Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module robot
- import Prelude;
- keyword MyKeywords = "begin" | "end" | "if" | "while" | "else" | "do" | "repeat" ;
- layout Layout = Whitespace* !>> [\ \t\n\r];
- lexical Whitespace = [\ \t\n\r];
- lexical Name = [a-zA-Z] !<< [a-zA-Z]+ !>> [a-zA-Z] \ MyKeywords ;
- lexical Integer = [0-9] !<< [0-9]+ !>> [0-9];
- lexical String = [\"] ![\"]* [\"];
- lexical CommentText = ![\n]* [\n];
- start syntax RobotProgram =
- program: "Script" Name scriptName "runs as"
- {Statement ""}* body
- "end";
- syntax Statement =
- Command com
- | ifStatement: "if" Expression cond "do" {Statement ""}* body "end"
- | ifElseStat: "if" Expression cond "do" {Statement ""}* body "end" "else do" {Statement ""}* elsebody "end"
- | While: "while" Expression cond "do" {Statement ""}* body "end"
- | Repeat: "repeat" Integer int "times" {Statement ""}* body "end"
- | Comment: "#" CommentText body;
- syntax Command =
- "step" | "turnLeft" | "drop" | "pick"
- | "trace" String message
- | "buildWall at" "row:" Integer introw "col:" Integer intcol
- | "destroyWall at" "row:" Integer introw "col:" Integer intcol
- | "dropMark at" "row:" Integer introw "col:" Integer intcol
- | "pickMark at" "row:" Integer introw "col:" Integer intcol;
- syntax Expression =
- "full" | "mark" | "wall ahead" | "heading" Direction dir
- | not: "not" Expression exp
- | and: Expression exp1 "and" Expression exp2
- | or: Expression exp1 "or" Expression exp1 ;
- syntax Direction = "south" | "north" | "west" | "east" ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement