behaviours generate just fine now, missions is next. We also need some color functions
[des2015.git] / dsl / xtend / src / robots / missions / TaskDSL.xtext
1 grammar robots.missions.TaskDSL with org.eclipse.xtext.common.Terminals
2
3 generate taskDSL "http://www.missions.robots/TaskDSL"
4
5 Robot:
6 'Name' name=ID
7 'Acceleration' acc=INT
8 'Speed' spd=INT
9 behaviour+=Behaviour+
10 mission+=Mission+;
11
12 Mission: 'Mission' name=ID 'using' behaviours+=[Behaviour]+ 'and stops when' stoppingExpression=StoppingExpression;
13
14 StoppingExpression:
15 '(' op=Operator s+=StoppingExpression s+=StoppingExpression+ ')' |
16 scond=StoppingCondition
17 ;
18
19 StoppingCondition:
20 'Collected at least' colors+=Color+ |
21 'Touched on' touch=LeftRight |
22 'Distance' op=Comparison dist=INT 'cm' |
23 'Color is' color=Color;
24
25 Behaviour: 'Behaviour' name=ID
26 'take control:' tc=StoppingExpression?
27 'action:' actions+=Action+;
28
29 Action:
30 whichMotor=LeftRight 'motor' dir=Direction ('with speed' spd=INT 'acceleration' acc=INT)? |
31 'wait' time=Time;
32
33 Time: time=INT 'ms' | {Time} 'forever';
34
35 Direction: d=DirectionE;
36 enum DirectionE: BACKWARDS = 'backward' | FORWARDS = 'forward';
37 Operator: d=OperatorE;
38 enum OperatorE: AND = 'and' | OR = 'or';
39 Comparison: d=ComparisonE;
40 enum ComparisonE: GE='>' | LE='<';
41 LeftRight: d=LeftRightE;
42 enum LeftRightE: LEFT='left' | RIGHT='right';
43 Color: d=ColorE;
44 enum ColorE:
45 BLACK='Black' | BLUE='Blue' | BROWN='Brown' | CYAN='Cyan' |
46 DARKGRAY='DarkGray' | GRAY='Gray' | GREEN='Green' |
47 LIGHTGRAY='LightGray' | MAGENTA='Magenta' | ORANGE='Orange' | PINK='Pink' |
48 RED='Red' | WHITE='White' | YELLOW='Yellow';