anchor.diff: -
  -/* 
  - * Taken from official Python 2.7.13 grammar:
  +/*
  + * Parser grammar taken directly from official Python 2.7.13 grammar
  + * with only minor syntactical changes (instances of [X] changed to (X)?, and
  + * semicolons added to ends of rules).:
    * https://docs.python.org/2/reference/grammar.html
    *
  - * Only minor syntactical changes (instances of [X] changed to (X)?, and 
  - * semicolons added to ends of rules), and added lexer rules and whitespace
  - * handling.
  - * 
  + * Added lexer rules, and code to handle INDENT's, DEDENT's,
  + * line continuations, etc.
  + *
    * Compiles with ANTLR 4.7, generated lexer/parser for Python 2 target.
    */
    
    grammar Python2;
  - 
  +
    tokens { INDENT, DEDENT, NEWLINE, ENDMARKER }
  - 
  +
   @lexer::header {
   from Python2Parser import Python2Parser
   from antlr4.Token  import CommonToken
  +
  +class IndentStack:
  +    def __init__(self)    : self._s = []
  +    def empty(self)       : return len(self._s) == 0
  +    def push(self, wsval) : self._s.append(wsval)
  +    def pop(self)         : self._s.pop()
  +    def wsval(self)       : return self._s[-1] if len(self._s) > 0 else 0
  +
  +class TokenQueue:
  +    def __init__(self)  : self._q = []
  +    def empty(self)     : return len(self._q) == 0
  +    def enq(self, t)    : self._q.append(t)
  +    def deq(self)       : return self._q.pop(0)
   }
  - 
  +
   @lexer::members {
       # Indented to append code to the constructor.
       self._openBRCount       = 0
       self._suppressNewlines  = False
       self._lineContinuation  = False
  -    self._tokens            = self.TokenQueue()
  -    self._indents           = self.IndentStack()
  -
  -class IndentStack:
  -    def __init__(self)    : self._s = []
  -    def empty(self)       : return len(self._s) == 0
  -    def pop(self)         : self._s.pop()   
  -    def wsval(self)       : return self._s[-1]   if len(self._s) > 0 else 0 
  -    def push(self, wsval) : self._s.append(wsval)
  -        
  -class TokenQueue:
  -    def __init__(self)  : self._q = []
  -    def enq(self, t)    : self._q.append(t)
  -    def deq(self)       : return self._q.pop(0)
  -    def empty(self)     : return len(self._q) == 0
  -    
  +    self._tokens            = TokenQueue()
  +    self._indents           = IndentStack()
  +
   def nextToken(self):
       if not self._tokens.empty():
           return self._tokens.deq()
  
positive.code:                 raise Exception()
  }  -> channel(HIDDEN)
      ;
      
  COMMENT:        '#' ~[\r\n]* -> skip;
  
  OPEN_PAREN:     '(' {self._openBRCount  += 1};
  
negative.code: 
  testlist1: test (',' test)*
      ;
  
  // not used in grammar, but may appear in "node" passed from Parser to Compiler
  encoding_decl: NAME
      ;
  
  yield_expr: 'yield' 'from'? (testlist)?
      ;
      
  /*****************************************************************************
   *                               Lexer rules
   *****************************************************************************/
  
  NAME: [a-zA-Z_] [a-zA-Z0-9_]*
      ;
  
  NUMBER
      :   '0' ([xX] [0-9a-fA-F]+         ([lL]  | [eE] [+-]? [0-9]+)?
      |        [oO] [0-7]+                [lL]?
      |        [bB] [01]+                 [lL]?)
      | ([0-9]+ '.' [0-9]* | '.' [0-9]+)         ([eE] [+-]? [0-9]+)?       [jJ]?
      |  [0-9]+                          ([lL]  | [eE] [+-]? [0-9]+ [jJ]? | [jJ])?
      ;
  
  STRING
      : ([uUbB]? [rR]? | [rR]? [uUbB]?)
      ( '\''     ('\\' (([ \t]+ ('\r'? '\n')?)|.) | ~[\\\r\n'])*  '\''
      | '"'      ('\\' (([ \t]+ ('\r'? '\n')?)|.) | ~[\\\r\n"])*  '"'
      | '"""'    ('\\' .                          | ~'\\'     )*? '"""'
      | '\'\'\'' ('\\' .                          | ~'\\'     )*? '\'\'\''
      )
      ;
  
  LINENDING:             (('\r'? '\n')+ {self._lineContinuation=False}
      |      '\\'  [ \t]* ('\r'? '\n')  {self._lineContinuation=True})
  {
  if self._openBRCount == 0 and not self._lineContinuation:
      if not self._suppressNewlines:
  