parser-lr 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/parser-lr.js +110 -823
- package/bin/parser-lr.js.map +1 -1
- package/dist/lib/grammar/grammar-from-cst.js +4 -1
- package/dist/lib/grammar/grammar-from-cst.js.map +1 -1
- package/dist/lib/grammar/grammar.json +86 -820
- package/dist/lib/grammar/table-validator.d.ts.map +1 -1
- package/dist/lib/grammar/table-validator.js +19 -1
- package/dist/lib/grammar/table-validator.js.map +1 -1
- package/docs/The Ferrite Programming Language.md +568 -0
- package/docs/grammar.md +55 -3
- package/grammars/6502.grammar +2 -2
- package/grammars/ferrite.grammar +107 -97
- package/grammars/grammar.grammar +19 -140
- package/grammars/lisp.grammar +3 -2
- package/package.json +1 -1
package/grammars/grammar.grammar
CHANGED
|
@@ -236,193 +236,72 @@ grammar
|
|
|
236
236
|
|
|
237
237
|
ast
|
|
238
238
|
grammar_file =
|
|
239
|
-
|
|
240
|
-
{ section }
|
|
241
|
-
start_decl
|
|
242
|
-
grammar_section
|
|
243
|
-
[ ast_section ]
|
|
244
|
-
[ transform_section ]
|
|
245
|
-
;
|
|
246
|
-
|
|
247
|
-
name_decl =
|
|
248
|
-
name_kw grammar_name semicolon
|
|
249
|
-
;
|
|
250
|
-
|
|
251
|
-
grammar_name =
|
|
252
|
-
identifier
|
|
253
|
-
| string_literal
|
|
254
|
-
;
|
|
255
|
-
|
|
256
|
-
section =
|
|
257
|
-
token_section
|
|
258
|
-
| skip_section
|
|
259
|
-
| states_section
|
|
239
|
+
#sections { section }
|
|
260
240
|
;
|
|
261
241
|
|
|
262
242
|
token_section =
|
|
263
|
-
|
|
243
|
+
#definitions { token_def }
|
|
264
244
|
;
|
|
265
245
|
|
|
266
246
|
skip_section =
|
|
267
|
-
|
|
268
|
-
;
|
|
269
|
-
|
|
270
|
-
states_section =
|
|
271
|
-
states_kw state_name { comma state_name } semicolon
|
|
272
|
-
;
|
|
273
|
-
|
|
274
|
-
token_def =
|
|
275
|
-
identifier equal regex_literal semicolon
|
|
276
|
-
;
|
|
277
|
-
|
|
278
|
-
state_name =
|
|
279
|
-
identifier
|
|
280
|
-
;
|
|
281
|
-
|
|
282
|
-
start_decl =
|
|
283
|
-
start_kw identifier semicolon
|
|
247
|
+
#definitions { token_def }
|
|
284
248
|
;
|
|
285
249
|
|
|
286
250
|
grammar_section =
|
|
287
|
-
|
|
251
|
+
#productions { production }
|
|
288
252
|
;
|
|
289
253
|
|
|
290
254
|
ast_section =
|
|
291
|
-
|
|
255
|
+
#types { ast_type }
|
|
292
256
|
;
|
|
293
257
|
|
|
294
258
|
transform_section =
|
|
295
|
-
|
|
296
|
-
;
|
|
297
|
-
|
|
298
|
-
production =
|
|
299
|
-
identifier equal expression semicolon
|
|
300
|
-
;
|
|
301
|
-
|
|
302
|
-
ast_type =
|
|
303
|
-
identifier equal expression semicolon
|
|
259
|
+
#rules { transform_rule }
|
|
304
260
|
;
|
|
305
261
|
|
|
306
262
|
transform_rule =
|
|
307
|
-
|
|
308
|
-
;
|
|
309
|
-
|
|
310
|
-
labeled_transform =
|
|
311
|
-
hash identifier transform_expr
|
|
312
|
-
;
|
|
313
|
-
|
|
314
|
-
transform_expr =
|
|
315
|
-
drop_kw
|
|
316
|
-
| pass_expr
|
|
317
|
-
| fold_left_expr
|
|
318
|
-
| fold_right_expr
|
|
319
|
-
| flatten_expr
|
|
320
|
-
| build_expr
|
|
321
|
-
;
|
|
322
|
-
|
|
323
|
-
pass_expr =
|
|
324
|
-
pass_kw lpar reference rpar
|
|
325
|
-
;
|
|
326
|
-
|
|
327
|
-
fold_left_expr =
|
|
328
|
-
fold_left_kw lpar build_target comma reference_list rpar
|
|
329
|
-
;
|
|
330
|
-
|
|
331
|
-
fold_right_expr =
|
|
332
|
-
fold_right_kw lpar build_target comma reference_list rpar
|
|
333
|
-
;
|
|
334
|
-
|
|
335
|
-
flatten_expr =
|
|
336
|
-
flatten_kw lpar build_target comma reference comma reference rpar
|
|
337
|
-
;
|
|
338
|
-
|
|
339
|
-
build_expr =
|
|
340
|
-
build_target [ lpar reference_list rpar ]
|
|
341
|
-
;
|
|
342
|
-
|
|
343
|
-
build_target =
|
|
344
|
-
identifier dot hash identifier
|
|
263
|
+
#alternatives { labeled_transform }
|
|
345
264
|
;
|
|
346
265
|
|
|
347
266
|
reference_list =
|
|
348
|
-
|
|
349
|
-
;
|
|
350
|
-
|
|
351
|
-
reference =
|
|
352
|
-
identifier
|
|
353
|
-
;
|
|
354
|
-
|
|
355
|
-
expression =
|
|
356
|
-
choice
|
|
267
|
+
#references { reference }
|
|
357
268
|
;
|
|
358
269
|
|
|
359
270
|
choice =
|
|
360
|
-
|
|
361
|
-
;
|
|
362
|
-
|
|
363
|
-
alternative =
|
|
364
|
-
labeled_alternative
|
|
365
|
-
;
|
|
366
|
-
|
|
367
|
-
labeled_alternative =
|
|
368
|
-
[ hash identifier ] sequence
|
|
271
|
+
#alternatives { alternative }
|
|
369
272
|
;
|
|
370
273
|
|
|
371
274
|
sequence =
|
|
372
|
-
|
|
373
|
-
;
|
|
374
|
-
|
|
375
|
-
factor =
|
|
376
|
-
bracketed
|
|
377
|
-
| repeat
|
|
378
|
-
| group
|
|
379
|
-
| primary
|
|
380
|
-
;
|
|
381
|
-
|
|
382
|
-
bracketed =
|
|
383
|
-
lbracket expression rbracket [ colon identifier ]
|
|
384
|
-
;
|
|
385
|
-
|
|
386
|
-
repeat =
|
|
387
|
-
lbrace expression rbrace
|
|
388
|
-
;
|
|
389
|
-
|
|
390
|
-
group =
|
|
391
|
-
lpar expression rpar
|
|
392
|
-
;
|
|
393
|
-
|
|
394
|
-
primary =
|
|
395
|
-
string_literal
|
|
396
|
-
| identifier
|
|
275
|
+
#factors { factor }
|
|
397
276
|
;
|
|
398
277
|
|
|
399
278
|
transform
|
|
400
279
|
grammar_file$repeat_0 ->
|
|
401
280
|
#main flatten(grammar_file.#sections, section, grammar_file$repeat_0) ;
|
|
402
281
|
|
|
403
|
-
token_section
|
|
282
|
+
token_section ->
|
|
404
283
|
#main flatten(token_section.#definitions, token_def, token_section$repeat_1) ;
|
|
405
284
|
|
|
406
|
-
skip_section
|
|
285
|
+
skip_section ->
|
|
407
286
|
#main flatten(skip_section.#definitions, token_def, skip_section$repeat_2) ;
|
|
408
287
|
|
|
409
|
-
grammar_section
|
|
288
|
+
grammar_section ->
|
|
410
289
|
#main flatten(grammar_section.#productions, production, grammar_section$repeat_4) ;
|
|
411
290
|
|
|
412
|
-
ast_section
|
|
291
|
+
ast_section ->
|
|
413
292
|
#main flatten(ast_section.#types, ast_type, ast_section$repeat_5) ;
|
|
414
293
|
|
|
415
|
-
transform_section
|
|
294
|
+
transform_section ->
|
|
416
295
|
#main flatten(transform_section.#rules, transform_rule, transform_section$repeat_6) ;
|
|
417
296
|
|
|
418
|
-
transform_rule
|
|
297
|
+
transform_rule ->
|
|
419
298
|
#main flatten(transform_rule.#alternatives, labeled_transform, transform_rule$repeat_7) ;
|
|
420
299
|
|
|
421
|
-
reference_list
|
|
300
|
+
reference_list ->
|
|
422
301
|
#main flatten(reference_list.#references, reference, reference_list$repeat_8) ;
|
|
423
302
|
|
|
424
|
-
choice
|
|
303
|
+
choice ->
|
|
425
304
|
#main flatten(choice.#alternatives, alternative, choice$repeat_9) ;
|
|
426
305
|
|
|
427
|
-
sequence
|
|
306
|
+
sequence ->
|
|
428
307
|
#main flatten(sequence.#factors, factor, sequence$repeat_10) ;
|
package/grammars/lisp.grammar
CHANGED
|
@@ -51,16 +51,17 @@ grammar
|
|
|
51
51
|
|
|
52
52
|
ast
|
|
53
53
|
program =
|
|
54
|
-
{ form }
|
|
54
|
+
#program { form }
|
|
55
55
|
;
|
|
56
56
|
|
|
57
57
|
form =
|
|
58
58
|
#list list
|
|
59
59
|
| #atom atom
|
|
60
|
+
| #elements { form }
|
|
60
61
|
;
|
|
61
62
|
|
|
62
63
|
list =
|
|
63
|
-
[open]:lpar
|
|
64
|
+
#list [open]:lpar
|
|
64
65
|
{ [element]:form }
|
|
65
66
|
[close]:rpar
|
|
66
67
|
;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "parser-lr",
|
|
3
3
|
"author": "Adam R Moss <adamrmoss@gmail.com>",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"description": "Shift-reduce parser library for EBNF grammars with LR table generation, lexing, and CST-to-AST transforms",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"ast",
|