grammar.txt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. location:
  2. | LOCATION_START EOL*
  3. line_statement*
  4. LOCATION_END EOL*
  5. EOF
  6. line_statement:
  7. | COMMENT EOL+ // A comment
  8. | COLUMN IDENT EOL* // A location
  9. | instruction, line_sep
  10. | inline_action line_sep
  11. | ACT expression COLUMN EOL+ // ACT … END ACT
  12. line_statement*
  13. END ACT? // Yes you can have END or END ACT
  14. line_sep
  15. | IF expression COLUMN EOL+ // IF … END IF
  16. line_statement*
  17. elif*
  18. else
  19. END IF? // Yes you can have END or END IF
  20. line_sep
  21. elif:
  22. | ELIF
  23. expression COLUMN EOL+
  24. line_statement*
  25. else:
  26. | ELSE EOL+
  27. line_statement*
  28. |
  29. line_sep:
  30. | EOL+
  31. | AMPERSAND+ EOL*
  32. instruction:
  33. | expression
  34. | let_assignation
  35. | keyword argument(expression)
  36. keyword:
  37. | STAR KEYWORD // A keyword starting with *
  38. | KEYWORD
  39. let_assignation:
  40. | assignation
  41. variable
  42. assignation_operator
  43. expression
  44. assignation:
  45. |
  46. | LET
  47. | SET
  48. assignation_operator:
  49. | EQUAL
  50. | INCR // +=
  51. | DECR // -=
  52. inline_action:
  53. | ACT expression COLUMN // There is a recursive code here
  54. | IF expression COLUMN // Because ACT: can contains an IF: etc
  55. (ELSE, instruction)? // complicated to flatten here.
  56. expression:
  57. | delimited(l_paren, expression, r_paren)
  58. | unary_operator expression
  59. | expression binary_operator expression
  60. | literal
  61. | integer
  62. | variable
  63. | function argument(expression)
  64. unary_operator:
  65. | OBJ
  66. | LOC
  67. | NO
  68. | MINUS
  69. | PLUS
  70. binary_operator:
  71. | EQUAL
  72. | LT GT // Different
  73. | EXCLAMATION // Neg, not a comment here
  74. | PLUS
  75. | MINUS
  76. | STAR // Not the first char of keyword here
  77. | DIV
  78. | MOD
  79. | GT
  80. | LT
  81. | GT EQUAL
  82. | LT EQUAL
  83. | EQUAL GT // Alternative syntax
  84. | EQUAL LT // Alternative syntax
  85. | AND
  86. | OR