HQLLexer.java

// $ANTLR 2.7.7 (20060906): "hql.g" -> "HQLLexer.java"$

/*
** Module   : HQLParser.java
**            HQLParserTokenTypes.java
**            HQLLexer.java
** Abstract : 
**
** Copyright (c) 2006-2023, Golden Code Development Corporation.
**
** -#- -I- --Date-- --JPRM-- -----------------------------Description-----------------------------
** 001 ECF 20060314   @25235 WARNING, THIS IS A GENERATED FILE!!!
**                           DO NOT EDIT THIS FILE. The original source file is hql.g!
*/

package com.goldencode.p2j.persist.hql;

import java.util.*;
import java.util.List;
import java.text.*;
import java.io.*;
import antlr.*;
import com.goldencode.p2j.uast.*;
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 HQL query statement (input as a stream of characters) into a
 * stream of tokens suitable for the {@link HQLParser}.
 * <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>Please note that this is a generated file using ANTLR 2.7.4 and a
 * grammar specified in <code>hql.g</code>.</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</code>. 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
 * HQLParserTokenTypes} 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>HQLParserTokenTypes</code> 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>HQLParserTokenTypes</code> interface and can thus
 * be referenced directly by the lexer and parser.
 *
 * @author ECF
 * @author GES
 */
public class HQLLexer extends antlr.CharScanner implements HQLParserTokenTypes, TokenStream
 {

   /** Logger. */
   private static final CentralLogger LOG = CentralLogger.get(HQLLexer.class);

   /** Map of keywords to symbol tokens */
   private static Map keywords = new HashMap();

   // 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( "case",   Integer.valueOf(CASE) );
      keywords.put( "cast",   Integer.valueOf(CAST) );
      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( "in",     Integer.valueOf(IN) );
      keywords.put( "is",     Integer.valueOf(IS) );
      keywords.put( "join",   Integer.valueOf(JOIN) );
      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( "or",     Integer.valueOf(OR) );
      keywords.put( "select", Integer.valueOf(SELECT) );
      keywords.put( "then",   Integer.valueOf(THEN) );
      keywords.put( "true",   Integer.valueOf(BOOL_TRUE) );
      keywords.put( "when",   Integer.valueOf(WHEN) );
      keywords.put( "where",  Integer.valueOf(WHERE) );
      keywords.put( "yes",    Integer.valueOf(BOOL_TRUE) );
   }
   
   /**
    * Provides a command line interface for an end user to drive and/or test
    * the HQLLexer class.
    * <p>
    * Syntax:
    * <pre>
    *    java HQLLexer &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 HQLLexer <expression>");
         System.exit(-1);
      }
         
      try
      {
         StringReader    expr       = new StringReader(args[0]);
         HQLLexer        lexer      = new HQLLexer(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 = HQLParser._tokenNames[next.getType()];
            
            StringBuffer sb = new StringBuffer(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.toString()                     +
                               " "                               +
                               next.getText());
         } 
         while (next.getType() != Token.EOF_TYPE);
      }
      catch (Exception excpt)
      {
         LOG.severe("", excpt);
      }
   }   
public HQLLexer(InputStream in) {
	this(new ByteBuffer(in));
}
public HQLLexer(Reader in) {
	this(new CharBuffer(in));
}
public HQLLexer(InputBuffer ib) {
	this(new LexerSharedInputState(ib));
}
public HQLLexer(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 '?':
				{
					mSUBST(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)=='>') && (true)) {
						mGT(true);
						theRetToken=_returnToken;
					}
					else if ((LA(1)=='<') && (true)) {
						mLT(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</code> 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 _cnt79=0;
		_loop79:
		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 ( _cnt79>=1 ) { break _loop79; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
			}
			}
			_cnt79++;
		} 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 _} and {@code $}).
 * <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);
		{
		_loop82:
		do {
			if ((_tokenSet_0.member(LA(1)))) {
				mVALID_SYM_CHAR(false);
			}
			else {
				break _loop82;
			}
			
		} 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</code>). 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;
		}
		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</code> 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</code> 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</code> 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</code> 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</code> 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</code> 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</code> 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</code> 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</code> 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</code> 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</code> 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</code> 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</code> 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</code> 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</code> 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</code> 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>?</code>).  This is a top level rule, creating a
 * <code>SUBST</code> 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 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</code> 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</code> literal cannot be parsed by <code>Long.parseLong</code>
 *         then it is too large to fit in a 64-bit variable so it will be matched as 
 *         <code>DEC_LITERAL</code>.
 *    <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</code> 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</code> token type.
 *    <li> Matches a decimal point followed by a sequence of numeric digits
 *         as a decimal constant with a <code>DEC_LITERAL</code> token type.
 * </ul>
 * <p>
 * This is a top level rule.  The token type defaults to
 * <code>NUM_LITERAL</code> 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;
		
		{
		if ((LA(1)=='.') && ((LA(2) >= '0' && LA(2) <= '9'))) {
			match('.');
			{
			int _cnt103=0;
			_loop103:
			do {
				if (((LA(1) >= '0' && LA(1) <= '9'))) {
					mDIGIT(false);
				}
				else {
					if ( _cnt103>=1 ) { break _loop103; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
				}
				
				_cnt103++;
			} while (true);
			}
			ntype = DEC_LITERAL;
		}
		else if ((LA(1)=='.') && (true)) {
			match('.');
			ntype = DOT;
		}
		else if (((LA(1) >= '0' && LA(1) <= '9'))) {
			{
			int _cnt105=0;
			_loop105:
			do {
				if (((LA(1) >= '0' && LA(1) <= '9'))) {
					mDIGIT(false);
				}
				else {
					if ( _cnt105>=1 ) { break _loop105; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
				}
				
				_cnt105++;
			} while (true);
			}
			{
			if ((LA(1)=='.')) {
				match('.');
				{
				_loop108:
				do {
					if (((LA(1) >= '0' && LA(1) <= '9'))) {
						mDIGIT(false);
					}
					else {
						break _loop108;
					}
					
				} while (true);
				}
				ntype = DEC_LITERAL;
			}
			else {
			}
			
			}
		}
		else {
			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;
	}
	
/** Matches any numeric digit: <code>0 - 9</code> */
	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 an opening single quote, arbitrary contents and an ending single
 * quote.  Two contiguous 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('\'');
		{
		_loop112:
		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 _loop112;
			}
			
		} 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</code> */
	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>$ _</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 = { 287948969894477824L, 576460745860972544L, 0L, 0L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
	private static final long[] mk_tokenSet_1() {
		long[] data = new long[8];
		data[0]=-549755814920L;
		for (int i = 1; i<=3; i++) { data[i]=-1L; }
		return data;
	}
	public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
	
	}