looking for tips on how to implement "ruby-style" Domain Specific Language in Python
mark.fink1 at googlemail.com
Tue Jan 6 16:32:20 CET 2009
I want to implement a internal DSL in Python. I would like the syntax
as human readable as possible. This means no disturbing '.;()\'
characters. I like to have the power of the hosting language as well.
Thats why I want to build it as an internal DSL and NOT as a external
I want the DSL as human readable as possible:
navigate_to 'www.openstreetmap.org' website
search 'Von-Gumppenberg-Strasse, Schmiechen'
Martin Fowler recommends "Method Chaining" to build internal DSLs:
.search("Von-Gumppenberg-Strasse, Schmiechen") \
I guess that it is possible to argue that this means the same.
Nevertheless I do not like all the parentheses and punctuation
necessary to satisfy the Python interpreter.
The reason why I need this is that I want to have non technical people
review the files written in the DSL.
I already know that there are parser frameworks available but I want
to build it as internal DSL in Python (Yes, I know ANTLR, Ply, and
How would one approach this in Python? Do I need to build a custom
loader which compiles *.dsl files to *.pyc files? Is it possible to
switch between the custom DSL and the standard Python interpreter?
More information about the Python-list