8000 Add syntax proposal with EBNF · unicode-org/message-format-wg@9cb94e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9cb94e6

Browse files
eemelistasm
andcommitted
Add syntax proposal with EBNF
Co-authored-by: Stanisław Małolepszy <sta@malolepszy.org>
1 parent ae650b9 commit 9cb94e6

File tree

2 files changed

+661
-0
lines changed

2 files changed

+661
-0
lines changed

spec/message.ebnf

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Message ::= Plain | Pattern | Preamble Variant+
2+
3+
/* Preamble */
4+
Preamble ::= Selector+
5+
Selector ::= (Variable '=')? '{' Expression '}'
6+
7+
/* Variants and Patterns */
8+
Variant ::= VariantKey* Pattern
9+
VariantKey ::= String | Nmtoken
10+
Pattern ::= '[' (Text | Placeable)* ']' /* ws: explicit */
11+
12+
/* Placeables */
13+
Placeable ::= '{' (Expression | MarkupStart | MarkupEnd)? '}'
14+
15+
/* Expressions */
16+
Expression ::= Operand Annotation? | Annotation
17+
Operand ::= String | Variable
18+
Annotation ::= ':' Name Option*
19+
Option ::= Name '=' (String | Nmtoken | Variable)
20+
21+
/* Markup Tags */
22+
MarkupStart ::= Name Option*
23+
MarkupEnd ::= '/' Name
24+
25+
<?TOKENS?>
26+
27+
/* Plain */
28+
Plain ::= PlainStart (PlainChar* PlainEnd)? /* ws: explicit */
29+
PlainChar ::= AnyChar - ('{' | '}')
30+
PlainStart ::= PlainChar - ('[' | '$' | WhiteSpace)
31+
PlainEnd ::= PlainChar - WhiteSpace
32+
33+
/* Text */
34+
Text ::= (TextChar | TextEscape)+
35+
TextChar ::= AnyChar - ('[' | ']' | '{' | '}' | Esc)
36+
AnyChar ::= .
37+
38+
/* Names */
39+
Variable ::= '$' Name /* ws: explicit */
40+
Name ::= NameStart NameChar* /* ws: explicit */
41+
Nmtoken ::= NameChar+ /* ws: explicit */
42+
NameStart ::= [a-zA-Z] | "_"
43+
| [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF]
44+
| [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D]
45+
| [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF]
46+
| [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
47+
NameChar ::= NameStart | [0-9] | "-" | "." | #xB7
48+
| [#x0300-#x036F] | [#x203F-#x2040]
49+
50+
/* Quoted strings */
51+
String ::= '"' (StringChar | StringEscape)* '"' /* ws: explicit */
52+
StringChar ::= AnyChar - ('"'| Esc)
53+
54+
/* Escape sequences */
55+
Esc ::= '\'
56+
TextEscape ::= Esc Esc | Esc '[' | Esc ']' | Esc '{' | Esc '}'
57+
StringEscape ::= Esc Esc | Esc '"'
58+
59+
/* WhiteSpace */
60+
WhiteSpace ::= #x9 | #xD | #xA | #x20 /* ws: definition */

0 commit comments

Comments
 (0)
0