looking for tips on how to implement "ruby-style" Domain Specific Language in Python

Jonathan Gardner jgardner at jonathangardner.net
Tue Jan 6 14:03:08 EST 2009


On Jan 6, 8:13 am, sturlamolden <sturlamol... at yahoo.no> wrote:
> On Jan 6, 4:32 pm, mark <mark.fi... at googlemail.com> wrote:
> >
> > Is it possible to
> > switch between the custom DSL and the standard Python interpreter?
> >
>
> - Write the DSL interpreter in Python.
>

There are Python modules out there that make writing a language
interpreter almost trivial, provided you are familiar with tools like
Bison and the theories about parsing in general. I suggest PLY, but
there are other really good solution out there.

If you are familiar enough with parsing and the syntax is simple
enough, you can write your own parser. The syntax you describe above
is really simple, so using str.split and then calling a function based
on the first item is probably enough.



More information about the Python-list mailing list