0

I am trying to write a grammar for a state transition language using Antlr4

This system has variables (e.g., states) that are declared once and can be referenced elsewhere.

My question is: does Antlr4 support cross-references as in XText?

If Antlr4 does not provide this functionality, I guess an "easy" way to do it is by having a memory Map that parses the tokens and stores the information in this Map?

STiGMa
  • 906
  • 3
  • 11
  • 24

1 Answers1

0

The short answer is no, cross-references in XText can implement a degree of complexity that would be hard to duplicate outside of an EMF-based system.

However, in its simplest form, cross-references require little more than a static symbol table. Depending on your needs, symbol versioning based on state traversal may be adequate. Versioning would be normally performed during a tree walk. Initialization of static symbols could be performed in grammar-based actions, though likely best done in the parser rather than the lexer.

Community
  • 1
  • 1
GRosenberg
  • 5,843
  • 2
  • 19
  • 23