diff options
author | Mattias Andrée <maandree@kth.se> | 2021-04-19 11:29:50 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-04-19 11:29:50 +0200 |
commit | 16b3146a1ed4497205a378472b35c40eb34c0d40 (patch) | |
tree | 1607ca63497008ce51f4333dcea9b729483f23f8 /calc-example | |
parent | Compile with -O2 and -s (diff) | |
download | libparser-16b3146a1ed4497205a378472b35c40eb34c0d40.tar.gz libparser-16b3146a1ed4497205a378472b35c40eb34c0d40.tar.bz2 libparser-16b3146a1ed4497205a378472b35c40eb34c0d40.tar.xz |
Add rejection + fix documentation of comment syntax (can contain string)
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'calc-example')
-rw-r--r-- | calc-example/calc.syntax | 32 |
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 | -)}, _; |