I have been trying all day to get the rule below accepted (oh yeah,
that doesn't count about 2 hours wasted before I figured out that you
can't have a space after the right curly brace and the question mark
in a semantic predicate (grin))
I get a "cannot generate the grammar because" error which is
rule expression alt 1 uses rewrite syntax and also an AST operator
Now, I'm pretty certain this is happening because of the "^" that
follows lhs = simpleExpression^ in the first section of the rule.
However, removing that operator causes no tree node to be generated in
the case where there is just a simple expression. However, I tried
removing that operator and adding a rewrite rule after the FIRST
closing right brace, e.g.
lhs = simpleExpression
{
$type = $lhs.type;
} -> ^($lhs)
and many variants but this just caused ANTLR to complain that
comparisonOperator was an unexpected token. I also tried inserting a
third predicate in the bottom group that would test whether $rhs was
null and just put out the $lhs in that case but that didn't work either.
Can somebody please put me out of my misery (in a kind manner (grin))
and show me what I'm doing wrong? I'd love to have a quiet weekend
with no problems to worry about!!!
Thanks,
D
------------------------------------------------------------------
expression returns [TAttributeType type]
:
optionalSign
lhs = simpleExpression^
{
$type = $lhs.type;
}
(
(comparisonOperator rhs = simpleExpression)
{
$type =
TErrorHandling.Compatible($comparisonOperator.tree.token,
$comparisonOperator.token, $lhs.type, $rhs.type);
}
-> { isString($lhs.type) }? ^(comparisonOperator
STRINGOP $lhs $rhs)
-> ^(comparisonOperator $lhs $rhs)
)*
;
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
-~----------~----~----~----~------~----~------~--~---