-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtree-sitter-beancount2.ebnf
142 lines (101 loc) · 2.35 KB
/
tree-sitter-beancount2.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//
// From tree-sitter-beancount2/src/grammar.json
//
//
// EBNF to generate railroad diagram at
// (IPV6) https://www.bottlecaps.de/rr/ui
// (IPV4) https://rr.red-dove.com/ui
//
source_file ::=
_definition*
_definition ::=
_entry_definition
| option_definition
| plugin_definition
| include_definition
| pushtag_definition
| poptag_definition
option_definition ::=
'option' text text
plugin_definition ::=
'plugin' text text?
include_definition ::=
'include' filepath
pushtag_definition ::=
'pushtag' tag
poptag_definition ::=
'poptag' tag
_entry_definition ::=
date ( open_definition | close_definition | commodity_definition | transaction_definition | note_definition | document_definition | event_definition | balance_definition | price_definition | pad_definition | custom_definition ) metadata_definition*
open_definition ::=
'open' account ( commodity ( ',' commodity )* )?
close_definition ::=
'close' account
commodity_definition ::=
'commodity' commodity
transaction_definition ::=
txn ( text text | text )? ( tag | link )* ( post_definition | metadata_definition )*
post_definition ::=
account ( amount commodity cost? price? )?
price ::=
'@{1,2}' unsigned_amount commodity
cost ::=
'{' unsigned_amount commodity '}'
tag ::=
'#'('-'|[a-zA-Z_])+
link ::=
'\^'('-'|[a-zA-Z_])+
note_definition ::=
'note' account note
document_definition ::=
'document' account filepath
filepath ::=
'".'+'"'
event_definition ::=
'event' text text
balance_definition ::=
'balance' account amount commodity
price_definition ::=
'price' commodity amount commodity
pad_definition ::=
'pad' account account
custom_definition ::=
'custom' text uncheck*
uncheck ::=
text
| '\S'+
account ::=
( 'Assets' | 'Liabilities' | 'Equity' | 'Income' | 'Expenses' ) ( ':' _account_component )*
metadata_definition ::=
metadata_key ':' metadata_value?
metadata_key ::=
[a-z][a-zA-Z0-9-_]*
metadata_value ::=
text
| account
| commodity
| date
| tag
| amount
_account_component ::=
[A-Z0-9][a-zA-Z0-9-]*
_booking_method ::=
'STRICT'
| 'NONE'
date ::=
[0-9][0-9][0-9][0-9][-/]('0'[1-9]|'1'[0-2])[-/]([012][0-9]|'3'[0-1])
note ::=
'".'*'"'
text ::=
'"' '.'* '"'
unsigned_amount ::=
[0-9]+('.'[0-9]+)?
amount ::=
'-'?[0-9]+('.'[0-9]+)?
txn ::=
'*'
| '!'
commodity ::=
[A-Z]+
comment ::=
';' '.'*