-
Notifications
You must be signed in to change notification settings - Fork 65
Generating Code
PhilippeSigaud edited this page Mar 18, 2012
·
15 revisions
Once a grammar is defined and a parse tree generated, how can it be used? We already saw how to use the parse tree in Using the Parse Tree, at runtime or compile-time. But since Pegged can parse at compile-time, the information can also be used to generate a string containing D code, which can in turn be mixed in standard D code.
This is exactly what Pegged itself does with the input you give it.
So, what's the difference with what we saw in lesson Using the Parse Tree?
None whatsoever, except be sure to do everything at compile-time, since you cannot mix runtime strings in.
Next lesson: User-Defined Parsers