-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathmessage.ebnf
61 lines (49 loc) · 1.83 KB
/
message.ebnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Message ::= Plain | Pattern | Preamble Variant+
/* Preamble */
Preamble ::= Selector+
Selector ::= (Variable '=')? '{' Expression '}'
/* Variants and Patterns */
Variant ::= VariantKey* Pattern
VariantKey ::= Literal | Nmtoken | '*'
Pattern ::= '[' (Text | Placeholder)* ']' /* ws: explicit */
/* Placeholders */
Placeholder ::= '{' (Expression | MarkupStart | MarkupEnd)? '}'
/* Expressions */
Expression ::= Operand Annotation? | Annotation
Operand ::= Literal | Variable
Annotation ::= Function Option*
Option ::= Name '=' (Literal | Nmtoken | Variable)
/* Markup Tags */
MarkupStart ::= Name Option*
MarkupEnd ::= '/' Name
<?TOKENS?>
/* Plain */
Plain ::= PlainStart (PlainChar* PlainEnd)? /* ws: explicit */
PlainChar ::= AnyChar - ('{' | '}')
PlainStart ::= PlainChar - ('[' | '$' | WhiteSpace)
PlainEnd ::= PlainChar - WhiteSpace
/* Text */
Text ::= (TextChar | TextEscape)+
TextChar ::= AnyChar - ('[' | ']' | '{' | '}' | Esc)
AnyChar ::= .
/* Names */
Variable ::= '$' Name /* ws: explicit */
Function ::= ':' Name /* ws: explicit */
Name ::= NameStart NameChar* /* ws: explicit */
Nmtoken ::= NameChar+ /* ws: explicit */
NameStart ::= [a-zA-Z] | "_"
| [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF]
| [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D]
| [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF]
| [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
NameChar ::= NameStart | [0-9] | "-" | "." | #xB7
| [#x0300-#x036F] | [#x203F-#x2040]
/* Literals */
Literal ::= '(' (LiteralChar | LiteralEscape)* ')' /* ws: explicit */
LiteralChar ::= AnyChar - ('(' | ')' | Esc)
/* Escape sequences */
Esc ::= '\'
TextEscape ::= Esc Esc | Esc '[' | Esc ']' | Esc '{' | Esc '}'
LiteralEscape ::= Esc Esc | Esc '(' | Esc ')'
/* WhiteSpace */
WhiteSpace ::= #x9 | #xD | #xA | #x20 /* ws: definition */