Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Question concerning grammar
Question concerning grammar [message #877651] Sun, 27 May 2012 05:40 Go to next message
Eclipse UserFriend
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 05:58 Go to previous messageGo to next message
Eclipse UserFriend
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

Re: Question concerning grammar [message #877683 is a reply to message #877655] Sun, 27 May 2012 07:46 Go to previous message
Eclipse UserFriend
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 08:01] by Moderator

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


Current Time: Wed Jul 23 15:17:46 EDT 2025

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

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

Back to the top