Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing a compiler for a DSL in python

I am writing a game in python and have decided to create a DSL for the map data files. I know I could write my own parser with regex, but I am wondering if there are existing python tools which can do this more easily, like re2c which is used in the PHP engine.

Some extra info:

  • Yes, I do need a DSL, and even if I didn't I still want the experience of building and using one in a project.
  • The DSL contains only data (declarative?), it doesn't get "executed". Most lines look like:

    SOMETHING: !abc @123 #xyz/123

    I just need to read the tree of data.

like image 630
too much php Avatar asked Dec 04 '08 00:12

too much php


1 Answers

I've always been impressed by pyparsing. The author, Paul McGuire, is active on the python list/comp.lang.python and has always been very helpful with any queries concerning it.

like image 197
Matthew Trevor Avatar answered Oct 12 '22 06:10

Matthew Trevor