[antlr-interest] Tree rewriting: java.lang.RuntimeException more than one node as root

Jeroen van Schagen jeroen.v.schagen at gmail.com
Thu Aug 13 05:59:14 PDT 2009


Hello,

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:

module simple

def main
    html { title "Hello world"; }
end

But when I start adding attributes or arguments to my *title* tag the
exceptions start occuring, for example:

html { title#myidattribute "Hello world"; }

My rewrite rules are probably specified incorrectly, but I cannot seem to
figure out how to fix the problem. If somebody could give me some pointers
that would be greatly appreciated. Below is the related grammar:

statement: markup+ statement -> ^( markup markup* ',' statement )
            | ... ;
markup:            designator arguments? ;
designator:        IDCON attribute* ;
attribute:        '#' IDCON // ID attribute
            | '.' IDCON // Class attribute
            | '$' IDCON // Name attribute
            | ':' IDCON // Type attribute
            | '@' NATCON // Width attribute
            | '@' NATCON '%' NATCON; // Width-height attribute
arguments:        '(' argument? ( ',' argument )* ')' ;
argument:        expression ;

URL:
http://code.google.com/p/waebric/source/browse/#svn/trunk/implementations/java/antlr/src/main/grammar

Thanks in advance,
Jeroen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090813/580dca9e/attachment.html 


More information about the antlr-interest mailing list