anchor.diff:  // literal string representation in the target language. We assume
   // that they are delimited by ' or " and so consume these
   // in their own alts so as not to inadvertantly match {}.
  -
  -mode Action;
  -
  -	NESTED_ACTION			: LBrace			-> type(ACTION_CONTENT), pushMode(Action)	;
  -
  -	ACTION_ESCAPE			: EscAny			-> type(ACTION_CONTENT)		;
  -
  -	ACTION_STRING_LITERAL	: DQuoteLiteral		-> type(ACTION_CONTENT)		;
  -	ACTION_CHAR_LITERAL		: SQuoteLiteral		-> type(ACTION_CONTENT)		;
  -
  -	ACTION_DOC_COMMENT		: DocComment		-> type(ACTION_CONTENT)		;
  -	ACTION_BLOCK_COMMENT	: BlockComment 		-> type(ACTION_CONTENT)		;
  -	ACTION_LINE_COMMENT		: LineComment 		-> type(ACTION_CONTENT)		;
  -
  -	END_ACTION				: RBrace	{ self.handleEndAction() }	;
  -
  -	UNTERMINATED_ACTION		: EOF		-> popMode		;
  -
  -	ACTION_CONTENT			: .							;
  -
  -
  -// -------------------------
  -
  -mode Options;
  -
  -	OPT_DOC_COMMENT		: DocComment		-> type(DOC_COMMENT), channel(OFF_CHANNEL)		;
  -	OPT_BLOCK_COMMENT	: BlockComment 		-> type(BLOCK_COMMENT), channel(OFF_CHANNEL)	;
  -	OPT_LINE_COMMENT	: LineComment 		-> type(LINE_COMMENT), channel(OFF_CHANNEL)		;
  -
  -	OPT_LBRACE			: LBrace			-> type(LBRACE)				;
  -	OPT_RBRACE			: RBrace			-> type(RBRACE), popMode	;
  -
  -	OPT_ID				: Id				-> type(ID)					;
  -	OPT_DOT				: Dot				-> type(DOT)				;
  -	OPT_ASSIGN			: Equal				-> type(ASSIGN)				;
  -	OPT_STRING_LITERAL	: SQuoteLiteral		-> type(STRING_LITERAL)		;
  -	OPT_INT				: DecimalNumeral	-> type(INT)				;
  -	OPT_STAR			: Star				-> type(STAR)				;
  -	OPT_SEMI			: Semi				-> type(SEMI)				;
  -
  -	OPT_WS				: Ws+	-> type(WS), channel(OFF_CHANNEL) 	;
  -
  -
  -// -------------------------
  -
  -mode Tokens;
  -
  -	TOK_DOC_COMMENT		: DocComment		-> type(DOC_COMMENT), channel(OFF_CHANNEL)		;
  -	TOK_BLOCK_COMMENT	: BlockComment 		-> type(BLOCK_COMMENT), channel(OFF_CHANNEL)	;
  -	TOK_LINE_COMMENT	: LineComment 		-> type(LINE_COMMENT), channel(OFF_CHANNEL)		;
  -
  -	TOK_LBRACE			: LBrace			-> type(LBRACE)				;
  -	TOK_RBRACE			: RBrace			-> type(RBRACE), popMode	;
  -
  -	TOK_ID				: Id				-> type(ID)					;
  -	TOK_DOT				: Dot				-> type(DOT)				;
  -	TOK_COMMA			: Comma				-> type(COMMA)				;
  -
  -	TOK_WS				: Ws+	-> type(WS), channel(OFF_CHANNEL) 	;
  -
  -
  -// -------------------------
  -
  -mode Channels;	// currently same as Tokens mode; distinguished by keyword
  -
  -	CHN_DOC_COMMENT		: DocComment		-> type(DOC_COMMENT), channel(OFF_CHANNEL)		;
  -	CHN_BLOCK_COMMENT	: BlockComment 		-> type(BLOCK_COMMENT), channel(OFF_CHANNEL)	;
  -	CHN_LINE_COMMENT	: LineComment 		-> type(LINE_COMMENT), channel(OFF_CHANNEL)		;
  -
  -	CHN_LBRACE			: LBrace			-> type(LBRACE)				;
  -	CHN_RBRACE			: RBrace			-> type(RBRACE), popMode	;
  -
  -	CHN_ID				: Id				-> type(ID)					;
  -	CHN_DOT				: Dot				-> type(DOT)				;
  -	CHN_COMMA			: Comma				-> type(COMMA)				;
  -
  -	CHN_WS				: Ws+	-> type(WS), channel(OFF_CHANNEL) 	;
  -
  -
  -// -------------------------
  -
  +mode TargetLanguageAction;
  +NESTED_ACTION
  +   : LBrace -> type (ACTION_CONTENT) , pushMode (TargetLanguageAction)
  +   ;
  +
  +ACTION_ESCAPE
  +   : EscAny -> type (ACTION_CONTENT)
  +   ;
  +
  +ACTION_STRING_LITERAL
  +   : DQuoteLiteral -> type (ACTION_CONTENT)
  +   ;
  +
  +ACTION_CHAR_LITERAL
  +   : SQuoteLiteral -> type (ACTION_CONTENT)
  +   ;
  +
  +ACTION_DOC_COMMENT
  +   : DocComment -> type (ACTION_CONTENT)
  +   ;
  +
  +ACTION_BLOCK_COMMENT
  +   : BlockComment -> type (ACTION_CONTENT)
  +   ;
  +
  +ACTION_LINE_COMMENT
  +   : LineComment -> type (ACTION_CONTENT)
  +   ;
  +
  +END_ACTION
  +   : RBrace
  +   { self.handleEndAction() }
  +   ;
  +
  +UNTERMINATED_ACTION
  +   : EOF -> popMode
  +   ;
  +
  +ACTION_CONTENT
  +   : .
  +   ;
  +
  +// -------------------------
   mode LexerCharSet;
  -
  -	LEXER_CHAR_SET_BODY
  -		:	(	~[\]\\]
  -			|	EscAny
  -			)+				-> more
  -		;
  -
  -	LEXER_CHAR_SET
  -		:	RBrack			-> popMode
  -		;
  -
  -	UNTERMINATED_CHAR_SET
  -		:	EOF				-> popMode
  -		;
  -
  +LEXER_CHAR_SET_BODY
  +   : (~ [\]\\] | EscAny)+ -> more
  +   ;
  +
  +LEXER_CHAR_SET
  +   : RBrack -> popMode
  +   ;
  +
  +UNTERMINATED_CHAR_SET
  +   : EOF -> popMode
  +   ;
   
   // ------------------------------------------------------------------------------
   // Grammar specific Keywords, Punctuation, etc.
  -
  -fragment Id	: NameStartChar NameChar*	;
  -
  +fragment Id
  +   : NameStartChar NameChar*
  +   ;
  +   
  
