Compile Time D Expression Parser?
youxkei at gmail.com
Mon Feb 27 19:24:21 PST 2012
(2012/02/28 2:24), d coder wrote:
> Is it possible to parse any EBNF of arbitrary complexity using your
> parser generator?
Yes, but some rewrites is required.
1) If your EBNF have (indirect) left recursion, you have to eliminate it
because the DSL which ctpg uses to generate parser is based on PEG,
parsing expression grammar.
For details, see: http://en.wikipedia.org/wiki/Parsing_expression_grammar .
2) As the example of parsing simple arithmetic expression shows, the
parser generated by ctpg have type such as int and string.
EBNF doesn't have type system so you have to add appropriate type
conversion into your EBNF.
More information about the Digitalmars-d