Versions Compared

Key

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

...

What is currentFunc, though? Normally that is a parser class instance variable set to the currently matched function by an action in the parser grammar. For constructs that can nest such as classes in some languages, the "current class" pointer needs to be treated like a stack. ANTLR as these has dynamically scoped very rules for this purpose; perhaps we could do something similar. The result of a pattern match could be an action or perhaps even just a context with no pattern:

No Format

method:
  {System.out.println("heh, I just entered a method")} // always exec in method context
  type ID {currentFunc = currentScope.resolve($ID.text);} // exec this but referred to ID
No Format

Rewrites for tree grammars

No Format