aboutsummaryrefslogtreecommitdiffstats
path: root/calc-example
diff options
context:
space:
mode:
Diffstat (limited to 'calc-example')
-rw-r--r--calc-example/calc.syntax32
1 files changed, 17 insertions, 15 deletions
diff --git a/calc-example/calc.syntax b/calc-example/calc.syntax
index 286019b..8051f57 100644
--- a/calc-example/calc.syntax
+++ b/calc-example/calc.syntax
@@ -1,27 +1,29 @@
-_WHITESPACE = " " | "\t" | " ";
-_ = {_WHITESPACE};
+_WHITESPACE = " " | "\t" | " ";
+_COMMENT = "(*", {!"*)", <0, 0xFF>}, "*)";
+_ = {_WHITESPACE | _COMMENT};
-DIGIT = <"0", "9">;
-ADD = _, ("+"), _;
-SUB = _, ("-" | "−"), _;
-MUL = _, ("*" | "⋅" | "×"), _;
-DIV = _, ("/" | "∕" | "÷"), _;
+DIGIT = <"0", "9">;
+ADD = _, ("+"), _;
+SUB = _, ("-" | "−"), _;
+MUL = _, ("*" | "⋅" | "×"), _;
+DIV = _, ("/" | "∕" | "÷"), _;
-sign = ADD | SUB;
-unsigned = DIGIT, {DIGIT | _WHITESPACE | "_" | "'"};
+sign = ADD | SUB;
-_number = unsigned | "(", _expr, (")" | -);
+unsigned = DIGIT, {DIGIT | _WHITESPACE | "_" | "'"};
-number = _number, {_, _number}; (* optionally with implicit multiplication *)
+_number = unsigned | "(", _expr, (")" | -);
-value = [sign], number;
+number = _number, {_, _number}; (* optionally with implicit multiplication *)
-_expr = hyper1;
+value = [sign], number;
+_expr = hyper1;
-hyper1 = _, hyper2, {(ADD | SUB), (hyper2 | -)}, _;
-hyper2 = _, value, {(MUL | DIV), (value | -)}, _;
+
+hyper1 = _, hyper2, {(ADD | SUB), (hyper2 | -)}, _;
+hyper2 = _, value, {(MUL | DIV), (value | -)}, _;