Skip to main content



      Home
Home » Modeling » TMF (Xtext) » (no subject)
(no subject) [message #677525] Wed, 08 June 2011 14:04 Go to next message
Eclipse UserFriend
Hi,

I have alittle problem with the factoring in my grammar that i couldnt figure out :

i have the flowwing grammar :
Quote:
> P returns P:
> {P}
> '{{ '
> ('id' id=String0)?
> (attr+=AddAttr)?
> '}'
> (c=C)?
> '}}';
>
> AddAttr returns AddAttr:
> {AddAttr}
> ('rId' rId=Int0)?
> ('value' value=String0)?
> ;
> Int0 returns type::Int:
> STRING
> ;
>
> String0 returns type::String:
> STRING
> ;


Any ideas where the error
Quote:
> Decision can match input such as "'}'" using multiple alternatives

comes from
thanks
Re: Decision can match input such as "'}'" using multiple alternatives [message #677568 is a reply to message #677525] Wed, 08 June 2011 14:53 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

rules, where everything is optional are a bit problematic. If you want
to have an AddAttr-Object in your model, I guess there should be some
content (at least one of rId or value). You could write that as

AddAttr returns AddAttr:
{AddAttr}
('rId' rId=Int0)
('value' value=String0)?
| ('value' value=String0)
;

Then you probably mean P either to have the line
(attr+=AddAttr)*
or
(attr=AddAttr)?

And here is one Problem (similar to the one you are facing). Assume you
go with the above AddAttr-definition where at least one feature is not
null and you have a model file

P{{ id "id"
rId "rId"
value "value
} //unclear what this bracket is doing here
//and your snippet did not say anything about C
}}

Now the parser cannot decide whether there is one AddAttr with both
features set or two (for the first one only rId is set, for the second
one only value is set). There is no syntactic help for deciding that
question. I don't know if you have influence on the language design but
the standard solution is a separator. Something like

(attr+=AddAttr (',' attr+=AddAttr)*)?

Alex

P.S.: Note also that it is not a good idea to put spaces into keywords.

Am 08.06.11 20:04, schrieb elhamlaoui:
> Hi,
>
> I have alittle problem with the factoring in my grammar that i couldnt
> figure out :
>
> i have the flowwing grammar :
> Quote:
>> P returns P:
>> {P}
>> '{{ '
>> ('id' id=String0)?
>> (attr+=AddAttr)?
>> '}'
>> (c=C)?
>> '}}';
>>
>> AddAttr returns AddAttr:
>> {AddAttr}
>> ('rId' rId=Int0)?
>> ('value' value=String0)?
>> ;
>> Int0 returns type::Int:
>> STRING
>> ;
>>
>> String0 returns type::String:
>> STRING
>> ;
>
>
> Any ideas where the error Quote:
>> Decision can match input such as "'}'" using multiple alternatives
>
> comes from
> thanks
Re: Decision can match input such as "'}'" using multiple alternatives [message #677570 is a reply to message #677525] Wed, 08 June 2011 15:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

please find the following line in your rule P:

(attr+=AddAttr)?

Your rule AddAttr is defined like this:

AddAttr returns AddAttr:
{AddAttr}
('rId' rId=Int0)?
('value' value=String0)?
;

The parse cannot decide whether to dive into AddAttr from rule P or not
if there is no input. The assignment attr+=AddAttr is optional, that is
it could skip that. On the other hand, the content of the rule AddAttr
is optional too so it would be save to call the rule and simply skip all
parts of it. The question is: which path to choose?

You'll have to change your grammar. Either the assignment itself is
mandatory or at least one part of the AddAttr has to be mandatory.

Hope that helps,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 08.06.11 20:04, schrieb elhamlaoui:
> Hi,
>
> I have alittle problem with the factoring in my grammar that i couldnt
> figure out :
>
> i have the flowwing grammar :
> Quote:
>> P returns P:
>> {P}
>> '{{ '
>> ('id' id=String0)?
>> (attr+=AddAttr)?
>> '}'
>> (c=C)?
>> '}}';
>>
>> AddAttr returns AddAttr:
>> {AddAttr}
>> ('rId' rId=Int0)?
>> ('value' value=String0)?
>> ;
>> Int0 returns type::Int:
>> STRING
>> ;
>>
>> String0 returns type::String:
>> STRING
>> ;
>
>
> Any ideas where the error Quote:
>> Decision can match input such as "'}'" using multiple alternatives
>
> comes from
> thanks
Re: Decision can match input such as "'}'" using multiple alternatives [message #677736 is a reply to message #677570] Thu, 09 June 2011 05:12 Go to previous message
Eclipse UserFriend
Hi,

thanks Alexander and Sebastian, its working now Very Happy
Previous Topic:Extending XbaseScopeProvider in Domainmodel example
Next Topic:Decision can match input such as "'}'" using multiple alternatives
Goto Forum:
  


Current Time: Sun Nov 09 06:45:49 EST 2025

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

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

Back to the top