aboutsummaryrefslogtreecommitdiffstats
path: root/README
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-02-26 17:23:41 +0100
committerMattias Andrée <m@maandree.se>2026-02-26 17:23:41 +0100
commitf75673290768677c08135f6aada53298544a14f2 (patch)
tree6b2fb2cbf4f380c400fcd4fb3ed5a594f2b400a9 /README
parentAdd extras/libparser-syntax-highlighter (diff)
downloadlibparser-f75673290768677c08135f6aada53298544a14f2.tar.gz
libparser-f75673290768677c08135f6aada53298544a14f2.tar.bz2
libparser-f75673290768677c08135f6aada53298544a14f2.tar.xz
cleanup
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'README')
-rw-r--r--README88
1 files changed, 45 insertions, 43 deletions
diff --git a/README b/README
index b5b833e..0183879 100644
--- a/README
+++ b/README
@@ -25,83 +25,85 @@ EXTENDED DESCRIPTION
(* CHARACTER CLASSES *)
- _space = " " | "\n" | "\t";
- _alpha = <"a", "z"> | <"A", "Z">;
- _octal = <"0", "7">;
- _digit = <"0", "9">;
- _xdigit = _digit | <"a", "f"> | <"A", "F">;
- _nonascii = <128, 255>;
+ _space = " " | "\n" | "\t";
+ _alpha = <"a", "z"> | <"A", "Z">;
+ _octal = <"0", "7">;
+ _digit = <"0", "9">;
+ _xdigit = _digit | <"a", "f"> | <"A", "F">;
+ _nonascii = <128, 255>;
(* WHITESPACE/COMMENTS, THE GRAMMAR IS FREE-FORM *)
- _comment_char = _space | !"*", !"\"", <"!", 0xFF>;
- _comment_tail = [_comment_char], [_string], ("*)" | _comment_tail | -);
- _comment = "(*", _comment_tail;
+ _comment_str_esc = "\\", (_space | <"!", 255>);
+ _comment_str_char = _space | !"\"", <"!", 255>;
+ _comment_str = "\"", {_comment_str_esc | _comment_str_char}, ("\"" | -);
+ _comment_char = _space | !"*)", !"\"", <"!", 0xFF>;
+ _comment = "(*", {_comment_char | _comment_str}, ("*)" | -);
- _ = {_space | _comment};
+ _ = {_space | _comment};
(* IDENTIFIERS *)
- _identifier_head = _alpha | _digit | _nonascii | "_";
- _identifier_tail = _identifier_head | "-";
+ _identifier_head = _alpha | _digit | _nonascii | "_";
+ _identifier_tail = _identifier_head | "-";
- identifier = _identifier_head, {_identifier_tail};
+ identifier = _identifier_head, {_identifier_tail};
(* STRINGS *)
- _escape_simple = "\\" | "\"" | "'" | "a" | "b" | "f" | "n" | "r" | "t" | "v";
- _escape_hex = ("x" | "X"), _xdigit, _xdigit;
- _escape_octal = _octal, {_octal}; (* May not exceed 255 in base 10 *)
- _escape = _escape_simple | _escape_hex | _escape_octal | -;
- _character = "\\", _escape | !"\"", <" ", 0xFF>;
- _string = "\"", _character, {_character}, ("\"" | -);
+ _escape_simple = "\\" | "\"" | "'" | "a" | "b" | "f" | "n" | "r" | "t" | "v";
+ _escape_hex = ("x" | "X"), _xdigit, _xdigit;
+ _escape_octal = _octal, {_octal}; (* May not exceed 255 in base 10 *)
+ _escape = _escape_simple | _escape_hex | _escape_octal | -;
+ _character = "\\", _escape | !"\"", <" ", 0xFF>;
+ _string = "\"", _character, {_character}, ("\"" | -);
- string = _string
- character = "\"", _character, ("\"" | -);
+ string = _string;
+ character = "\"", _character, ("\"" | -);
(* INTEGERS *)
- _decimal = _digit, {_digit};
- _hexadecimal = "0", ("x" | "X"), _xdigit, {_xdigit};
+ _decimal = _digit, {_digit};
+ _hexadecimal = "0", ("x" | "X"), _xdigit, {_xdigit};
- integer = _decimal | _hexadecimal; (* May not exceed 255. *)
+ integer = _hexadecimal | _decimal; (* May not exceed 255. *)
(* GROUPINGS *)
- _low = character | integer;
- _high = character | integer;
+ _low = character | integer;
+ _high = character | integer;
- nondeterministic = "?";
+ nondeterministic = "?";
- committed = "+", _, _operand;
- rejection = "!", _, _operand;
- concatenation = _operand, {_, ",", _, _operand};
- alternation = concatenation, {_, [nondeterministic], "|", _, concatenation};
- optional = [nondeterministic], "[", _, _expression, _, "]";
- repeated = [nondeterministic], "{", _, _expression, _, "}";
- group = "(", _, _expression, _, ")";
- char-range = "<", _, _low, _, ",", _, _high, "_", ">";
- exception = "-";
- embedded-rule = identifier;
+ committed = "+", _, _operand;
+ rejection = "!", _, _operand;
+ concatenation = _operand, {_, ",", _, _operand};
+ alternation = concatenation, {_, [nondeterministic], "|", _, concatenation};
+ optional = [nondeterministic], "[", _, _expression, _, "]";
+ repeated = [nondeterministic], "{", _, _expression, _, "}";
+ group = "(", _, _expression, _, ")";
+ char-range = "<", _, _low, _, ",", _, _high, _, ">";
+ exception = "-";
+ embedded-rule = identifier;
- _literal = char-range | exception | string;
- _group = optional | repeated | group | embedded-rule;
- _operand = _group | _literal | rejection | committed;
+ _literal = char-range | exception | string;
+ _group = optional | repeated | group | embedded-rule;
+ _operand = _group | _literal | rejection | committed;
- _expression = alternation;
+ _expression = alternation;
(* RULES *)
- rule = identifier, _, "=", _, _expression, _, ";";
+ rule = identifier, _, "=", _, _expression, _, ";";
(* This is the root rule of the grammar. *)
- grammar = _, {rules, _};
+ grammar = _, {rule, _};
The file must be encoded in UTF-8, with LF as the line
break (CR and FF are illegal just because).