-
-
Notifications
You must be signed in to change notification settings - Fork 389
Expand file tree
/
Copy pathsyntax.ebnf
More file actions
53 lines (45 loc) · 1.78 KB
/
syntax.ebnf
File metadata and controls
53 lines (45 loc) · 1.78 KB
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
(*
* Intlify message syntax v0.7.0
* (vue-i18n compatible)
*)
(* entrypoint *)
Resource ::= Plural | Message;
(* main structure *)
Plural ::= Message Space* "|" Space* (Message (Space* "|" Space*)?)+;
Message ::= (Text? (Placeholder | Linked)? Text?)+;
(* primitives *)
Text ::= TextChar+;
Placeholder ::= Named | List | Literal;
Named ::= "{" Space? (NamedIdentifier) Space? "}";
List ::= "{" Space? (NumberLiteral) Space? "}";
Literal ::= "{" Space? StringLiteral Space? "}";
Linked ::= "@" (LinkedModifier)? LinkedDelimiter LinkedRefer;
LinkedRefer ::= LinkedKey | Placeholder;
LinkedKey ::= LinkedKeyChar+;
LinkedModifier ::= LinkedDot Identifier;
LinkedDelimiter ::= ":";
LinkedDot ::= ".";
(* characters *)
AnyChar ::= [#x0-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]; (* Unicode character *)
SpecialChar ::= "{" | "}" | "|" | "@";
TextEscape ::= #x005C (SpecialChar | #x005C); (* \{, \}, \|, \@, \\ *)
TextChar ::= TextEscape | (AnyChar - SpecialChar);
LinkedKeyChar ::= AnyChar - LinkedKeySpecialChar;
LinkedKeySpecialChar ::= "{" | "@" | "|" | "(" | ")" | Space;
(* literals *)
StringLiteral ::= "'" QuotedChar* "'";
NumberLiteral ::= "-"? Digits;
SpecialQuotedChar ::= #x0027 | #x005C; (* single quote or backslash *)
SpecialEscape ::= #x005C SpecialQuotedChar; (* \' or \\ *)
UnicodeEscape ::= (#x005C "u" /[0-9a-fA-F]{4}/) | (#x005C "U" /[0-9a-fA-F]{6}/);
QuotedChar ::= (AnyChar - SpecialQuotedChar - LineEnd) | SpecialEscape | UnicodeEscape;
(* number *)
Digits ::= [0-9]+;
(* identifier *)
Identifier ::= [a-zA-Z_] [a-zA-Z0-9_$]*;
NamedIdentifier ::= [a-zA-Z_] [a-zA-Z0-9_\-$]*;
(* whitespaces *)
SpaceInline ::= #x0020; (* "\u0020" *)
Tab ::= #x0009; (* "\u0009" *)
LineEnd ::= #x000D#x000A | #x000A | #x2028 | #x2029; (* CRLF | LF | LS | PS *)
Space ::= (Tab | SpaceInline | LineEnd)+;