Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


But 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


Um, 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: