Has anyone done work to convert the output of peg back to the input grammar?
I have recently inherited a project that uses PEG. We have the PEG parser but the source grammar seems to be lost or missing. Is it possible to recover the grammar from only the PEG parser code?
The process is pretty straightforward to do by hand.
peg$parse
.} else {
peg$currPos = s#;
s# = peg$FAILED;
}
means there was an item in sequence.
while (s# !== peg$FAILED)
is a repetition.if (s# === peg$FAILED)
is an alternative branch of a choice.
Most helpful comment
The process is pretty straightforward to do by hand.
peg$parse
.means there was an item in sequence.
while (s# !== peg$FAILED)
is a repetition.if (s# === peg$FAILED)
is an alternative branch of a choice.