Since most of the traffic here is linking to the post I had on working with a lexer/yacc in lisp, I thought that I’d share a link to a post on a more ‘lispy’ way to approach the issue.

Paul says :

To a CL’er, infix notation is just unnecessary syntactic sugar. Many novice CL’ers try to create macros that understand infix notation early on in their careers, but as they become more familiar with the power of CL, they drop the syntatic sugar and use parse trees directly.

Which is true – the structure of lisp is exactly what you get when you run a bunch of infix code through a lex/yac or even an ANTLR combination.

The problem that I had when I was investigating the issue was that most people don’t think in prefix notation the way a lisper would! The prefix (also know as ‘abstract syntax tree’ or AST for short) notation is much easier to deal with from a programming perspective, which is why the first step for almost all compilers is to translate things down to AST format. This is why the above advice makes perfect sense if you are creating a DSL for yourself, but may not work if you are trying to create one for the rest of the world.

Just random thoughts . . .

Advertisement