FQLLexer.java

// $ANTLR 2.7.7 (20060906): "fql.g" -> "FQLLexer.java"$

/*
** Module   : FQLParser.java
**            FQLParserTokenTypes.java
**            FQLLexer.java
** Abstract : 
**
** Copyright (c) 2019, Golden Code Development Corporation.
**
** -#- -I- --Date-- ---------------------------------Description---------------------------------
** 001 OM  20190913 WARNING, THIS IS A GENERATED FILE. DO NOT EDIT THIS FILE!!! 
**                  The original source file is fql.g!
*/

package com.goldencode.p2j.persist.orm;

import java.util.*;
import java.text.*;
import java.io.*;
import antlr.*;
import com.goldencode.p2j.util.logging.*;

import java.io.InputStream;
import antlr.TokenStreamException;
import antlr.TokenStreamIOException;
import antlr.TokenStreamRecognitionException;
import antlr.CharStreamException;
import antlr.CharStreamIOException;
import antlr.ANTLRException;
import java.io.Reader;
import java.util.Hashtable;
import antlr.CharScanner;
import antlr.InputBuffer;
import antlr.ByteBuffer;
import antlr.CharBuffer;
import antlr.Token;
import antlr.CommonToken;
import antlr.RecognitionException;
import antlr.NoViableAltForCharException;
import antlr.MismatchedCharException;
import antlr.TokenStream;
import antlr.ANTLRHashString;
import antlr.LexerSharedInputState;
import antlr.collections.impl.BitSet;
import antlr.SemanticException;

/**
 * Tokenizes an FQL query statement (input as a stream of characters) into a stream of tokens
 * suitable for the {@link FQLParser}.
 * <p>
 * Each token has an integer token type by which the parser references and matches tokens. This is
 * done to make a high performance parser. To make this work, the lexer must create a token object
 * when it matches a top level rule, this token object includes the token type and the actual text
 * found in the original character stream. The lexer's main job is to look ahead into the
 * character stream, switch into the top level rule that matches some set of characters and when
 * this is complete, to create a valid token object and return this to the parser. The lexer thus
 * implements a token stream interface from the parser's perspective.
 * <p>
 * <b>This is a generated file using ANTLR 2.7.x and a grammar specified in {@code fql.g}.</b>
 * <p>
 * Symbol resolution is the process by which the proper token type is assigned to a token created
 * from a match to the generic symbol rule. In the lexer, the only symbol resolution that can be
 * done is to match with reserved keywords. Reserved keywords are given preference over other
 * symbol types in any case where there is a conflict.
 * <p>
 * Other key design points:
 * <ul>
 *    <li>This grammar has been designed to ignore case. All symbol definitions use lowercase
 *        characters and ANTLR generates code to match both the uppercase and lowercase version of
 *        each character. This is enabled using the lexer options section.
 *    <li>The lexer is defined to create a single token of any string. All logic for matching
 *        string literals is embedded in the lexer.
 *    <li>At the top level of the lexer, all tokens are one of the following types: 
 *       <ul>
 *          <li>string literals
 *          <li>whitespace (spaces, tabs, carriage returns, line feeds)
 *          <li>operators
 *          <li>integer and decimal literals
 *          <li>reserved keywords 
 *          <li>user-defined symbols
 *       </ul>
 *    <li>The lexer's top level entry point is {@code nextToken}. This method has a for-loop that
 *        uses up to 3 characters of lookahead to identify which of the top level token rules to
 *        call. To do this, each token rule's left-most match characters are "rolled up" and
 *        tested in this top level rule. 
 *    <li>Whitespace tokens are artificially set to the special "skip" token type, which drops
 *        them from the token stream seen by the parser. This is an important feature that
 *        simplifies the parser design.
 * </ul>
 * <p>
 * All token types are defined as integer constants in {@link FQLParserTokenTypes} which is an
 * interface that the parser, lexer and other related classes all implement. This allows all of
 * these classes to directly refer to the token types and share this common set of definitions.
 * All top-level lexer rules generate a token of the same name in the
 * {@code FQLParserTokenTypes} interface.
 * <p> 
 * There is a tokens { } section in the parser where artificial tokens are defined (tokens that
 * are not backed by a lexer rule). These tokens are also added to the
 * {@code FQLParserTokenTypes} interface and can thus be referenced directly by the lexer
 * and parser.
 */
