-
Notifications
You must be signed in to change notification settings - Fork 0
/
lang_spec.txt
376 lines (248 loc) · 8.15 KB
/
lang_spec.txt
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
Munyo is a indent-based simple data language.
type-name argument|param-name argument|param-name...
type-name argument|param-name argument|param-name...
↑ Child items must be indented. Indents must be Tab(ASCII code 9). Whitespaces can't be used for the indentation.
type-name|param-name|param-name arg|...
↑ Arguments are optional.
In original Munyo, arguments consume everything before ('|' / EndOfLine) except the separater
which is one whitespace(ASCII code 32) after 'type-name'/'param-name'
some_type some argument |some_param some param arg
↑ The argument of 'some_type' is ' some argument ' and 'some_param' is ' some param arg'
type-name argument| param-name argument|...
↑ 'param-name' can have preceding whitespaces.
Whitespaces can't be used for 'type-name'/'param-name' because of the limitations of the syntax.
You can use other characters(with special syntax like '\t','\n', etc.), but if you want to use
Munyo with serde, you need to follow Rust's identifier naming syntax for 'type-name'/'param-name'.
↓ When you use Munyo with serde, a type can have multiple arguments separated by whitespaces.
type-name argument1 argument2...|param-name argument|...
type-name argument1 argument2 | param-name param-argument |...
↑ When it's used with serde without 'RestOf', whitespaces can be added between arguments,
'argument' and ('|' or EOL), 'param-name' and 'param-argument', and "param-argument' and ('|' or EOL).
Those whitespaces are not consumed by arguments.
When you use 'RestOf', the rest of the arguments are consumed including whitespaces.
You need to trim them if you don't need them.
*Line continuation
name argument\
continuation of the argument...
↑ Backslash with line-break means argument\ncontinuation.
The argument is separated with the code LF(ASCII code 10) and tabs are ignored.
name argument\
continuation...
↑ Tabs are ignored, which means it's no problem when indents are unaligned.
name argument\
continuation of the argument...
↑ If the newline starts with whitespace, the continuation starts with whitespace.
name argument|
continuation
↑ '|' with line-break means argumentcontinuation. Nothing separates them. Tabs are ignored.
type-name argument
|param-name argument
|param-name argument...
↑ Lines starts with '|' are continuation of the previous line. The param belongs to
the last type in the prior lines. Tabs are ignored.
name argument\
|param-name arg...
↑ When the previous line has a backslash with line-break, the argument ends with 'LF'.
name argument|
|param-name arg...
↑↓ This has the same meaning with
name argument
|param-name arg...
*Comment
↓ When you use '||', the text from there to the line-break is commented out.
munyo arg|| this is comment.
↓ If you want to end with '|', and write comments after that, you can use '|||'
munyo arg||| comment
continuation
↓ If you want to end with '\', and write comments after that, you can use '||\'
munyo arg||\ comment
continuation
↓ When you use serde without 'RestOf', you can add one whitespace between arg and '||'
munyo arg || comment
↓ You can also add one whitespace between arg of param and '||'
munyo arg | param arg || comment
*Default type and empty line type
>default-type-name
↑ Lines start with '>'(ASCII code 62) define default-types.
↓ When default-type is defined, typenames must be omitted.
argument|param-name arg...
↓ If you want to specify the typename in this context, you need '>\'.
>\type-name argument|param-name...
With '>|':
>|empty-line-type-name
you can define empty-line-type.
type-name argument...
type-name argument...
↑↓ That's recognized as
type-name argument...
empty-line-type
type-name argument...
You can define both with
>default-type-name|empty-line-type-name
This affects only the current indentation level.
>munyo|emp
argument
argument
menyo
monyo
↑↓ This is recognized as
>munyo|emp
munyo argument
emp
munyo argument
menyo
monyo
↑ Child and parent levels aren't affected.
When you double the '>':
>>default-type-name|empty-line-type-name
the default and empty-line types are defined in the current and descendant levels.
>>munyo|emp
argument
menyo
monyo
This is recognized as:
>>munyo|emp
munyo argument
emp
munyo menyo|| When an empty-line item is defined and there's an item after an empty line with an indent, it's considered as a child of the empty-line item.
emp|| Empty-line items are aligned with the last line's indent level. How many tabs the line has are not relevant.
monyo
↑ The child level is also affected, but the parent level is unaffected.
When you triple the '>':
>>>default-type-name|empty-line-type-name
It's applied to to all lines below it at the same indentation level.
foo
>>>triple
tripled
bar
still tripled
child isnt affected
↑↓ This is recognized as
foo
>>>triple
triple tripled
bar
triple still tripled
child isnt affected
↓ When you use '>' multiple times in the current level, it's overridden.
>munyo|manyo
argument
>penyo|ponyo
argument
↑↓ That's recognized as:
>munyo|manyo
munyo argument
manyo
>penyo|ponyo
penyo argument
ponyo
↓ You can override them with empty items.
>munyo|manyo
munyo argument
manyo
>|ponyo|| Default item is canceled.
argument|| <- default item doesn't occur. It's probably syntax error
ponyo
>munyo|manyo
munyo argument
manyo
>penyo|
|| ↑ empty-line item is canceled.
penyo argument
|| ↑ No empty-line item occured
>
|| ↑ Both default and empty-line item is canceled
'>>>' can be overridden in the same way as '>'.
↓ When there's no item but comments in a line, it's not considered an empty line.
>|emp
||This line has comments, so no empty-line item appeared here.
↑↓ This is recognized as:
>|emp
emp
||This line has comments, so no empty-line item appeared here.
When '>>' is used multiple times, it's overridden or stacked.
↓ If '>>' is used on the same level, it's overridden:
>>penyo
argument
>>punyo
argument
↑↓ This is recognized as:
>>penyo
penyo argument
>>punyo
punyo argument
↓ If '>>' is used on another level, it's stacked:
>>ganbo
argument
>>punyo
argument
argument
argument
argument
↑↓ This is recognized as:
>>ganbo
ganbo argument
>>punyo
punyo argument
punyo argument
ganbo argument
|| ↑ 'punyo' affects decendants, but the parent is still 'ganbo'
ganbo argument
|| ↑ This line is not a descendant of 'punyo', but 'ganbo'
↓ You can override the definition on the same level.
>>ganbo
argument
>>punyo
argument
>>
argument
argument
argument
↑↓ This is recognized as:
>>ganbo
ganbo argument
>>punyo
punyo argument
>>
argument || ← Probably syntax error
ganbo argument
ganbo argument
|| ↑ The parent definition is still alive.
↓ '>' definition is always prioritized over '>>' and '>>>' when conflicted.
↓ '>>>' definition is always prioritized over '>>' when conflicted.
>tama
>>pema
argument
>tama
>>>pema
argument2
>>>pema
>>puma
argument3
They are recognized as:
>tama
>>pema
tama argument
>tama
>>>pema
tama argument2
>>>pema
>>puma
pema argument3
In define statements, default-type-name and empty-line-type-name can have leading and trailing whitespaces.
> default-type-name | empty-line-type-name || comments...
*Special characters
'\' and '|' are special characters. If you want to use them in a raw text, use '\\' and '\|'. They are considered normal characters '\' and '|'.
'>','>>','>>>' are special characters when they are used on the start of the line. You can use '\>','\>>' and '\>>>' at the start of the line.
'\r','\n','\t' are supported. They are ASCII code 13, 10, 9 respectively.
The usages of '\' which aren't discribed in this specification is not valid.
*Miscellaneous
When default type is defined, you can't construct default item without arguments.
|| ↑ An empty line isn't considered as a default-type item with no arguments.
|param-name arguments|...
|| ↑ Lines that start with '|' is not considered as a default-type item with no arguments with params. It's a line continuation.
You can use these.
>\default-type-name
|| ↑ No argument
>\default-type-name|param-name arguments
|| ↑ No argument with a param