[antlr-interest] Mismatched Tree Node and lack of StringTemplateoutput
Jim Idle
jimi at temporal-wave.com
Wed Jun 6 14:55:59 PDT 2007
When you say that ISTRUCT is defined as:
ISTRUCT:;
Do you meant that your lexer rule for the token is empty, or that you
have declared it in the tokens section as an imaginary? If the former
then it isn't a valid token definition, if the latter then this is
usually a warning that will eventually go away, about imaginary tokens
not being declared in the lexer.
I think that you are trying to define and use an imaginary token
however:
tokens
{
ISTRUCT;
}
Which you can then use in your rewrite rule. Indeed that is mostly what
they are for.
Your AST error sounds like something unrelated to this though in that
your parser is not producing the tree that your tree parser is
expecting.
You need to check that your tree grammar rule matches exactly the tree
you are producing. You need to produce syntactically perfect trees and
also a grammar that considers what you are producing to be that syntax
;-).
So if you explicit or implicit tree production produces
^(FRED ^(VERSION blah))
But your tree parse is actually looking for:
^(FRED VERSION blah)
Then this is the kind of thing you are going to see.
Jim
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Cameron Palmer
Sent: Wednesday, June 06, 2007 1:38 PM
To: ANTR Interest
Subject: [antlr-interest] Mismatched Tree Node and lack of
StringTemplateoutput
I created a rule to appear in my AST that involved an imaginary token:
dsBody
: id COLON INT EOL
iStructElements -> ^(ISTRUCT id INT iStructElements)
;
Where ISTRUCT is defined:
ISTRUCT :;
This throws a warning:
The following token definitions are unreachable: ISTRUCT.
Should I worry about this?
Second question...
I am getting This error:
SDFWalker.g: node from line 0:0 mismatched tree node: DOWN expecting
VERSION
Thanks,
Cameron.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070606/e7dc7abd/attachment-0001.html
More information about the antlr-interest
mailing list