At 00:59 14/08/2009, Jeroen van Schagen wrote:
>I recently started writing an interpreter for the WAEBRIC
>language, which is a language for generating XHTML code based on
>self defined function blocks. However, I keep getting runtime
>exceptions when running my parser. The following program
>interprets fine:
[...]
>statement: markup+ statement -> ^( markup markup* ',' statement )
>
> | ... ;
>markup: designator arguments? ;
The root of a tree must be a single token/node. Since the markup
rule can match more than one token, it doesn't qualify. When you
have situations like this, it's often best to use an imaginary
token as the root (and it's frequently useful even in other cases,
to make the tree easier to read or parse in a tree parser.)
statement
: markup+ statement
-> ^(STATEMENT markup+ ',' statement)
;
Although bear in mind that as written, this rule is ambiguous --
it's nonsensical to follow a list of markup with a statement
because a statement is just more markup. It's also a bit strange
to put a generated comma into the rewrite; the tree nesting should
be sufficient indication of structure.
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---