public class FQLLexer extends antlr.CharScanner implements FQLParserTokenTypes, TokenStream
 {
 
   /** Logger. */
   private static final CentralLogger LOG = CentralLogger.get(FQLLexer.class);

   /** Map of keywords to symbol tokens */
   private static Map keywords = new HashMap();
   
   /** The set of all keywords. */
   private static Set allWords = new HashSet();
   
   // Static initializer which populates a keyword map where the symbol text (in the mSYMBOL
   // method) can be submitted to the keyword map for a lookup. If a match is found, then the
   // token type of the token is set based on the token type field stored in the map. This token
   // type will override the default token type of SYMBOL. Since all of these keywords are not
   // encoded in the matching rules of the grammar itself, there are no actual token definitions
   // in the lexer that match these keywords.
   static
   {
      keywords.put( "and",    Integer.valueOf(AND) );
      keywords.put( "as",     Integer.valueOf(AS) );
      keywords.put( "asc",    Integer.valueOf(ASC) );
      keywords.put( "by",     Integer.valueOf(BY) );
      keywords.put( "case",   Integer.valueOf(CASE) );
      keywords.put( "cast",   Integer.valueOf(CAST) );
      keywords.put( "cross",  Integer.valueOf(CROSS) );
      keywords.put( "delete", Integer.valueOf(DELETE) );
      keywords.put( "desc",   Integer.valueOf(DESC) );
      keywords.put( "else",   Integer.valueOf(ELSE) );
      keywords.put( "end",    Integer.valueOf(END) );
      keywords.put( "escape", Integer.valueOf(ESCAPE) );
      keywords.put( "false",  Integer.valueOf(BOOL_FALSE) );
      keywords.put( "from",   Integer.valueOf(FROM) );
      keywords.put( "full",   Integer.valueOf(FULL) );
      keywords.put( "group",  Integer.valueOf(GROUP) );
      keywords.put( "having", Integer.valueOf(HAVING) );
      keywords.put( "in",     Integer.valueOf(IN) );
      keywords.put( "inner",  Integer.valueOf(INNER) );
      keywords.put( "insert", Integer.valueOf(INSERT) );
      keywords.put( "into",   Integer.valueOf(INTO) );
      keywords.put( "is",     Integer.valueOf(IS) );
      keywords.put( "join",   Integer.valueOf(JOIN) );
      keywords.put( "left",   Integer.valueOf(LEFT) );
      keywords.put( "like",   Integer.valueOf(LIKE) );
      keywords.put( "no",     Integer.valueOf(BOOL_FALSE) );
      keywords.put( "not",    Integer.valueOf(NOT) );
      keywords.put( "null",   Integer.valueOf(NULL) );
      keywords.put( "on",     Integer.valueOf(ON) );
      keywords.put( "or",     Integer.valueOf(OR) );
      keywords.put( "order",  Integer.valueOf(ORDER) );
      keywords.put( "outer",  Integer.valueOf(OUTER) );
      keywords.put( "right",  Integer.valueOf(RIGHT) );
      keywords.put( "select", Integer.valueOf(SELECT) );
      keywords.put( "set",    Integer.valueOf(SET) );
      keywords.put( "single", Integer.valueOf(SINGLE) );
      keywords.put( "then",   Integer.valueOf(THEN) );
      keywords.put( "true",   Integer.valueOf(BOOL_TRUE) );
      keywords.put( "update", Integer.valueOf(UPDATE) );
      keywords.put( "values", Integer.valueOf(VALUES) );
      keywords.put( "when",   Integer.valueOf(WHEN) );
      keywords.put( "where",  Integer.valueOf(WHERE) );
      keywords.put( "yes",    Integer.valueOf(BOOL_TRUE) );
      
      allWords.addAll(keywords.keySet());
      
      allWords = Collections.unmodifiableSet(allWords);
   }
   
   /**
    * Get the set of all reserved keywords.
    *
    * @return   See above.
    */
   public static Set getReserved()
   {
      return allWords;
   }
   
   /**
    * Provides a command line interface for an end user to drive and/or test the FQLLexer class.
    * <p>
    * Syntax:
    * <pre>
    *    java FQLLexer &lt;expression&gt;
    * </pre>
    *
    * @param   args 
    *          List of command line arguments.
    */
   public static void main(String[] args)  
   {
      if (args.length != 1)
      {
         LOG.severe("Syntax: java FQLLexer <expression>");
         System.exit(-1);
      }
      
      try
      {
         StringReader    expr       = new StringReader(args[0]);
         FQLLexer        lexer      = new FQLLexer(expr);
         int             maxSymSize = 20;
         NumberFormat    lfmt       = NumberFormat.getInstance();
         NumberFormat    cfmt       = NumberFormat.getInstance();
         
         CommonToken     next;
         String          decode;
         
         lfmt.setMinimumIntegerDigits(5);
         lfmt.setGroupingUsed(false);
         cfmt.setMinimumIntegerDigits(3);
         cfmt.setGroupingUsed(false);
         
         do
         {
            next = (CommonToken) lexer.nextToken();
            decode = FQLParser._tokenNames[next.getType()];
            
            StringBuilder sb = new StringBuilder(decode).append('>');
            int trailing = maxSymSize - decode.length();
            
            for (int i = 0; i < trailing; i++)
            {
               sb.append(' ');
            }
            
            System.out.println("[" + lfmt.format(next.getLine()) + ":" + cfmt.format(next.getColumn()) +
                               "] <" + sb + " " + next.getText());
         } 
         while (next.getType() != Token.EOF_TYPE);
      }
      catch(Exception excpt)
      {
         LOG.severe("", excpt);
      }
   }   
public FQLLexer(InputStream in) {
	this(new ByteBuffer(in));
}
public FQLLexer(Reader in) {
	this(new CharBuffer(in));
}
public FQLLexer(InputBuffer ib) {
	this(new LexerSharedInputState(ib));
}
public FQLLexer(LexerSharedInputState state) {
	super(state);
	caseSensitiveLiterals = false;
	setCaseSensitive(false);
	literals = new Hashtable();
}

public Token nextToken() throws TokenStreamException {
	Token theRetToken=null;
tryAgain:
	for (;;) {
		Token _token = null;
		int _ttype = Token.INVALID_TYPE;
		resetText();
		try {   // for char stream error handling
			try {   // for lexical error handling
				switch ( LA(1)) {
				case '\t':  case '\n':  case '\r':  case ' ':
				{
					mWS(true);
					theRetToken=_returnToken;
					break;
				}
				case '$':  case '_':  case 'a':  case 'b':
				case 'c':  case 'd':  case 'e':  case 'f':
				case 'g':  case 'h':  case 'i':  case 'j':
				case 'k':  case 'l':  case 'm':  case 'n':
				case 'o':  case 'p':  case 'q':  case 'r':
				case 's':  case 't':  case 'u':  case 'v':
				case 'w':  case 'x':  case 'y':  case 'z':
				{
					mSYMBOL(true);
					theRetToken=_returnToken;
					break;
				}
				case '|':
				{
					mCONCAT(true);
					theRetToken=_returnToken;
					break;
				}
				case ',':
				{
					mCOMMA(true);
					theRetToken=_returnToken;
					break;
				}
				case '=':
				{
					mEQUALS(true);
					theRetToken=_returnToken;
					break;
				}
				case '!':
				{
					mNOT_EQ(true);
					theRetToken=_returnToken;
					break;
				}
				case '[':
				{
					mLBRACKET(true);
					theRetToken=_returnToken;
					break;
				}
				case ']':
				{
					mRBRACKET(true);
					theRetToken=_returnToken;
					break;
				}
				case '(':
				{
					mLPARENS(true);
					theRetToken=_returnToken;
					break;
				}
				case ')':
				{
					mRPARENS(true);
					theRetToken=_returnToken;
					break;
				}
				case '+':
				{
					mPLUS(true);
					theRetToken=_returnToken;
					break;
				}
				case '-':
				{
					mMINUS(true);
					theRetToken=_returnToken;
					break;
				}
				case '*':
				{
					mMULTIPLY(true);
					theRetToken=_returnToken;
					break;
				}
				case '/':
				{
					mDIVIDE(true);
					theRetToken=_returnToken;
					break;
				}
				case '.':  case '0':  case '1':  case '2':
				case '3':  case '4':  case '5':  case '6':
				case '7':  case '8':  case '9':
				{
					mNUM_LITERAL(true);
					theRetToken=_returnToken;
					break;
				}
				case '\'':
				{
					mSTRING(true);
					theRetToken=_returnToken;
					break;
				}
				default:
					if ((LA(1)=='>') && (LA(2)=='=')) {
						mGTE(true);
						theRetToken=_returnToken;
					}
					else if ((LA(1)=='<') && (LA(2)=='=')) {
						mLTE(true);
						theRetToken=_returnToken;
					}
					else if ((LA(1)=='?') && ((LA(2) >= '0' && LA(2) <= '9'))) {
						mPOSITIONAL(true);
						theRetToken=_returnToken;
					}
					else if ((LA(1)=='>') && (true)) {
						mGT(true);
						theRetToken=_returnToken;
					}
					else if ((LA(1)=='<') && (true)) {
						mLT(true);
						theRetToken=_returnToken;
					}
					else if ((LA(1)=='?') && (true)) {
						mSUBST(true);
						theRetToken=_returnToken;
					}
				else {
					if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
				else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
				}
				}
				if ( _returnToken==null ) continue tryAgain; // found SKIP token
				_ttype = _returnToken.getType();
				_returnToken.setType(_ttype);
				return _returnToken;
			}
			catch (RecognitionException e) {
				throw new TokenStreamRecognitionException(e);
			}
		}
		catch (CharStreamException cse) {
			if ( cse instanceof CharStreamIOException ) {
				throw new TokenStreamIOException(((CharStreamIOException)cse).io);
			}
			else {
				throw new TokenStreamException(cse.getMessage());
			}
		}
	}
}

/**
 * Matches any amount of whitespace in an expression and sets the token type to SKIP. In addition,
 * each newline character causes the lexer's line counter to be incremented in order to properly
 * maintain each token's line information.
 * <p>
 * Spaces, tabs and carriage returns and line feeds (newlines) are all matched.
 * <p>
 * This is a top level lexer rule which means that there is an associated {@code WS} token.
 */
	public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = WS;
		int _saveIndex;
		
		{
		int _cnt119=0;
		_loop119:
		do {
			switch ( LA(1)) {
			case ' ':
			{
				match(' ');
				break;
			}
			case '\t':
			{
				match('\t');
				break;
			}
			case '\r':
			{
				match('\r');
				break;
			}
			case '\n':
			{
				match('\n');
				newline();
				break;
			}
			default:
			{
				if ( _cnt119>=1 ) { break _loop119; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
			}
			}
			_cnt119++;
		} while (true);
		}
		_ttype =  Token.SKIP;
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Match a valid symbol name. All symbols must start with an alphabetic character, the "_"
 * character or the "$" character.  Subsequent characters can be alphanumeric or one of the
 * special symbol characters ({@code _}, {@code $}) and the {@code DOT}. Depending on the context,
 * the latter will be interpreted as a property qualifier or package separator for {@code alias}-es.
 *
 * <b>Symbols are matched case-insensitively.</b>
 * <p>
 * Once a symbol has been found, a keyword lookup occurs. If matched, the the token's type is
 * overridden from the default ({@code SYMBOL}) to the artificial token type associated with
 * the keyword.
 * <p>
 * This is a top level lexer rule which means that there is an associated {@code SYMBOL} token.
 */
	public final void mSYMBOL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = SYMBOL;
		int _saveIndex;
		
		mVALID_1ST_IDENT(false);
		{
		_loop122:
		do {
			if ((_tokenSet_0.member(LA(1)))) {
				mVALID_SYM_CHAR(false);
			}
			else {
				break _loop122;
			}
			
		} while (true);
		}
		
		int stype = SYMBOL;
		
		Integer found = (Integer) keywords.get(getText().toLowerCase());
		
		if (found != null)
		{
		// symbol is a keyword; set the token type accordingly.
		stype = found.intValue();
		}
		
		_ttype = stype;
		
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches any character that can appear in the 1st position of a symbol (matches any
 * {@code LETTER} or {@code SYM_CHAR}).
 */
	protected final void mVALID_1ST_IDENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = VALID_1ST_IDENT;
		int _saveIndex;
		
		switch ( LA(1)) {
		case 'a':  case 'b':  case 'c':  case 'd':
		case 'e':  case 'f':  case 'g':  case 'h':
		case 'i':  case 'j':  case 'k':  case 'l':
		case 'm':  case 'n':  case 'o':  case 'p':
		case 'q':  case 'r':  case 's':  case 't':
		case 'u':  case 'v':  case 'w':  case 'x':
		case 'y':  case 'z':
		{
			mLETTER(false);
			break;
		}
		case '$':  case '_':
		{
			mSYM_CHAR(false);
			break;
		}
		default:
		{
			throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
		}
		}
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches any single character that can appear in the 2nd or later position in a symbol (matches
 * any {@code LETTER, DIGIT or SYM_CHAR}). This is simply a helper rule to make references easier.
 */
	protected final void mVALID_SYM_CHAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = VALID_SYM_CHAR;
		int _saveIndex;
		
		switch ( LA(1)) {
		case 'a':  case 'b':  case 'c':  case 'd':
		case 'e':  case 'f':  case 'g':  case 'h':
		case 'i':  case 'j':  case 'k':  case 'l':
		case 'm':  case 'n':  case 'o':  case 'p':
		case 'q':  case 'r':  case 's':  case 't':
		case 'u':  case 'v':  case 'w':  case 'x':
		case 'y':  case 'z':
		{
			mLETTER(false);
			break;
		}
		case '0':  case '1':  case '2':  case '3':
		case '4':  case '5':  case '6':  case '7':
		case '8':  case '9':
		{
			mDIGIT(false);
			break;
		}
		case '$':  case '_':
		{
			mSYM_CHAR(false);
			break;
		}
		case '.':
		{
			mDOT(false);
			break;
		}
		default:
		{
			throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
		}
		}
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the '||' concatenation operator. This is a top level rule, creating a {@code CONCAT}
 * token type.
 */
	public final void mCONCAT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = CONCAT;
		int _saveIndex;
		
		match("||");
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the ',' character. This is a top level rule, creating a {@code COMMA} token type.
 */
	public final void mCOMMA(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = COMMA;
		int _saveIndex;
		
		match(',');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the "=" string. This is a top level rule, creating an {@code EQUALS} token type.
 */
	public final void mEQUALS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = EQUALS;
		int _saveIndex;
		
		match("=");
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the inequality string. This is a top level rule, creating a {@code NOT_EQ} token type.
 */
	public final void mNOT_EQ(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = NOT_EQ;
		int _saveIndex;
		
		match("!=");
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the '&gt;' character. This is a top level rule, creating a {@code GT} token type.
 */
	public final void mGT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = GT;
		int _saveIndex;
		
		match('>');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the '&lt;' character. This is a top level rule, creating a {@code LT} token type.
 */
	public final void mLT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = LT;
		int _saveIndex;
		
		match('<');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the '&gt;=' character sequence. This is a top level rule, creating a {@code GTE} token
 * type.
 */
	public final void mGTE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = GTE;
		int _saveIndex;
		
		match(">=");
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the '&lt;=' character sequence. This is a top level rule, creating a {@code LTE} token
 * type.
 */
	public final void mLTE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = LTE;
		int _saveIndex;
		
		match("<=");
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the '[' character. This is a top level rule, creating a {@code LBRACKET} token type.
 */
	public final void mLBRACKET(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = LBRACKET;
		int _saveIndex;
		
		match('[');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the ']' character. This is a top level rule, creating a {@code RBRACKET} token type.
 */
	public final void mRBRACKET(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = RBRACKET;
		int _saveIndex;
		
		match(']');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the '(' character. This is a top level rule, creating a {@code LPARENS} token type.
 */
	public final void mLPARENS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = LPARENS;
		int _saveIndex;
		
		match('(');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the ')' character. This is a top level rule, creating a {@code RPARENS} token type.
 */
	public final void mRPARENS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = RPARENS;
		int _saveIndex;
		
		match(')');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the '+' character. This is a top level rule, creating a {@code PLUS} token type.
 */
	public final void mPLUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = PLUS;
		int _saveIndex;
		
		match('+');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the '-' character. This is a top level rule, creating a {@code MINUS} token type.
 */
	public final void mMINUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = MINUS;
		int _saveIndex;
		
		match('-');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the '*' character. This is a top level rule, creating a {@code MULTIPLY} token type.
 */
	public final void mMULTIPLY(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = MULTIPLY;
		int _saveIndex;
		
		match('*');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the '/' character. This is a top level rule, creating a {@code DIVIDE} token type.
 */
	public final void mDIVIDE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = DIVIDE;
		int _saveIndex;
		
		match('/');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches the query substitution parameter placeholder character. This is a question mark
 * ({@code ?}). This is a top level rule, creating a {@code SUBST} token type.
 */
	public final void mSUBST(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = SUBST;
		int _saveIndex;
		
		match('?');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/** Matches a positional parameter {@code ?\d+}. */
	public final void mPOSITIONAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = POSITIONAL;
		int _saveIndex;
		
		match('?');
		{
		int _cnt142=0;
		_loop142:
		do {
			if (((LA(1) >= '0' && LA(1) <= '9'))) {
				mDIGIT(false);
			}
			else {
				if ( _cnt142>=1 ) { break _loop142; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
			}
			
			_cnt142++;
		} while (true);
		}
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/** Matches any numeric digit: {@code 0 - 9} */
	protected final void mDIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = DIGIT;
		int _saveIndex;
		
		matchRange('0','9');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches all forms of valid integer literals and decimal literals. Scenarios that are matched:
 * <ul>
 *    <li>Matches a sequence of one or more digits (without a decimal point and additional
 *        digits) as an integer literal with a {@code NUM_LITERAL} token type.
 *    <li>If the literal at previous step can be parsed as integer but cannot fit in 32-bit
 *        space, it will be set to LONG_LITERAL.
 *    <li>If the {@code NUM_LITERAL} literal cannot be parsed by {@code Long.parseLong} then it
 *        is too large to fit in a 64-bit variable so it will be matched as {@code DEC_LITERAL}.
 *    <li>Matches a sequence of one or more digits followed by a '.' but no additional digits, as
 *        a decimal literal with a {@code DEC_LITERAL} token type. 
 *    <li>Matches one or more numeric digits followed by a decimal point and another sequence of 
 *        numeric digits as a decimal constant with a {@code DEC_LITERAL} token type.
 *    <li>Matches a decimal point followed by a sequence of numeric digits as a decimal constant
 *        with a {@code DEC_LITERAL} token type.
 * </ul>
 * <p>
 * This is a top level rule. The token type defaults to {@code NUM_LITERAL} and is overridden by
 * specific actions depending on the scenario matched.
 */
	public final void mNUM_LITERAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = NUM_LITERAL;
		int _saveIndex;
		
		
		int ntype = NUM_LITERAL;
		
		{
		switch ( LA(1)) {
		case '.':
		{
			mDOT(false);
			{
			int _cnt146=0;
			_loop146:
			do {
				if (((LA(1) >= '0' && LA(1) <= '9'))) {
					mDIGIT(false);
				}
				else {
					if ( _cnt146>=1 ) { break _loop146; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
				}
				
				_cnt146++;
			} while (true);
			}
			ntype = DEC_LITERAL;
			break;
		}
		case '0':  case '1':  case '2':  case '3':
		case '4':  case '5':  case '6':  case '7':
		case '8':  case '9':
		{
			{
			int _cnt148=0;
			_loop148:
			do {
				if (((LA(1) >= '0' && LA(1) <= '9'))) {
					mDIGIT(false);
				}
				else {
					if ( _cnt148>=1 ) { break _loop148; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
				}
				
				_cnt148++;
			} while (true);
			}
			{
			if ((LA(1)=='.')) {
				mDOT(false);
				{
				_loop151:
				do {
					if (((LA(1) >= '0' && LA(1) <= '9'))) {
						mDIGIT(false);
					}
					else {
						break _loop151;
					}
					
				} while (true);
				}
				ntype = DEC_LITERAL;
			}
			else {
			}
			
			}
			break;
		}
		default:
		{
			throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
		}
		}
		}
		
		if (ntype == NUM_LITERAL)
		{
		try
		{
		long l = Long.parseLong(getText());
		if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE)
		{
		ntype = LONG_LITERAL;
		}
		}
		catch (NumberFormatException exc)
		{
		ntype = DEC_LITERAL;
		}
		}
		_ttype =  ntype;
		
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**<strong>The DOT</strong>. Used for decimal numbers, qualifying properties and package path separator. */
	protected final void mDOT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = DOT;
		int _saveIndex;
		
		match('.');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches an opening single quote, arbitrary contents and an ending single quote. Two continguous
 * single quote characters are used to specify a one single quote in the output string (it does
 * not terminate the string).
 * <p>
 * Any newlines inside the string are identified and the lexer's internal newline counter is
 * properly maintained.
 * <p>
 * The greedy option does not need to be disabled here as the closure rule termination is built
 * into the subrule itself: it accepts anything that isn't an unescaped single quote character
 * (see above).
 * <p>
 * Tabs and spaces are maintained inside strings. Opening and closing single quote characters are
 * dropped.
 */
	public final void mSTRING(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = STRING;
		int _saveIndex;
		
		{
		match('\'');
		{
		_loop155:
		do {
			if ((LA(1)=='\'') && (LA(2)=='\'')) {
				match("\'\'");
			}
			else if ((LA(1)=='\n')) {
				match('\n');
				newline();
			}
			else if ((_tokenSet_1.member(LA(1)))) {
				matchNot('\'');
			}
			else {
				break _loop155;
			}
			
		} while (true);
		}
		match('\'');
		}
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/** Matches any alphabetic character: {@code a - z} */
	protected final void mLETTER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = LETTER;
		int _saveIndex;
		
		matchRange('a','z');
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
/**
 * Matches all characters that can be made part of a valid user-defined symbol (except alphabetic
 * and numeric characters).  These are: {@code $ _}.
 */
	protected final void mSYM_CHAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
		int _ttype; Token _token=null; int _begin=text.length();
		_ttype = SYM_CHAR;
		int _saveIndex;
		
		switch ( LA(1)) {
		case '_':
		{
			match('_');
			break;
		}
		case '$':
		{
			match('$');
			break;
		}
		default:
		{
			throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
		}
		}
		if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
			_token = makeToken(_ttype);
			_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
		}
		_returnToken = _token;
	}
	
	
	private static final long[] mk_tokenSet_0() {
		long[] data = new long[1025];
		data[0]=288019338638655488L;
		data[1]=576460745860972544L;
		return data;
	}
	public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
	private static final long[] mk_tokenSet_1() {
		long[] data = new long[2048];
		data[0]=-549755814913L;
		for (int i = 1; i<=1022; i++) { data[i]=-1L; }
		data[1023]=9223372036854775807L;
		return data;
	}
	public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
	
	}