antlr/antlr4 — pull request #768 by ericvergnaud (2014-11-30 08:43:08+00:00)
Title: add support for $self

Hi,
proposing to add a new $self property, referring to the parser instance.
The purpose is to enable multi target semantic predicates, using a strategy where parser is derived from an abstract parser which implements utility methods.
Currently this is not possible:
- Java and C# method calls do not need 'this', so are easily portable
- Python method calls require 'self'. A way to work around this is to always use 'self', and declare a 'self' member in Java and C# abstract parsers as described in our Wiki
- Javascript method calls require 'this'. This defeats the Python workaround.
A TestDollarSelf is provided to illustrate the concept.
I also validated it with all other targets and will add a multi-target test if agreed.
All the existing tests pass ok.