RoBOTL Grammar (version 3.0, can be parsed by LL(1) parsers)
Theo Van Dinter
Peter Sagerson
1997/11/02
Key:
----
[] = 0 or 1 (regexp = ()?)
{} = 0 or more (regexp = ()*)
<> = 1 or more (regexp = ()+)
Program -> [Declaration] Execution
/* World & Robot Declaration Section */
Declaration -> Define "{" [DMS_State] {DecState} "}"
DMS_State -> DMS Expression ";"
DecState -> WE_State | NRT_State | DGI_State
WE_State -> WorldEntity Name "{" {WE_Inst} "}"
WE_Inst -> Beeper_Inst | Block_Inst | Wall_Inst
Beeper_Inst -> Beeper At Coords ["=" Expression] ";"
Block_Inst -> Block At Coords ";"
Wall_Inst -> Wall From Coords Direction For Expression ";"
NRT_State -> NRT Name "{" IsLikeA Name ";" {NRT_Inst} "}"
NRT_Inst -> DNI_Inst | DIB_Inst | DI_Inst
DNI_Inst -> DNI Name As Instructions
DIB_Inst -> DIB Expression ";"
DI_Inst -> DI Name ["=" Expression] ";"
DGI_State -> DGI Name ["=" Expression] ";"
Coords -> Expression "," Expression
Direction -> North | East | West | South
/* Robot Execution Section (Statements) */
Execution -> Execute "{" {Statements} "}"
Statements -> Statement | "{" {Statements} "}"
Statement -> NewState | TellState | IterateState | PlaceState
| RemoveState | AssignState | TurnonState | TurnoffState
| IfState | WhileState | DoWhileState
NewState -> New Name Name [At Coords] ";"
TellState -> Tell Name ":" Instructions
IterateState -> Iterate Expression Times Statements
PlaceState -> Place Name [At Coords] ";"
RemoveState -> Remove Name ";"
AssignState -> Name "=" Expression ";"
TurnonState -> TurnOn All ";"
TurnoffState -> TurnOff All ";"
IfState -> If "(" Expression ")" Statements [Else Statements]
WhileState -> While Expression Statements
DoWhileState -> Do Statements While "(" Expression ")" ";"
/* Robot Execution Section (Instructions) */
Instructions -> Instruction | "{" {Instructions} "}"
Instruction -> MoveInst | AssignUserInst | IterateInst | IfInst | WhileInst |
DoWhileInst | SimpleInst
SimpleInst -> TurnOn ";" | TurnOff ";" | PutBeep ";" |
PickBeep ";" | TurnLeft ";"
MoveInst -> Move Expression ";"
AssignUserInst -> Name ( AssignInst | UserInst )
AssignInst -> "=" Expression ";"
UserInst -> ";"
IterateInst -> Iterate Expression Times Instructions
IfInst -> If "(" Expression ")" Instructions [Else Instructions]
WhileInst -> While Expression Instructions
DoWhileInst -> Do Instructions While "(" Expression ")" ";"
/* Expression Grammar */
Expression -> Exp1 {Or Exp1}
Exp1 -> Exp2 {And Exp2}
Exp2 -> Exp3 {RelOp Exp3}
Exp3 -> Exp4 {LtGt Exp4}
Exp4 -> Exp5 {AddOp Exp5}
Exp5 -> Exp6 {MulOp Exp6}
Exp6 -> Not Value | AddOp Value | Value
Value -> IntegerFunc | BoolFunc | "(" Expression ")" | Number | Name
IntegerFunc -> BeepersInBag | BeepersOnFloor | XPosition |
YPosition | MapSize
BoolFunc -> FrontIsClear | LeftIsClear | RightIsClear |
FacingNorth | FacingSouth | FacingEast | FacingWest
/* Basic Tokens - Case Insensitive */
Number -> <Digit>
Name -> Letter {Digit | Letter | "_"}
Letter -> "A-Z" | "a-z"
Digit -> "0-9"
TurnOff -> "turnoff"
TurnOn -> "turnon"
All -> "all"
Define -> "define"
Size -> "size"
WorldEntity -> "worldentity"
Beeper -> "beeper"
At -> "at"
Block -> "block"
Wall -> "wall"
From -> "From"
For -> "for"
North -> "north"
South -> "south"
East -> "east"
West -> "west"
NRT -> "newrobottype"
IsLikeA -> "islikea"
As -> "as"
DNI -> "definenewinstruction"
Execute -> "execute"
DI -> "defineinteger"
DIB -> "defineinitialbeepers"
DMS -> "definemapsize"
DGI -> "defineglobalinteger"
Tell -> "tell"
New -> "new"
Iterate -> "iterate"
Times -> "times"
Place -> "place"
Remove -> "remove"
If -> "if"
Else -> "else"
While -> "while"
Do -> "do"
Move -> "move"
TurnLeft -> "turnleft"
PickBeep -> "pickbeeper"
PutBeep -> "putbeeper"
Not -> "not" | "!"
BeepersInBag -> "beepersinbag"
BeepersOnFloor -> "beepersonfloor"
XPosition -> "xposition"
YPosition -> "yposition"
FrontIsClear -> "frontisclear"
LeftIsClear -> "leftisclear"
RightIsClear -> "rightisclear"
FacingNorth -> "facingnorth"
FacingSouth -> "facingsouth"
FacingEast -> "facingeast"
FacingWest -> "facingwest"
Or -> "or" | "||"
And -> "and" | "&&"
RelOp -> "!=" | "=="
LtGt -> ">" | "<" | ">=" | "<="
AddOp -> "+" | "-"
MulOp -> "*" | "/"
This guide is not great to look at under text-only browsers. Sorry.
Since you need a graphical browser for the applet, we figured you'd be
using it for the reference guide.
Document Last Revised: Friday November 14th, 1997 at 2:02pm
Copyright ©1997
Worcester Polytechnic Institute
Page Written by: Theo Van
Dinter (felicity@kluge.net)