-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftan.waxeye
56 lines (44 loc) · 1.32 KB
/
ftan.waxeye
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
value <= null | boolean | number | string | list | element | richText
null <- :'null'
boolean <- 'true' | 'false'
number <- ?numsign digits ?(decpoint digits) ?(numexp ?numsign digits)
numsign <- [+-]
decpoint <- "."
numexp <- [eE]
digits <- +[0-9]
string
<- (:'"' *(!'"' charRep) :'"')
| (:"'" *(!"'" charRep) :"'")
list
<- emptyList /* because empty RHS is not recognized */
| :"[" ?:space
?( ?:space
| (value | implicitnull) *( :(?space "," ?space) (value | implicitnull) )
| value *( :?space value )
)
?:space :"]"
emptyList <- '[' ?:space ']'
implicitnull <- &(?space [,\]])
element
<- emptyElement
| :"<" ?name *(attribute) ?content ?:space :">"
emptyElement <- '<' ?:space '>'
name <- simpleName | quotedName
simpleName <= (letter | [_]) *(letter | [0-9_])
quotedName <= :"`" +((!"`" charRep) | escape) :"`"
attribute <- :?space name :(?space "=" ?space) value
content <- :?space value
richText <- :"|" *(charRep | element) :"|"
letter <= [A-Za-z0-9À-ÖÙ-ÿ]
space <= +[\t\n\r\<00>-\<20>\<A0>]
charRep <= (![\\|{<] .) | escape
escape
<- :'\\'
( [nrtsS\\"'|`<{] # Not [, which is used for cells.
| space
| hexcode
| cell
)
hexcode <- :'x' *[0-9A-Za-z] :';'
# Cell does not work correctly, because Waxeye does not support back-references.
cell <- :'[' . *(!']' . | '\\]') . :']'