I am trying to do something that seems pretty simple, which is adjusting the
root token of a tree in my tree parser.
Basically my parser always sees a=b as a comparison and generates ^( EQUAL a
b) as an AST, and in the tree parser I want to adjust that to ^( ASSIGN a b)
if I am at the statement
My parser grammar can generate a number of subtrees with similar structure,
and just a different root type. In the tree grammar I am trying to just pass
such a subtree along without any changes, but that is turning out to be much
trickier than I expected, am I missing something?
Given this AST:
Hello,
is ST and/or Antlr can solve that problem?
Sure, it can! But a pattern matching framework could be a better
alternative because it is more straight forward in mapping input to
output. However, if you at all costs want to use ANTLR in combination
with StringTemplate, you need to do the
Christian wrote
Hi,
what is the error/exception message?
Regards,
Christian
MissingTokenException at the second '=', after parsing a=b.c as an
expression. The tail recursion on expr is causing it it seems, but that's a
real issue for me... here is a slightly modified version with
Mh, I am with you. I also do not understand backtracking in this
situation ;)
Could anyone else explain it, please?
Am 28.11.2011 15:18, schrieb franck102:
Christian wrote
Hi,
what is the error/exception message?
Regards,
Christian
MissingTokenException at the second '=', after parsing
On Mon, Nov 28, 2011 at 9:02 AM, Christian chw...@gmx.de wrote:
Mh, I am with you. I also do not understand backtracking in this
situation ;)
Could anyone else explain it, please?
Pretty sure you are having problems because you have '.' as an
inline/generated token in your rules. I've said
expr : ID suffix;
will try to match the sep '.'. backtrack takes first alt that wins and the
decision for suffix needs to backtrack due to your program rule. therefore it
attempts '.' expr and fails.
allowing …… as a program is not a good idea ;)
T
On Nov 26, 2011, at 4:21
Greetings!
On 11/28/2011 08:08 AM, franck102 wrote:
My parser grammar can generate a number of subtrees with similar structure,
and just a different root type. In the tree grammar I am trying to just pass
such a subtree along without any changes, but that is turning out to be much
trickier
Try turning backtrack mode off and see what ANTLR says about your
production. This will give you the clue that you need. You probably need
to add an explicit predicate. Clearly, you rules below are ambiguous on
the '.' as it is a separator. So it thinks you are parsing ID '.' as a
statement.
The
This answer is incorrect - the '.' will be the same token. See my earlier
answer.
Jim
-Original Message-
From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
boun...@antlr.org] On Behalf Of Kirby Bohling
Sent: Monday, November 28, 2011 8:18 AM
To: Christian
Cc:
None of those suggestion will help with the actual grammar unfortunately. It
is indeed ambiguous, that is the warning I get if I turn backtracking off,
but I can't refactor the rules (or the actual, large grammar) w/o ending
with a completely meaningless AST.
I still don't understand why antlr
Thanks John,
I had tried the first one (using a label assigned in each branch of the
alternative), I just posted it wrong.
Your 2nd 3rd suggestions should work I expect, thanks!
Too bad the most natural one ^( ( AND | OR ) ... w/o rewrite doesn't work...
--
View this message in context:
12 matches
Mail list logo