3 ms·
You can write a macro that expands a grammar definition into the appropriate code. Anything a preprocessor can do, a macro can do like that.
by pfdietz 2y ago
You can write a macro that expands a grammar definition into the appropriate code. Anything a preprocessor can do, a macro can do like that.
- jjtheblunt 2y agoBut it’s the reverse direction that Bison/Yacc does, as it writes code to recognize essentially expanded grammar rules/macros, collapsing existing code into an expandable grammar rule/macro that would correspond. Thinking…if there’s an obvious equivalence
- pfdietz 2y agoUm, what? Bison/yacc generate compilable C from a grammar file. A CL macro would expand to Common Lisp starting from a grammar description. It's not the reverse at all.