Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Question concerning grammar
Question concerning grammar [message #877651] Sun, 27 May 2012 09:40 Go to next message
egger is currently offline eggerFriend
Messages: 13
Registered: November 2011
Junior Member
Hello all!

I have concering problems with my grammar definition. I would like to define the grammar for the syntax below. But xtext says, that line one an two are incorrect (red x on the left side of the code line). I think i have some problems with the =Clip( definition but i don't know what it could be? Any suggestions?

Best regards, egger


Syntax:
[Structures]
Structure1=CT1Prostata25mmBecken2,Skelett,SkelettStructure1
Structure2=CT1Prostata25mmBecken2,CTVprostata2,PTVStructure1
Structure3=Box(v{SkelettStructure1.xmin},v{SkelettStructure1.ymin},v{SkelettStructure1.zmin}+v{SkelettStructure1.d}*0.33,v{SkelettStructure1.w}*0.25,v{PTVStructure1.ymax}-v{SkelettStructure1.ymin}+v{SkelettStructure1.w}*0.04,v{SkelettStructure1.d}*0.45),FemurRightBoxStructure1
Structure5.PreProcess1=Clip(FemurRightBoxStructure1,1)



Grammar/xtext:
Model :
	structures+=Structure+ 
;
Structure :
	'[Structures]' 
	astructure+= AbstractStructure*

;

AbstractStructure: 
	StructureElement | StructurePreProcess
;

StructureElement:
	ORAStructure | Box 
;
StructurePreProcess:
	Clip
;
ORAStructure:
	name=ID "=" StructureSetUid "," StructureUid "," newStructureUid = ID 
;

Box :
	name=ID "=Box(" args=Arguments ")," newStructureUid = ID
;

Clip:
	name=UnifiedName "=Clip(" newStructureUid = ID "," INT ")"  
;
UnifiedName : 
	ID "." ID
;
Arguments:
	("{"|ID|INT|FLOAT|OPERATOR|"}"|"."|",")*
;

/**
 * Predefined Keywords
 * 
 */
StructureSetUid:
	"CT1Prostata25mmBecken2" | "CT1Prostata06mmGoldmarker"
;
StructureUid:
	"Skelett" | "CTVprostata2"
;

/**
 * Terminals
 * 
 */
terminal OPERATOR :
	('+'|'-'|'*'|'/')+
;
terminal FLOAT :
	INT+ "." INT+
;
Re: Question concerning grammar [message #877655 is a reply to message #877651] Sun, 27 May 2012 09:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13488
Registered: July 2009
Senior Member
Hi,

there are a lot of problems/bad ideas in your grammar:

the grammar goes into a parser. the parser is based on a lexer. and that is greedy and dislikes ambiguities.

- do not mix keywords like "=Clip(" better split them up "=" "Clip" "(" (problem occurs at other places too)
- you do not need a float rule at all since Arguments mixes everything up anyway

~Christian



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Question concerning grammar [message #877683 is a reply to message #877655] Sun, 27 May 2012 11:46 Go to previous message
egger is currently offline eggerFriend
Messages: 13
Registered: November 2011
Junior Member
hi christian,

thanks for your hints! the whole topic is really new to me. i'm open for all the feedback i can get Wink best regards, egger

[Updated on: Sun, 27 May 2012 12:01]

Report message to a moderator

Previous Topic:Auto formater XText
Next Topic:Non-LL1 Grammar handling with JvmTypes
Goto Forum:
  


Current Time: Mon Jul 06 13:32:32 GMT 2020

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

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

Back to the top