我有一个名为的语法leach.xtext
,当我将它放入我的文件中的 Xtext 时,我myDsl.xtext
收到以下错误:
生成的包 'leach' 可能不是空的。
通过查看其他示例,他们都在 xtext 文件的开头添加了一些“规则”,然后指向语法中的第一个原始规则。但我不明白该怎么做。下面是整个语法,虽然我认为只有前几行应该是相关的。
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate leach "http://www.xtext.org/example/mydsl/MyDsl" //error appears here..
start : ('Prepare' ':' '{' ingredients '}')+ (procdef) cook;
cook : 'Cook' ID ':' '{' instructions serve ';' '}';
ingredients : ingredient ( ',' ingredient)*;
ingredient : amount food;
quality : 'large' | 'sliced' | 'finelySliced' | 'chopped' | 'fresh' | 'grated' |
'ground' | 'unsalted' | 'fluffy' | 'goldenBrown' ;
amount : INT (unit);
unit : 'l' | 'ml' | 'cl' | 'oz' | 'g' | 'kg' | 'tesp' | 'tbsp';
temperature : INT heat;
heat : 'c' | 'f';
tlength : tunit '(' INT ')';
tunit : 'sec' | 'min';
hobheat : 'LOW' | 'MEDIUM' | 'HIGH';
hob : 'hob1' | 'hob2' | 'hob3' | 'hob4';
food : 'cookingApples' | 'sugar' | 'shortcrustPastry' | 'wensleydaleCheese' | 'whippedCream' |
'bacon' | 'redOnion' | 'doubleCream' | 'flatleatParsley' | 'parmesan' | 'greenSalad' |
'tomatoKetchup' | 'blackPepper' | 'goldenSyrup' | 'vanillaExtract' | 'brownSugar' | 'eggs' |
'pecanNuts' | 'lard' | 'vegetableOil' | 'butter' | 'readyPastry' | 'salt' | ID ;
instructions : (instruction);
instruction : 'if' '(' expr ')' '{' instructions '}' ( 'else' '{' instructions '}') |
whil '(' expr ')' '{' instructions '}' |
'do' '{' instructions '}' whil '(' expr ')' |
process ';' |
assign ';' |
cook;
whil : 'while' | 'until';
assign : 'set' varname '=' expr;
varname : '@' ID;
process : 'Preheat' '(' temperature ')' |
'AddToOven' '(' container ')' |
'Slice' '(' food ',' amount ')' |
'RemoveFromHeat' '(' container ')' |
'Drain' '(' container ')' |
'Grease' '(' container ',' food ')' |
'Layer' '(' container ',' food ')' |
'SetHeat' '(' ( (hobheat ',' hob) | temperature ) ')' |
'Whisk' '(' container ')' |
'Stir' '(' container ')' |
'AddTo' '(' container ',' food ',' amount ')' |
'PutOnHub' '(' container ',' hob ')' |
'Wait' '(' (expr | tlength)+ ')' |
'EmptyTo' '(' container ',' container ')' |
'MoveTo' '(' container ',' food ',' amount ')' |
'~' ID '(' (expr (',' expr) ) ')' ;
procdef : 'function' ID '(' (expr (',' expr) ) ')' block;
block : '{' instructions (retur)? '}';
serve : 'serve' (container | '@'ID);
retur : 'return' expr ';' ;
container : 'bowl' | 'saucePan' | 'fryingPan' | 'bakingTray' | 'pieDish' | 'plate';
expr : e1 ('~~' e1 |
'<' e1 |
'<=' e1 |
'>' e1 |
'>=' e1 |
'==' e1 |
'!=' e1 )*;
e1 : e2 ('^' e2)*;
e2 : e3 ('|' e3)*;
e3 : e4 ('&' e4)*;
e4 : e5 ('+' e5 | '-' e5)*;
e5 : e6 ('*' e6 | '/' e6 | '&' e6)*;
e6 : ('!') e7;
e7 : e8 ('**' e7);
e8 : 'true' | 'false' | INT | quality | food | container | process | '(' expr ')';