|
| 1 | +from-match = atoms |
| 2 | + |
| 3 | +; an empty match is not allowed. |
| 4 | +atoms = atom *(atom) |
| 5 | + |
| 6 | +atom = simple-matcher / codepoint |
| 7 | + |
| 8 | +codepoint = backslash "u" "{" cphex "}" |
| 9 | + |
| 10 | +cphex = 1*6LHEXDIG |
| 11 | + |
| 12 | +; TODO |
| 13 | +simple-matcher = DIGIT / ALPHA / SP |
| 14 | + |
| 15 | +; message = simple-message / complex-message |
| 16 | + |
| 17 | +; simple-message = o [simple-start pattern] |
| 18 | +; simple-start = simple-start-char / escaped-char / placeholder |
| 19 | +; pattern = *(text-char / escaped-char / placeholder) |
| 20 | +; placeholder = expression / markup |
| 21 | + |
| 22 | +; complex-message = o *(declaration o) complex-body o |
| 23 | +; declaration = input-declaration / local-declaration |
| 24 | +; complex-body = quoted-pattern / matcher |
| 25 | + |
| 26 | +; input-declaration = input o variable-expression |
| 27 | +; local-declaration = local s variable o "=" o expression |
| 28 | + |
| 29 | +; quoted-pattern = "{{" pattern "}}" |
| 30 | + |
| 31 | +; matcher = match-statement s variant *(o variant) |
| 32 | +; match-statement = match 1*(s selector) |
| 33 | +; selector = variable |
| 34 | +; variant = key *(s key) o quoted-pattern |
| 35 | +; key = literal / "*" |
| 36 | + |
| 37 | +; ; Expressions |
| 38 | +; expression = literal-expression |
| 39 | +; / variable-expression |
| 40 | +; / function-expression |
| 41 | +; literal-expression = "{" o literal [s function] *(s attribute) o "}" |
| 42 | +; variable-expression = "{" o variable [s function] *(s attribute) o "}" |
| 43 | +; function-expression = "{" o function *(s attribute) o "}" |
| 44 | + |
| 45 | +; markup = "{" o "#" identifier *(s option) *(s attribute) o ["/"] "}" ; open and standalone |
| 46 | +; / "{" o "/" identifier *(s option) *(s attribute) o "}" ; close |
| 47 | + |
| 48 | +; ; Expression and literal parts |
| 49 | +; function = ":" identifier *(s option) |
| 50 | +; option = identifier o "=" o (literal / variable) |
| 51 | + |
| 52 | +; attribute = "@" identifier [o "=" o literal] |
| 53 | + |
| 54 | +; variable = "$" name |
| 55 | + |
| 56 | +; literal = quoted-literal / unquoted-literal |
| 57 | +; quoted-literal = "|" *(quoted-char / escaped-char) "|" |
| 58 | +; unquoted-literal = name / number-literal |
| 59 | +; ; number-literal matches JSON number (https://www.rfc-editor.org/rfc/rfc8259#section-6) |
| 60 | +; number-literal = ["-"] (%x30 / (%x31-39 *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT] |
| 61 | + |
| 62 | +; ; Keywords; Note that these are case-sensitive |
| 63 | +; input = %s".input" |
| 64 | +; local = %s".local" |
| 65 | +; match = %s".match" |
| 66 | + |
| 67 | +; ; Names and identifiers |
| 68 | +; ; identifier matches https://www.w3.org/TR/REC-xml-names/#NT-QName |
| 69 | +; ; name matches https://www.w3.org/TR/REC-xml-names/#NT-NCName but excludes U+FFFD and U+061C |
| 70 | +; identifier = [namespace ":"] name |
| 71 | +; namespace = name |
| 72 | +; name = [bidi] name-start *name-char [bidi] |
| 73 | +; name-start = ALPHA / "_" |
| 74 | +; / %xC0-D6 / %xD8-F6 / %xF8-2FF |
| 75 | +; / %x370-37D / %x37F-61B / %x61D-1FFF / %x200C-200D |
| 76 | +; / %x2070-218F / %x2C00-2FEF / %x3001-D7FF |
| 77 | +; / %xF900-FDCF / %xFDF0-FFFC / %x10000-EFFFF |
| 78 | +; name-char = name-start / DIGIT / "-" / "." |
| 79 | +; / %xB7 / %x300-36F / %x203F-2040 |
| 80 | + |
| 81 | +; ; Restrictions on characters in various contexts |
| 82 | +; simple-start-char = content-char / "@" / "|" |
| 83 | +; text-char = content-char / ws / "." / "@" / "|" |
| 84 | +; quoted-char = content-char / ws / "." / "@" / "{" / "}" |
| 85 | +; content-char = %x01-08 ; omit NULL (%x00), HTAB (%x09) and LF (%x0A) |
| 86 | +; / %x0B-0C ; omit CR (%x0D) |
| 87 | +; / %x0E-1F ; omit SP (%x20) |
| 88 | +; / %x21-2D ; omit . (%x2E) |
| 89 | +; / %x2F-3F ; omit @ (%x40) |
| 90 | +; / %x41-5B ; omit \ (%x5C) |
| 91 | +; / %x5D-7A ; omit { | } (%x7B-7D) |
| 92 | +; / %x7E-2FFF ; omit IDEOGRAPHIC SPACE (%x3000) |
| 93 | +; / %x3001-10FFFF ; allowing surrogates is intentional |
| 94 | + |
| 95 | +; ; Character escapes |
| 96 | +; escaped-char = backslash ( backslash / "{" / "|" / "}" ) |
| 97 | +backslash = %x5C ; U+005C REVERSE SOLIDUS "\" |
| 98 | + |
| 99 | + |
| 100 | +; ; Required whitespace |
| 101 | +; s = *bidi ws o |
| 102 | + |
| 103 | +; ; Optional whitespace |
| 104 | +; o = *(ws / bidi) |
| 105 | + |
| 106 | +; ; Bidirectional marks and isolates |
| 107 | +; ; ALM / LRM / RLM / LRI, RLI, FSI & PDI |
| 108 | +; bidi = %x061C / %x200E / %x200F / %x2066-2069 |
| 109 | + |
| 110 | +; Whitespace characters |
| 111 | +; ws = SP / HTAB / CR / LF / %x3000 |
| 112 | + |
| 113 | +; uppercase rules are omitted from the AST by default |
| 114 | + |
| 115 | +; from STD-68 |
| 116 | +DIGIT = %x30-39 ; 0-9 |
| 117 | +ALPHA = %x41-5A / %x61-7A ; A-Z / a-z |
| 118 | +SP = %x20 |
| 119 | +; HTAB = %xF900 ; horizontal tab |
| 120 | +; LF = %x0A ; linefeed |
| 121 | +; CR = %x0D ; carriage return |
| 122 | +HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" |
| 123 | +; like HEXDIG but lowercase also |
| 124 | +LHEXDIG = HEXDIG / "a" / "b" / "c" / "d" / "e" / "f" |
0 commit comments