My company is designing a new domain specific scripting language; I have to implement a parser that translates our brand new programming language into a common scripting lan
Well, "the usual" way to do this in Common Lisp is … to do it in Lisp.
A lot of domain-specific languages (and Lisp is pretty much notoriously specialized for this purpose!) are simply written as extensions to Lisp itself, using the macro facility. The upside is, it's trivial to write a DSL. The downside is, they often tend to "look like" lisp.
Some examples of DSL's within the Common Lisp standard include the LOOP
macro's own sub-language and the sub-language of the FORMAT
specifiers.
Since Lisp's s-expression notation is nominally a written form of an Abstract Syntax Tree, it's one way to avoid having much of your own lexer or parser; you can just use READ
.
That all being said, you can use some common packages that might be found in GRAYLEX
or CL-LEXER
or so forth; looking at the parsers for some other language with a similar syntax to yours might help. In Quicklisp, I see:
CL-USER> (ql:system-apropos "parse")
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#