Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If we actually execute a parser, we have a problem. At parse time, we always know where we are in the ATN, but we have no idea how that corresponds to elements in the original grammar. I guess I could create a mapping as part of the ATN I generate in the parser file. The mapping would convert ATN states transitions to the unique identifiers in the GrammarAST nodes. They are like pointers that would transcend Java VM executions. As long as we have the same grammar, the GrammarAST unique identifiers would be the same. That assumes of course that we have a deterministic process for creating the unique identifiers, which we would by using the above counter.

...

  • Beef up GrammarAST, adding more types, getters
  • Add unique ID to GrammarAST
  • Add GrammarAST ptr in Transition objects
  • Generate an ASTState number two GrammarAST unique identifier map information in the generated code that maps ATN transitions to GrammarAST unique identifiers.
  • Alter the trace ATN mechanism so that it tracks the ATN transitions not the states
  • Create a mechanism to record the unique identifier for each input symbol matched during a parse.