3 ms·
> Something like Yacc/Bison is easily done with suitable macros. Is this true? I may have misunderstood what macros can do in terms of remembering state, whil
by jjtheblunt 2y ago
> Something like Yacc/Bison is easily done with suitable macros.
Is this true? I may have misunderstood what macros can do in terms of remembering state, while applying. Looking it up again to see what i overlooked...
- pfdietz 2y agoYou 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.