Writing a compiler for a DSL in python

前端 未结 8 1964
囚心锁ツ
囚心锁ツ 2021-02-02 03:51

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 py

8条回答
  •  耶瑟儿~
    2021-02-02 04:37

    Peter,

    DSLs are a good thing, so you don't need to defend yourself :-) However, have you considered an internal DSL ? These have so many pros versus external (parsed) DSLs that they're at least worth consideration. Mixing a DSL with the power of the native language really solves lots of the problems for you, and Python is not really bad at internal DSLs, with the with statement handy.

提交回复
热议问题