From 16b3146a1ed4497205a378472b35c40eb34c0d40 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 19 Apr 2021 11:29:50 +0200 Subject: Add rejection + fix documentation of comment syntax (can contain string) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- calc-example/calc.syntax | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'calc-example') 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 | -)}, _; -- cgit v1.2.3-70-g09d2