positive.code: // multi-character string. All literals are single quote delimited and
  // may contain unicode escape sequences of the form \uxxxx, where x
  // is a valid hexadecimal number (per Unicode standard).
  
  STRING_LITERAL
  	: SQuoteLiteral
  	;
  
  UNTERMINATED_STRING_LITERAL
  	: USQuoteLiteral
  	;
  
  
  // -------------------------
  // Arguments
  
negative.code: // Certain argument lists, such as those specifying call parameters
  // to a rule invocation, or input parameters to a rule specification
  // are contained within square brackets.
  BEGIN_ARGUMENT
     : LBrack
     { self.handleBeginArgument() }
     ;
  
  // -------------------------
  // Target Language Actions
  BEGIN_ACTION
     : LBrace -> pushMode (TargetLanguageAction)
     ;
  
  // -------------------------
  // Keywords
  //
  // 'options', 'tokens', and 'channels' are considered keywords
  // but only when followed by '{', and considered as a single token.
  // Otherwise, the symbols are tokenized as RULE_REF and allowed as
  // an identifier in a labeledElement.
  OPTIONS      : 'options'  WSNLCHARS* '{'  ;
  TOKENS       : 'tokens'   WSNLCHARS* '{'  ;
  CHANNELS     : 'channels' WSNLCHARS* '{'  ;
  
  fragment WSNLCHARS : ' ' | '\t' | '\f' | '\n' | '\r' ;
  
  IMPORT
     : 'import'
     ;
  
  FRAGMENT
     : 'fragment'
     ;
  
  LEXER
     : 'lexer'
     ;
  
  PARSER
     : 'parser'
     ;
  
  GRAMMAR
     : 'grammar'
     ;
  
  PROTECTED
     : 'protected'
     ;
  
  PUBLIC
     : 'public'
     ;
  
  PRIVATE
     : 'private'
     ;
  
  RETURNS
     : 'returns'
     ;
  
  LOCALS
     : 'locals'
     ;
  
  THROWS
     : 'throws'
     ;
  
  CATCH
     : 'catch'
     ;
  
  FINALLY
     : 'finally'
     ;
  
  MODE
     : 'mode'
     ;
     // -------------------------
     // Punctuation
  
  COLON
     : Colon
     ;
  
  COLONCOLON
     : DColon
     ;
  
  COMMA
     : Comma
     ;
  
  SEMI
     : Semi
     ;
  
  LPAREN
     : LParen
     ;
  
  RPAREN
     : RParen
     ;
  
  LBRACE
     : LBrace
     ;
  
  RBRACE
     : RBrace
     ;
  
  RARROW
     : RArrow
     ;
  
  LT
     : Lt
     ;
  
  GT
     : Gt
     ;
  
  ASSIGN
     : Equal
     ;
  
  QUESTION
     : Question
     ;
  
  STAR
     : Star
     ;
  
  PLUS_ASSIGN
     : PlusAssign
     ;
  
  PLUS
     : Plus
     ;
  
  OR
     : Pipe
     ;
  
  DOLLAR
     : Dollar
     ;
  
  RANGE
     : Range
     ;
  
  DOT
     : Dot
     ;
  
  AT
     : At
     ;
  
  POUND
     : Pound
     ;
  
  NOT
     : Tilde
     ;
     // -------------------------
     // Identifiers - allows unicode rule/token names
  
  ID
     : Id
     ;
     // -------------------------
     // Whitespace
  
  WS
     : Ws+ -> channel (OFF_CHANNEL)
     ;
  
  // -------------------------
  // Illegal Characters
  