Question concerning grammar [message #877651] |
Sun, 27 May 2012 09:40 |
egger 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 |
|
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
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.03086 seconds