Advertisement
Guest User

Untitled

a guest
May 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. module robot
  2.  
  3. import Prelude;
  4.  
  5. keyword MyKeywords = "begin" | "end" | "if" | "while" | "else" | "do" | "repeat" ;
  6.  
  7. layout Layout = Whitespace* !>> [\ \t\n\r];
  8. lexical Whitespace = [\ \t\n\r];
  9.  
  10. lexical Name = [a-zA-Z] !<< [a-zA-Z]+ !>> [a-zA-Z] \ MyKeywords ;
  11. lexical Integer = [0-9] !<< [0-9]+ !>> [0-9];
  12. lexical String = [\"] ![\"]* [\"];
  13. lexical CommentText = ![\n]* [\n];
  14.  
  15. start syntax RobotProgram =
  16. program: "Script" Name scriptName "runs as"
  17. {Statement ""}* body
  18. "end";
  19.  
  20. syntax Statement =
  21. Command com
  22. | ifStatement: "if" Expression cond "do" {Statement ""}* body "end"
  23. | ifElseStat: "if" Expression cond "do" {Statement ""}* body "end" "else do" {Statement ""}* elsebody "end"
  24. | While: "while" Expression cond "do" {Statement ""}* body "end"
  25. | Repeat: "repeat" Integer int "times" {Statement ""}* body "end"
  26. | Comment: "#" CommentText body;
  27.  
  28. syntax Command =
  29. "step" | "turnLeft" | "drop" | "pick"
  30. | "trace" String message
  31. | "buildWall at" "row:" Integer introw "col:" Integer intcol
  32. | "destroyWall at" "row:" Integer introw "col:" Integer intcol
  33. | "dropMark at" "row:" Integer introw "col:" Integer intcol
  34. | "pickMark at" "row:" Integer introw "col:" Integer intcol;
  35.  
  36. syntax Expression =
  37. "full" | "mark" | "wall ahead" | "heading" Direction dir
  38. | not: "not" Expression exp
  39. | and: Expression exp1 "and" Expression exp2
  40. | or: Expression exp1 "or" Expression exp1 ;
  41.  
  42. syntax Direction = "south" | "north" | "west" | "east" ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement