Skip to main content



      Home
Home » Modeling » TMF (Xtext) » problem in Grammar
problem in Grammar [message #520002] Wed, 10 March 2010 13:11 Go to next message
Eclipse UserFriend
Hello,
I'm having a problem with the following grammar;
Can you please help me out.
Thanx
Quote:

Configuration : "Configuration" name=ID1
( TypeList+=Type )*
"Instances"
( InstanceList=Instance)*
"Attachments"
( att+=Attachment )*
"End Configuration";

Instance: ComponentInstance | ConnectorInstance ;

Type: Component| Connector;

Component : "Component" name=ID1
( port+=Port )*
"Computation" '=' computation=ProcessExpression ;

Connector : "Connector" name=ID1
( role+=Role )*
"Glue" '=' glue=ProcessExpression ;

Port : "Port" name=ID1 '=' behavior=ProcessExpression;

Role : "Role" name=ID1 '=' behavior=ProcessExpression;

ComponentInstance : name=ID1 ':' type=[Component];

ConnectorInstance : name=ID1 ':' type=[Connector];

Attachment : originInstance=[ComponentInstance] '.' originPort=[Port] "As" targetInstance=[ConnectorInstance] '.' originRole=[Role] ;

ProcessExpression : TerminalProcessExpression ( binaryOp=( '[]' | '|~|' ) right=ProcessExpression)?;//

TerminalProcessExpression returns ProcessExpression: Prefix |Process |Parenthese;//

//ProcessExpression : Prefix |Process |Parenthese | ExternalChoice | InternalChoice ;

//ExternalChoice: left=ProcessExpression "[]" right=ProcessExpression;

//InternalChoice: left=ProcessExpression "|~|" right=ProcessExpression;

Process: name=ID1 ;

Parenthese: '(' p=ProcessExpression ')';

Prefix: event=EventExpression '->' target=ProcessExpression;

EventExpression : EventSignalled | EventObserved | InternalTraitement;

EventSignalled: name=QUALIFIED_NAME1 (data+=Data)*;

EventObserved: name=QUALIFIED_NAME2 (data+=Data)*;

InternalTraitement: name=QUALIFIED_NAME3;

Data: ('?' | '!') name=ID1;

terminal QUALIFIED_NAME1 :'_' (ID1)+ '.' (ID1)*;

terminal QUALIFIED_NAME2 : (ID1)+ '.' (ID1)*;

terminal QUALIFIED_NAME3 : '0' (ID1)+ '.' (ID1)*;

terminal ID1 : ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;

Re: problem in Grammar [message #520042 is a reply to message #520002] Wed, 10 March 2010 17:29 Go to previous messageGo to next message
Eclipse UserFriend
Hello,
I'm having a problem with the following grammar;
Can you please help me out.
Thank you for your help
Quote:

ComponentInstance : name=ID1 ':' type=[Component];

ConnectorInstance : name=ID1 ':' type=[Connector];

Attachment : originInstance=[ComponentInstance] '.' originPort=[Port] "As" targetInstance=[ConnectorInstance] '.' originRole=[Role] ;

ProcessExpression : TerminalProcessExpression ( {Operation.left=current} binaryOp=( '[]' | '|~|' ) right=ProcessExpression)?;//

TerminalProcessExpression returns ProcessExpression: Prefix |Process |Parenthese;
...

Re: problem in Grammar [message #520118 is a reply to message #520042] Wed, 10 March 2010 23:04 Go to previous messageGo to next message
Eclipse UserFriend
And, what exactly is the problem with your grammar? What is it you need
help with?
Kind of hard to guess ;)

- henrik

farah <farah.fourati@hotmail.fr> wrote:
> Hello,
> I'm having a problem with the following grammar;
> Can you please help me out.
> Thank you for your help
> Quote:
> > ComponentInstance : name=ID1 ':' type=[Component];
> > > ConnectorInstance : name=ID1 ':' type=[Connector];
> > > Attachment : originInstance=[ComponentInstance] '.'
> > > originPort=[Port] "As" targetInstance=[ConnectorInstance] '.'
> > > originRole=[Role] ;
> > > ProcessExpression : TerminalProcessExpression (
> > > {Operation.left=current} binaryOp=( '[]' | '|~|' )
> > > right=ProcessExpression)?;//
> > > TerminalProcessExpression returns ProcessExpression: Prefix
> > > |Process |Parenthese;
> > ...
>
>


--
- henrik
Re: problem in Grammar [message #520224 is a reply to message #520118] Thu, 11 March 2010 10:33 Go to previous messageGo to next message
Eclipse UserFriend
Hello, I am not an expert at xtext. I am just a biginner, and I would like to use xtext in order to obtain the xmi file of the metamodel generated in order to move from one model to another.
the grammar that I have just written presents errors dues at the left recursive call as well as few problems with ':' and '->'. how can I fix these problems? the following part represents my grammar:I would like to know whether add something else apart from the input grammar and text in order to have the xmi file

with my best rgards
Farah
Re: problem in Grammar [message #520250 is a reply to message #520224] Thu, 11 March 2010 11:58 Go to previous messageGo to next message
Eclipse UserFriend
Worry about one thing at a time. First you must have a working grammar.
Then you can create an instance of the model, serialized etc.

Please look at the documentation for how to deal with left recursion and
precedence. Sven posted a link to a typical expression grammar that may
serve as inspiration. Or, for a larger more complex grammar, look at b3.

If still stuck, it is easier to help you if you can ask more specific
questions. Which part of the grammar is not working, what is the
expected input that it is supposed to parse, etc. Just seeing a grammar
for an unknown language does not give all that much to go on (at least
not for me ;)

Regards
- henrik

farah <farah.fourati@hotmail.fr> wrote:
> Hello, I am not an expert at xtext. I am just a biginner, and I would
> like to use xtext in order to obtain the xmi file of the metamodel
> generated in order to move from one model to another.
> the grammar that I have just written presents errors dues at the left
> recursive call as well as few problems with ':' and '->'. how can I
> fix these problems? the following part represents my grammar:I would
> like to know whether add something else apart from the input grammar
> and text in order to have the xmi file
>
> with my best rgards
> Farah
>


--
- henrik
Re: problem in Grammar [message #520420 is a reply to message #520250] Fri, 12 March 2010 05:41 Go to previous message
Eclipse UserFriend
thank you for your help
for the left recursivty I resourced on the xtext documentation

and this is the code
Quote:

ProcessExpression : TerminalProcessExpression ( {binary.left=current} binaryOp=choice right=ProcessExpression)?;

TerminalProcessExpression returns ProcessExpression: Prefix |Process |Parenthese | ProcessExpression ;
enum choice: EC = '[]' |IC = '|~|' ;




in EBNF I Write
Quote:

ProcessExpression : Prefix |Process |Parenthese | ExternalChoice | InternalChoice ;

ExternalChoice: left=ProcessExpression "[]" right=ProcessExpression;

InternalChoice: left=ProcessExpression "|~|" right=ProcessExpression;


This grammar is that of Wright ADL

with my best rgards
Farah

[Updated on: Fri, 12 March 2010 05:45] by Moderator

Previous Topic:Newbie Grammar not working
Next Topic:Problem resolving imports
Goto Forum:
  


Current Time: Sat Jul 05 03:21:32 EDT 2025

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

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

Back to the top