Skip to main content



      Home
Home » Modeling » TMF (Xtext) » problem grammar please(we need help please)
problem grammar please [message #532137] Fri, 07 May 2010 06:04 Go to next message
Eclipse UserFriend
Hi,
We have an other problem with the grammar and we need help.
Here is a simple example that points out that problem.

A basic grammar is :

Model :
information+=Information*

Information:
"name" name=ID "married" boolean=("0"|"1") ("number of children" number=INT )? ;

Suppose we have to parse file like this :
name Jacques married 1 number of children 4
name Anne married 0 number of children 0

Our first example is correct while the second example does not work. Very Happy
apparently the problem is that Xtext confuse boolean and integer.

How can I express that in Xtext? please
Re: problem grammar please [message #532170 is a reply to message #532137] Fri, 07 May 2010 07:56 Go to previous messageGo to next message
Eclipse UserFriend
The INT terminal will eat the 0 or 1 that you are trying to convert to
Boolean. You could create a Boolean rule that takes an INT and use data
coversion to turn it into a boolean.
- henrik
bouragba <bouragbamohamed@gmail.com> wrote:
> Hi,
> We have an other problem with the grammar and we need help.
> Here is a simple example that points out that problem.
>
> A basic grammar is :
>
> Model :
> information+=Information*
>
> Information:
> "name" name=ID "married" boolean=("0"|"1") ("number of children"
> number=INT )? ;
>
> Suppose we have to parse file like this :
> name Jacques married 1 number of children 4
> name Anne married 0 number of children 0
>
> Our first example is correct while the second example does not work.
> :d apparently the problem is that Xtext confuse boolean and integer.
>
> How can I express that in Xtext? please


--
- henrik
Re: problem grammar please [message #532182 is a reply to message #532137] Fri, 07 May 2010 08:51 Go to previous messageGo to next message
Eclipse UserFriend
In such cases one usually uses the boolean assignment operator:

... married?='married'? ...

or for explicitness in both cases

... (married?='married'|'unmarried') ...

which makes for a more concise syntax.

Sven

bouragba schrieb:
> Hi,
> We have an other problem with the grammar and we need help.
> Here is a simple example that points out that problem.
>
> A basic grammar is :
>
> Model :
> information+=Information*
>
> Information:
> "name" name=ID "married" boolean=("0"|"1") ("number of children"
> number=INT )? ;
>
> Suppose we have to parse file like this :
> name Jacques married 1 number of children 4
> name Anne married 0 number of children 0
>
> Our first example is correct while the second example does not work. :d
> apparently the problem is that Xtext confuse boolean and integer.
>
> How can I express that in Xtext? please


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de:
Re: problem grammar please [message #532387 is a reply to message #532137] Sun, 09 May 2010 09:40 Go to previous message
Eclipse UserFriend
Thanks a lot for your answers.
we used the answers of Henrik Lindberg and it work thanks.
Razz
Previous Topic:[XText] import dsl problem
Next Topic:Xpand Special Symbol: » Howto type on a mac
Goto Forum:
  


Current Time: Mon Jul 21 07:13:38 EDT 2025

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

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

Back to the top