org.hibernate.sql.ordering.antlr.GeneratedOrderByLexer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
JPMS Module-Info's for a few of the Jakarta Libraries just until they add them in themselves
// $ANTLR : "order-by.g" -> "GeneratedOrderByLexer.java"$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*
*/
package org.hibernate.sql.ordering.org.hibernate.relocated.org.hibernate.relocated.antlr;
import java.io.InputStream;
import org.hibernate.relocated.org.hibernate.relocated.antlr.TokenStreamException;
import org.hibernate.relocated.org.hibernate.relocated.antlr.TokenStreamIOException;
import org.hibernate.relocated.org.hibernate.relocated.antlr.TokenStreamRecognitionException;
import org.hibernate.relocated.org.hibernate.relocated.antlr.CharStreamException;
import org.hibernate.relocated.org.hibernate.relocated.antlr.CharStreamIOException;
import org.hibernate.relocated.org.hibernate.relocated.antlr.ANTLRException;
import java.io.Reader;
import java.util.Hashtable;
import org.hibernate.relocated.org.hibernate.relocated.antlr.CharScanner;
import org.hibernate.relocated.org.hibernate.relocated.antlr.InputBuffer;
import org.hibernate.relocated.org.hibernate.relocated.antlr.ByteBuffer;
import org.hibernate.relocated.org.hibernate.relocated.antlr.CharBuffer;
import org.hibernate.relocated.org.hibernate.relocated.antlr.Token;
import org.hibernate.relocated.org.hibernate.relocated.antlr.CommonToken;
import org.hibernate.relocated.org.hibernate.relocated.antlr.RecognitionException;
import org.hibernate.relocated.org.hibernate.relocated.antlr.NoViableAltForCharException;
import org.hibernate.relocated.org.hibernate.relocated.antlr.MismatchedCharException;
import org.hibernate.relocated.org.hibernate.relocated.antlr.TokenStream;
import org.hibernate.relocated.org.hibernate.relocated.antlr.ANTLRHashString;
import org.hibernate.relocated.org.hibernate.relocated.antlr.LexerSharedInputState;
import org.hibernate.relocated.org.hibernate.relocated.antlr.collections.impl.BitSet;
import org.hibernate.relocated.org.hibernate.relocated.antlr.SemanticException;
/**
* Lexer for the order-by fragment parser
* @author Steve Ebersole
* @author Joshua Davis
*/
public class GeneratedOrderByLexer extends org.hibernate.relocated.org.hibernate.relocated.antlr.CharScanner implements OrderByTemplateTokenTypes, TokenStream
{
public GeneratedOrderByLexer(InputStream in) {
this(new ByteBuffer(in));
}
public GeneratedOrderByLexer(Reader in) {
this(new CharBuffer(in));
}
public GeneratedOrderByLexer(InputBuffer ib) {
this(new LexerSharedInputState(ib));
}
public GeneratedOrderByLexer(LexerSharedInputState state) {
super(state);
caseSensitiveLiterals = false;
setCaseSensitive(false);
literals = new Hashtable();
literals.put(new ANTLRHashString("asc", this), new Integer(14));
literals.put(new ANTLRHashString("desc", this), new Integer(15));
literals.put(new ANTLRHashString("descending", this), new Integer(30));
literals.put(new ANTLRHashString("nulls", this), new Integer(16));
literals.put(new ANTLRHashString("collate", this), new Integer(13));
literals.put(new ANTLRHashString("ascending", this), new Integer(29));
}
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 '(':
{
mOPEN_PAREN(true);
theRetToken=_returnToken;
break;
}
case ')':
{
mCLOSE_PAREN(true);
theRetToken=_returnToken;
break;
}
case ',':
{
mCOMMA(true);
theRetToken=_returnToken;
break;
}
case '`':
{
mHARD_QUOTE(true);
theRetToken=_returnToken;
break;
}
case '\'':
{
mQUOTED_STRING(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_INT(true);
theRetToken=_returnToken;
break;
}
case '\t': case '\n': case '\r': case ' ':
{
mWS(true);
theRetToken=_returnToken;
break;
}
default:
if ((_tokenSet_0.member(LA(1)))) {
mIDENT(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());
}
}
}
}
public final void mOPEN_PAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = OPEN_PAREN;
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;
}
public final void mCLOSE_PAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = CLOSE_PAREN;
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;
}
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;
}
public final void mHARD_QUOTE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = HARD_QUOTE;
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;
}
public final void mIDENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = IDENT;
int _saveIndex;
mID_START_LETTER(false);
{
_loop708:
do {
if ((_tokenSet_1.member(LA(1)))) {
mID_LETTER(false);
}
else {
break _loop708;
}
} while (true);
}
_ttype = testLiteralsTable(_ttype);
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
protected final void mID_START_LETTER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ID_START_LETTER;
int _saveIndex;
switch ( LA(1)) {
case '_':
{
match('_');
break;
}
case '$':
{
match('$');
break;
}
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':
{
matchRange('a','z');
break;
}
default:
if (((LA(1) >= '\u0080' && LA(1) <= '\ufffe'))) {
matchRange('\u0080','\ufffe');
}
else {
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;
}
protected final void mID_LETTER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ID_LETTER;
int _saveIndex;
if ((_tokenSet_0.member(LA(1)))) {
mID_START_LETTER(false);
}
else if (((LA(1) >= '0' && LA(1) <= '9'))) {
matchRange('0','9');
}
else {
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;
}
public final void mQUOTED_STRING(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = QUOTED_STRING;
int _saveIndex;
match('\'');
{
_loop715:
do {
boolean synPredMatched714 = false;
if (((LA(1)=='\'') && (LA(2)=='\''))) {
int _m714 = mark();
synPredMatched714 = true;
inputState.guessing++;
try {
{
mESCqs(false);
}
}
catch (RecognitionException pe) {
synPredMatched714 = false;
}
rewind(_m714);
inputState.guessing--;
}
if ( synPredMatched714 ) {
mESCqs(false);
}
else if ((_tokenSet_2.member(LA(1)))) {
matchNot('\'');
}
else {
break _loop715;
}
} 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;
}
protected final void mESCqs(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = ESCqs;
int _saveIndex;
match('\'');
match('\'');
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
public final void mNUM_INT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = NUM_INT;
int _saveIndex;
Token f1=null;
Token f2=null;
Token f3=null;
Token f4=null;
boolean isDecimal=false; Token t=null;
switch ( LA(1)) {
case '.':
{
match('.');
if ( inputState.guessing==0 ) {
_ttype = DOT;
}
{
if (((LA(1) >= '0' && LA(1) <= '9'))) {
{
int _cnt720=0;
_loop720:
do {
if (((LA(1) >= '0' && LA(1) <= '9'))) {
matchRange('0','9');
}
else {
if ( _cnt720>=1 ) { break _loop720; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
}
_cnt720++;
} while (true);
}
{
if ((LA(1)=='e')) {
mEXPONENT(false);
}
else {
}
}
{
if ((LA(1)=='d'||LA(1)=='f')) {
mFLOAT_SUFFIX(true);
f1=_returnToken;
if ( inputState.guessing==0 ) {
t=f1;
}
}
else {
}
}
if ( inputState.guessing==0 ) {
if (t != null && t.getText().toUpperCase().indexOf('F')>=0)
{
_ttype = NUM_FLOAT;
}
else
{
_ttype = NUM_DOUBLE; // assume double
}
}
}
else {
}
}
break;
}
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
{
{
switch ( LA(1)) {
case '0':
{
match('0');
if ( inputState.guessing==0 ) {
isDecimal = true;
}
{
switch ( LA(1)) {
case 'x':
{
{
match('x');
}
{
int _cnt727=0;
_loop727:
do {
if ((_tokenSet_3.member(LA(1))) && (true)) {
mHEX_DIGIT(false);
}
else {
if ( _cnt727>=1 ) { break _loop727; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
}
_cnt727++;
} while (true);
}
break;
}
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
{
{
int _cnt729=0;
_loop729:
do {
if (((LA(1) >= '0' && LA(1) <= '7'))) {
matchRange('0','7');
}
else {
if ( _cnt729>=1 ) { break _loop729; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
}
_cnt729++;
} while (true);
}
break;
}
default:
{
}
}
}
break;
}
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8':
case '9':
{
{
matchRange('1','9');
}
{
_loop732:
do {
if (((LA(1) >= '0' && LA(1) <= '9'))) {
matchRange('0','9');
}
else {
break _loop732;
}
} while (true);
}
if ( inputState.guessing==0 ) {
isDecimal=true;
}
break;
}
default:
{
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
}
}
}
{
if ((LA(1)=='l')) {
{
match('l');
}
if ( inputState.guessing==0 ) {
_ttype = NUM_LONG;
}
}
else if (((_tokenSet_4.member(LA(1))))&&(isDecimal)) {
{
switch ( LA(1)) {
case '.':
{
match('.');
{
_loop737:
do {
if (((LA(1) >= '0' && LA(1) <= '9'))) {
matchRange('0','9');
}
else {
break _loop737;
}
} while (true);
}
{
if ((LA(1)=='e')) {
mEXPONENT(false);
}
else {
}
}
{
if ((LA(1)=='d'||LA(1)=='f')) {
mFLOAT_SUFFIX(true);
f2=_returnToken;
if ( inputState.guessing==0 ) {
t=f2;
}
}
else {
}
}
break;
}
case 'e':
{
mEXPONENT(false);
{
if ((LA(1)=='d'||LA(1)=='f')) {
mFLOAT_SUFFIX(true);
f3=_returnToken;
if ( inputState.guessing==0 ) {
t=f3;
}
}
else {
}
}
break;
}
case 'd': case 'f':
{
mFLOAT_SUFFIX(true);
f4=_returnToken;
if ( inputState.guessing==0 ) {
t=f4;
}
break;
}
default:
{
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
}
}
}
if ( inputState.guessing==0 ) {
if (t != null && t.getText().toUpperCase() .indexOf('F') >= 0)
{
_ttype = NUM_FLOAT;
}
else
{
_ttype = NUM_DOUBLE; // assume double
}
}
}
else {
}
}
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;
}
protected final void mEXPONENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = EXPONENT;
int _saveIndex;
{
match('e');
}
{
switch ( LA(1)) {
case '+':
{
match('+');
break;
}
case '-':
{
match('-');
break;
}
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
{
break;
}
default:
{
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
}
}
}
{
int _cnt747=0;
_loop747:
do {
if (((LA(1) >= '0' && LA(1) <= '9'))) {
matchRange('0','9');
}
else {
if ( _cnt747>=1 ) { break _loop747; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
}
_cnt747++;
} while (true);
}
if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
_token = makeToken(_ttype);
_token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
}
_returnToken = _token;
}
protected final void mFLOAT_SUFFIX(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = FLOAT_SUFFIX;
int _saveIndex;
switch ( LA(1)) {
case 'f':
{
match('f');
break;
}
case 'd':
{
match('d');
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;
}
protected final void mHEX_DIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = HEX_DIGIT;
int _saveIndex;
{
switch ( LA(1)) {
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
{
matchRange('0','9');
break;
}
case 'a': case 'b': case 'c': case 'd':
case 'e': case 'f':
{
matchRange('a','f');
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;
}
public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
int _ttype; Token _token=null; int _begin=text.length();
_ttype = WS;
int _saveIndex;
{
switch ( LA(1)) {
case ' ':
{
match(' ');
break;
}
case '\t':
{
match('\t');
break;
}
case '\n':
{
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
break;
}
default:
if ((LA(1)=='\r') && (LA(2)=='\n')) {
match('\r');
match('\n');
if ( inputState.guessing==0 ) {
newline();
}
}
else if ((LA(1)=='\r') && (true)) {
match('\r');
if ( inputState.guessing==0 ) {
newline();
}
}
else {
throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
}
}
}
if ( inputState.guessing==0 ) {
_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;
}
private static final long[] mk_tokenSet_0() {
long[] data = new long[3072];
data[0]=68719476736L;
data[1]=576460745860972544L;
for (int i = 2; i<=1022; i++) { data[i]=-1L; }
data[1023]=9223372036854775807L;
return data;
}
public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
private static final long[] mk_tokenSet_1() {
long[] data = new long[3072];
data[0]=287948969894477824L;
data[1]=576460745860972544L;
for (int i = 2; i<=1022; i++) { data[i]=-1L; }
data[1023]=9223372036854775807L;
return data;
}
public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
private static final long[] mk_tokenSet_2() {
long[] data = new long[2048];
data[0]=-549755813889L;
for (int i = 1; i<=1022; i++) { data[i]=-1L; }
data[1023]=9223372036854775807L;
return data;
}
public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
private static final long[] mk_tokenSet_3() {
long[] data = new long[1025];
data[0]=287948901175001088L;
data[1]=541165879296L;
return data;
}
public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
private static final long[] mk_tokenSet_4() {
long[] data = new long[1025];
data[0]=70368744177664L;
data[1]=481036337152L;
return data;
}
public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4());
}