craff / pacomb

A parsing library that compiles grammars to combinators using elimination of left recursion
MIT License
18 stars 2 forks source link

Printing of grammar after empty elimination is incomplete #21

Closed craff closed 4 years ago

craff commented 4 years ago

EKey and ELr are not printed

craff commented 4 years ago

Works

The grammar AB defined as : AB ::= AC 'a' 'c' | BC 'b' 'c' | () BC ::= AC 'a' 'c' | AB 'a' 'b' | () AC ::= BC 'b' 'c' | AB 'a' 'b' | ()

is printed as following after elimination of left recursion:

AB ::= (() | AB_lr from AB_lr ::= (('b' 'c' | 'a' 'c')) (BC_lr 'b' 'c' | AC_lr 'a' 'c') AC_lr ::= (('a' 'b' | 'b' 'c')) (BC_lr 'b' 'c' | AB_lr 'a' 'b') BC_lr ::= (('a' 'b' | 'a' 'c')) (AC_lr 'a' 'c' | AB_lr 'a' 'b')*

This really is a kind of product vector * matrix, the line of the matrix have the "star" and XXX_lr are used do index the matrix