-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdoml.abnf
74 lines (44 loc) · 2.32 KB
/
doml.abnf
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
;; NOTE: this grammar is for the old version of DOML and is yet to be updated to the new one.
;; WARNING: This grammar is W.I.P. and should not be considered as final until stated as final
;; This is an attempt to define DOML in ABNF according to the grammar defined
;; in RFC 5234 (http://www.ietf.org/rfc/rfc5234.txt). And later in RFC 7405 (https://tools.ietf.org/html/rfc7405).
;; Misc
newline = ( %x0A / ; LF
%x0D.0A ) ; CRLF
ws = *wschar
wschar = ( %x20 / ; Space
%x09 ) ; Horizontal tab
minus = "-" ; -
plus = "+" ; +
DIGIT = %x30-39 ; 0 - 9
OCT = %x30-37 ; 0 - 7
HEX = DIGIT / %i"a" / %i"b" / %i"c" / %i"d" / %i"e" / %i"f" ; 0 - 9 or A-F (a-f also)
BINARY = %x30-31 ; 0 or 1
otherBase = "0" ((%i"x" *HEX) / (%i"b" *BINARY) / (%i"o" OCT)) ; 0x or 0b or 0o (case insensitive)
quote = %x22 ; "
backslash = %x5C ; \
forwardslash = %x2F ; /
identifier = ("_" / ALPHA) *("_" / ALPHA / DIGIT)
creationIdentifier = identifier "." identifier
extendedIdentifier = ("_" / ALPHA) *("_" / ALPHA / "[" / "]" / "(" / ")" / "." / "<" / ">" / "{" / "}")
comment = (forwardslash forwardslash newline) / (forwardslash "*" ANY "*" forwardslash) ;; // ... or /* Text */
wsComment = ws / comment
;; Note for simplicity the following rule is defined as being ANY text including unicode
text = ANY
;; Values
integer = [ minus / plus ] ( *( DIGIT ) / ( otherBase ) )
frac = "." 1*DIGIT
exp = "e" [ minus / plus ] *DIGIT
float = [ minus / plus ] *( DIGIT ) ( frac / ( frac exp ) / exp )
string = quote *(text / (backslash quote)) quote ;; "ANY" (including the opportunity to escape quotes)
boolean = %s"true" / %s"false" ;; true or false
lookup = identifier [ "." extendedIdentifier ]
value = integer / float / string / boolean / lookup / vector
values = value *( "," value )
vector = "[" values "]"
;; Intermediates
creation = "@" wsComment identifier wsComment "=" wsComment creationIdentifier [ [ "->" identifier ] "(" values ")" ] wsComment [ "..." ] [ newline ]
set = wsComment [ identifier ] "." extendedIdentifier wsComment "=" wsComment values [ newline ]
;; Top Level
doml = 1*expression ;; 1 or more expressions
expression = creation / set *( ";" set ) / (comment [ newline ])