/
syntax1.ebnf
108 lines (51 loc) · 3.35 KB
/
syntax1.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
letterenglishlarge = "A"|"B"|"C"|"D"|"E"|"F"|"G"|"H"|"I"|"J"|"K"|"L"|"M"|"N"|"O"|"P"|"Q"|"R"|"S"|"T"|"U"|"V"|"W"|"X"|"Y"|"Z" ;
letterenglishsmall = "a"|"b"|"c"|"d"|"e"|"f"|"g"|"h"|"i"|"j"|"k"|"l"|"m"|"n"|"o"|"p"|"q"|"r"|"s"|"t"|"u"|"v"|"w"|"x"|"y"|"z" ;
letterrussianlarge = "А"|"Б"|"В"|"Г"|"Д"|"Е"|"Ё"|"Ж"|"З"|"И"|"Й"|"К"|"Л"|"М"|"Н"|"О"|"П"|"Р"|"С"|"Т"|"У"|"Ф"|"Х"|"Ц"|"Ч"|"Ш"|"Щ"|"Ъ"|"Ы"|"Ь"|"Э"|"Ю"|"Я" ;
letterrussiansmall = "а"|"б"|"в"|"г"|"д"|"е"|"ё"|"ж"|"з"|"и"|"й"|"к"|"л"|"м"|"н"|"о"|"п"|"р"|"с"|"т"|"у"|"ф"|"х"|"ц"|"ч"|"ш"|"щ"|"ъ"|"ы"|"ь"|"э"|"ю"|"я" ;
letterenglish = letterenglishlarge | letterenglishsmall ;
letterrussian = letterrussianlarge | letterrussiansmall ;
letter = letterenglish | letterrussian;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
minus = "-" ;
dquote = '"' ;
backslash = "\\" ;
lbracket = "[";
rbracket = "]";
space = " " | "\t" ;
specialsequence = backslash, dquote | backslash, backslash | backslash, "n" | backslash, "t" | backslash, "b" ;
linecontinuation = backslash, line_separator ;
spaces = space, {space} ;
line_separator = "\n\r" | "\n" | "\r" ;
line_separators = {spaces} , line_separator, { { spaces } , line_separator } ;
startofcomment = "#" | ";" ;
raw_symbol_inside_quotes = ? Terminals.AnyChar ? - ( dquote | specialsequence | linecontinuation | line_separator );
raw_symbol_in_comment = ? Terminals.AnyChar ? - line_separator ;
textofcomment = { raw_symbol_in_comment } ;
comment = startofcomment , { textofcomment } ;
separator = spaces | line_separators | comment ;
variable_assignment = variablename, [ {separator}, "=", {separator}, variablevalue ] ;
special_include_syntax = "include.path", {separator}, "=", {separator}, filepath ;
variable = variable_assignment | special_include_syntax ;
variablename = letterenglish, { ( letterenglish | digit | [minus] | "." ) , ( letterenglish | digit )} ;
variablevalue = quotedstringwithcontinuations | unquoted_string_in_the_wild ;
filepath = variablevalue;
quotedstring = dquote, {raw_symbol_inside_quotes | specialsequence}, dquote ;
quotedstringwithcontinuations = dquote , { raw_symbol_inside_quotes | specialsequence | linecontinuation }, dquote ;
unquoted_string_in_the_wild_unit = raw_symbol_inside_quotes | specialsequence ;
unquoted_string_in_the_wild = unquoted_string_in_the_wild_unit , { unquoted_string_in_the_wild_unit } ,
{ { linecontinuation} ,
unquoted_string_in_the_wild_unit , { unquoted_string_in_the_wild_unit } } ;
subsectiontitleunit = raw_symbol_inside_quotes | specialsequence ;
subsectiontitle = subsectiontitleunit, {subsectiontitleunit} ;
sectiontitleunit = letter | minus | "." ;
sectiontitle = sectiontitleunit, { sectiontitleunit } ;
subsectionbody = variable , { separator , variable } ;
subsection = subsectionheader, {separator}, subsectionbody ;
sectionbody = variable , { separator , variable } , { {separator} , subsection } ;
subsectionheader = lbracket , {spaces} , sectiontitle , {spaces} , dquote , subsectiontitle , dquote , {spaces} , rbracket ;
sectionheader = lbracket, {spaces}, sectiontitle, {spaces}, rbracket ;
headless_section = subsection, { {separator}, subsection } ;
section = ( sectionheader, {separator}, sectionbody )
| headless_section
;
filecontent = [separator] , { section , {separator} } , [separator] ;