Advertisement
Guest User

Untitled

a guest
Apr 27th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
BNF 1.40 KB | None | 0 0
  1. PDefs. Program ::= [Def] ;
  2. terminator Def "" ;
  3.  
  4. DFun. Def ::= Type UIdent "(" [Arg] ")" "{" [Stm] "}" ;
  5. separator Arg "," ;
  6. terminator Stm "" ;
  7.  
  8. ADecl. Arg ::= Type UIdent ;
  9. SExp. Stm ::= Exp ";" ;
  10.  
  11. SDecl. Stm ::= Type UIdent ";" ;
  12. SDecls. Stm ::= Type UIdent "," [UIdent] ";" ;
  13. SInit. Stm ::= Type UIdent "=" Exp ";" ;
  14.  
  15. SReturn. Stm ::= "return" Exp ";" ;
  16. SWhile. Stm ::= "while" "(" Exp ")" Stm ;
  17. SFor. Stm ::= "for" Exp "to" Exp "do" Stm ;
  18. SPass. Stm ::= "pass" ";";
  19. SBlock. Stm ::= "{" [Stm] "}" ;
  20. SIfElse. Stm ::= "if" "(" Exp ")" Stm "else" Stm ;
  21. SPrint. Stm ::= "Print" "(" Exp ")" ";";
  22.  
  23. token UIdent (letter (letter|digit|'_')*) ;
  24. terminator UIdent "" ;
  25.  
  26. EInt. Exp13 ::= Integer ;
  27. ETrue. Exp13 ::= "True" ;
  28. EFalse. Exp13 ::= "False" ;
  29. EId. Exp13 ::= UIdent ;
  30. EApp. Exp13 ::= UIdent "(" [Exp] ")" ;
  31. ETimes. Exp12 ::= Exp12 "*" Exp13 ;
  32. EDiv. Exp12 ::= Exp12 "/" Exp13 ;
  33. EPlus. Exp11 ::= Exp11 "+" Exp12 ;
  34. EMinus. Exp11 ::= Exp11 "-" Exp12 ;
  35. ELt. Exp9 ::= Exp9 "<" Exp10 ;
  36. EGt. Exp9 ::= Exp9 ">" Exp10 ;
  37. ELtEq. Exp9 ::= Exp9 "<=" Exp10 ;
  38. EGtWq. Exp9 ::= Exp9 ">=" Exp10 ;
  39. EEq. Exp8 ::= Exp8 "==" Exp9 ;
  40. ENEq. Exp8 ::= Exp8 "!=" Exp9 ;
  41. EAnd. Exp4 ::= Exp4 "and" Exp5 ;
  42. EOr. Exp3 ::= Exp3 "or" Exp4 ;
  43. EAss. Exp2 ::= Exp3 "=" Exp2 ;
  44.  
  45. coercions Exp 13 ;
  46. separator Exp "," ;
  47.  
  48. Tbool. Type ::= "Bool" ;
  49. Tint. Type ::= "Int" ;
  50. Tvoid. Type ::= "void" ;
  51.  
  52. comment "#" ;
  53. comment "/*" "*/" ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement