WardCunningham / pegasm

PEG parser aspiring to be as fast as Pegleg and as convenient as Treetop
5 stars 0 forks source link

Bootstrap PEG Parser #2

Open WardCunningham opened 11 years ago

WardCunningham commented 11 years ago

Here is the data flow for an experiment that bootstraps a working peg parser-generator from three passes over the peg grammar.

Grammar.txt  --->  hand-coding
                         |
                         V   **
Grammar.txt  --->  Parser.java --> ParserAgent.java --> Trace-1.txt
                         |
                         V
                    parse-tree
                         |
                         V        **
                ParserGenerator.java
                         |
                         V
Grammar.txt -> GeneratedParser.class -> ParserAgent.java --> Trace-2.txt

I've marked with \ the classes that need to be extended or coded to complete this first test. The ParserGenerator would only need to make something equivalent to the unmodified Parser.java because the ParserAgent will demonstrate that it is parsing correctly (when Trace-1 matches Trace-2).

WardCunningham commented 11 years ago

Should the above work, then the ParserGenerator.java could be extended to generate parsers that call action routines. When provided with action routines that produce the same parse-trees then another bootstrap round would free the system from the original hand-crafted parser.