Advertisement
marcelocamargo

EBNF for IguanaScript

Jul 8th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 3.28 KB | None | 0 0
  1. application-definition = "[<", application-type, ">]", newline ;
  2. application-type = "ConsoleApplication" | "WindowApplication" | "ComponentApplication" ;
  3. newline = ? \n | \r ? ;
  4. using-library = "with", identifier, newline ;
  5. identifier = ( letter | "_" ), { ( letter | digit | "_" ) } ;
  6. letter = "A" | "B" | "C" | "D" | "E"
  7.        | "F" | "G" | "H" | "I" | "J"
  8.        | "K" | "L" | "M" | "N" | "O"
  9.        | "P" | "Q" | "R" | "S" | "T"
  10.        | "U" | "V" | "W" | "X" | "Y"
  11.        | "Z" ;                                                  
  12. digit = "1" | "2" | "3" | "4" | "5" |
  13.       | "6" | "7" | "8" | "9" | "0" ;
  14. namespace = "module", identifier, ":", "{", { interface|type }, "}" ;
  15. interface = "interface", identifier, ":", "{", interface-implementations, "}" ;
  16. type = [ "implement", identifier, { ",", identifier } , "for" ], "type", identifier, ":", "{", ( type-able ), "}" ;
  17. interface-implementations = { identifier, { identifier }, newline } ;
  18. type-able = { ( member | let-method | inherit ), newline } ;
  19. member = "member", variadic-args ;
  20. let-method = "let", identifier, variadic-args-optional, ":", "{", (let-able), "}" ;
  21. let-able = ( let-variable | while | for | times | method-call | do-while | foreach | conditional | implicit-conditional | case-when ), newline ;
  22. inherit = "inherit", identifier ;
  23. variadic-args = identifier, { ",", identifier } ;
  24. variadic-args-optional = [ variadic-args ] ;
  25. let-variable = "let", identifier, variable-able ;
  26. while = "while", condition, ":", "{", let-able, "}" ;
  27. for = "for", identifier, "in", ( identifier | { digit } ), "..", ( identifier | { digit } ), ":", "{", let-able, "}" ;
  28. times = ( identifier | { digit } ), ".", "times", identifier, ":", "{", let-able, "}";
  29. method-call = "call", identifier, variadic-args-optional ;
  30. condition = condition-able, [ comparasion-operators, condition-able ], { ( "||" | "&&" ), condition } ;
  31. bool = "True" | "False" ;
  32. integer = [ "-" ], { digit }, [ "e", digit, { digit } ] ;
  33. string = ? String ? ;
  34. double-float = [ "-" ], { digit }, [ ".", digit, { digit } ];
  35. condition-able = identifier | double-float | { digit } | bool
  36. comparasion-operators = "==" | "!=" | "<" | ">" | ">=" | "<=" | "===" | "!==" ;
  37. conditional = "if", condition, ":", "{", let-able, "}" ;
  38. do-while = "do", ":", "{", newline, let-able, "}", "while", condition ;
  39. foreach = "foreach", identifier, "as", identifier, ":", "{", let-able,"}" ;
  40. for = "for", for-able, ":", "{", let-able, "}" ;
  41. for-able = identifier, "=", ( { digit } | double-float | identifier ), ";", condition, ";", for-calc, ":", "{", let-able, "}" ;
  42. for-calc = ( identifier, increment-decrement ) | ( increment-decrement, identifier ) | math-calc ;
  43. increment-decrement = "++" | "--" ;
  44. math-calc = ? JavaScript Math Calc ? ;
  45. implicit-conditional = condition, "then", return-value, newline, "otherwise", return-value ;
  46. case-when = "case", ( identifier | string | letter ) , ":", "{", newline, { when }, "}" ;
  47. variable-able = bool | integer | double-float | condition | math-calc | string | integer ;
  48. return-value = ? All possible JS values of return ? ;
  49. return-value = function-return, digit, integer, double, identifier, string, math-calc ;
  50. function-return = { identifier, "." }, identifier, variadic-args-optional;
  51. when = "when", condition, ":", newline, let-able, [ "break" | "continue" ], newline ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement