Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » problem with xtext and antlr(Decision can match input such as “'?'” using multiple alternatives: 1, 2)
problem with xtext and antlr [message #1133242] Fri, 11 October 2013 18:14 Go to next message
Luca Puglia is currently offline Luca PugliaFriend
Messages: 1
Registered: October 2013
Junior Member
0 down vote favorite


I'm using xText for writing a new eclipse plugin for a new language. But when I try to generate the code Antlr give me this warning:

Decision can match input such as "'?'" using multiple alternatives: 1, 2




I'm sure, after commenting much code, that the problem is in the following code snip:

...
Expression:
     operatorExpr=OperatorExpr (condExpr=CondExpr)?
     |exprPrimary=ExprPrimary (condExpr=CondExpr)?
;

CondExpr:
     '?'
;


ExprPrimary:
     Identifier
;

OperatorExpr:
     '+' expression=Expression
;
...


How can i solve the warning?
Re: problem with xtext and antlr [message #1135539 is a reply to message #1133242] Sun, 13 October 2013 07:56 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Given e.g.

+ <someIdentifier> ?

the parser cannot decide whether the '?' belongs to the Expression
holding the OperatorExpression or the one holding the PrimaryExpression.
This is equivalent to the famous dangling-else problem (Google).

You could use a syntactic predicate to solve this, but it looks like
you're trying to build an expression grammar, which should be structured
differently in LL grammars. I'd suggest to read
http://blog.efftinge.de/2010/08/parsing-expressions-with-xtext.html

Am 11.10.13 21:09, schrieb Luca Puglia:
> 0 down vote favorite
>
>
> I'm using xText for writing a new eclipse plugin for a new language. But
> when I try to generate the code Antlr give me this warning:
>
> Decision can match input such as "'?'" using multiple alternatives: 1, 2
>
>
>
> I'm sure, after commenting much code, that the problem is in the
> following code snip:
>
> ..
> Expression:
> operatorExpr=OperatorExpr (condExpr=CondExpr)?
> |exprPrimary=ExprPrimary (condExpr=CondExpr)?
> ;
>
> CondExpr:
> '?'
> ;
>
>
> ExprPrimary:
> Identifier
> ;
>
> OperatorExpr:
> '+' expression=Expression
> ;
> ..
>
> How can i solve the warning?
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: problem with xtext and antlr [message #1139572 is a reply to message #1135539] Tue, 15 October 2013 21:38 Go to previous message
NESARAJ THOMPSON is currently offline NESARAJ THOMPSONFriend
Messages: 1
Registered: October 2013
Junior Member
Can you please let me know how did you deploy the xtext project ? Is it integrated with eclipse as a plug-in?
Previous Topic:platform:/resource when projects sit outside the workspace?
Next Topic:Terminal
Goto Forum:
  


Current Time: Fri Apr 26 09:54:42 GMT 2024

Powered by FUDForum. Page generated in 0.02845 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top