-
-
Notifications
You must be signed in to change notification settings - Fork 334
/
syntax.ebnf
49 lines (41 loc) · 1.46 KB
/
syntax.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
(*
* Inltify message syntax v0.5.0
* (vue-i18n compatible)
*)
(* entrypoint *)
Resource ::= Plural | Mesasge;
(* main structure *)
Plural ::= Message Space* "|" Space* (Message (Space* "|" Space*)?)+;
Message ::= (Text? (Placeholder | Linked)? Text?)+;
(* primitives *)
Text ::= TextChar+;
Placeholder ::= Named | List | StringLiteral;
Named ::= "{" Space? (NamedIdentifier) Space? "}";
List ::= "{" Space? (NumberLiteral) Space? "}";
Linked ::= "@" (LinkedModifier)? LinkedDelimiter LinkedRefer;
LinkedRefer ::= LinkedKey | Placeholder;
LinkedKey ::= Text;
LinkedModifier ::= LinkedDot Identifier;
LinkedDelimiter ::= ":";
LinkedDot ::= ".";
(* characters *)
AnyChar ::= [#x0-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]; (* Unicode character *)
SpecialChar ::= "{" | "}" | "|" | "@";
TextChar ::= AnyChar - SpecialChar - LineEnd;
(* literals *)
StringLiteral ::= "'" QuotedChar* "'";
NumberLiteral ::= "-"? Digits;
SpecialQuotedChar ::= "\'" | "\\";
SpecialEscape ::= "\\" SpecialQuotedChar;
UnicodeEscape ::= ("\\u" /[0-9a-fA-F]{4}/) | ("\\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; (* \n0009 *)
LineEnd ::= #x000D#x000A | #x000A; (* "\u000D\u000A" | "\u000A" *)
Space ::= (Tab | SpaceInline | LineEnd)+;