org.hibernate.hql.antlr

Class HqlBaseParser

Implemented Interfaces:
HqlTokenTypes
Known Direct Subclasses:
HqlParser

public class HqlBaseParser
extends LLkParser
implements HqlTokenTypes

Hibernate Query Language Grammar
This grammar parses the query language for Hibernate (an Open Source, Object-Relational mapping library). A partial BNF grammar description is available for reference here: http://www.hibernate.org/Documentation/HQLBNF Text from the original reference BNF is prefixed with '//##'.
Author:
Joshua Davis (pgmjsd@sourceforge.net)

Field Summary

static String[]
_tokenNames
static BitSet
_tokenSet_0
static BitSet
_tokenSet_1
static BitSet
_tokenSet_10
static BitSet
_tokenSet_11
static BitSet
_tokenSet_12
static BitSet
_tokenSet_13
static BitSet
_tokenSet_14
static BitSet
_tokenSet_15
static BitSet
_tokenSet_16
static BitSet
_tokenSet_17
static BitSet
_tokenSet_18
static BitSet
_tokenSet_19
static BitSet
_tokenSet_2
static BitSet
_tokenSet_20
static BitSet
_tokenSet_21
static BitSet
_tokenSet_22
static BitSet
_tokenSet_23
static BitSet
_tokenSet_24
static BitSet
_tokenSet_25
static BitSet
_tokenSet_26
static BitSet
_tokenSet_27
static BitSet
_tokenSet_28
static BitSet
_tokenSet_29
static BitSet
_tokenSet_3
static BitSet
_tokenSet_30
static BitSet
_tokenSet_31
static BitSet
_tokenSet_32
static BitSet
_tokenSet_33
static BitSet
_tokenSet_34
static BitSet
_tokenSet_35
static BitSet
_tokenSet_4
static BitSet
_tokenSet_5
static BitSet
_tokenSet_6
static BitSet
_tokenSet_7
static BitSet
_tokenSet_8
static BitSet
_tokenSet_9

Fields inherited from interface org.hibernate.hql.antlr.HqlTokenTypes

AGGREGATE, ALIAS, ALL, AND, ANY, AS, ASCENDING, AVG, BETWEEN, BOTH, CASE, CASE2, CLASS, CLOSE, CLOSE_BRACKET, COLON, COMMA, CONCAT, CONSTANT, CONSTRUCTOR, COUNT, DELETE, DESCENDING, DISTINCT, DIV, DOT, ELEMENTS, ELSE, EMPTY, END, EOF, EQ, ESCAPE, ESCqs, EXISTS, EXPONENT, EXPR_LIST, FALSE, FETCH, FILTER_ENTITY, FLOAT_SUFFIX, FROM, FULL, GE, GROUP, GT, HAVING, HEX_DIGIT, IDENT, ID_LETTER, ID_START_LETTER, IN, INDEX_OP, INDICES, INNER, INSERT, INTO, IN_LIST, IS, IS_NOT_NULL, IS_NULL, JAVA_CONSTANT, JOIN, LE, LEADING, LEFT, LIKE, LITERAL_ascending, LITERAL_by, LITERAL_descending, LT, MAX, MEMBER, METHOD_CALL, MIN, MINUS, NE, NEW, NOT, NOT_BETWEEN, NOT_IN, NOT_LIKE, NULL, NULL_TREE_LOOKAHEAD, NUM_DOUBLE, NUM_FLOAT, NUM_INT, NUM_LONG, OBJECT, OF, ON, OPEN, OPEN_BRACKET, OR, ORDER, ORDER_ELEMENT, OUTER, PARAM, PLUS, PROPERTIES, QUERY, QUOTED_STRING, RANGE, RIGHT, ROW_STAR, SELECT, SELECT_FROM, SET, SOME, SQL_NE, STAR, SUM, THEN, TRAILING, TRUE, UNARY_MINUS, UNARY_PLUS, UNION, UPDATE, VECTOR_EXPR, VERSIONED, WEIRD_IDENT, WHEN, WHERE, WITH, WS

Constructor Summary

HqlBaseParser(ParserSharedInputState state)
HqlBaseParser(TokenBuffer tokenBuf)
HqlBaseParser(TokenBuffer tokenBuf, int k)
HqlBaseParser(TokenStream lexer)
HqlBaseParser(TokenStream lexer, int k)

Method Summary

void
additiveExpression()
void
aggregate()
void
alias()
void
aliasedExpression()
void
altWhenClause()
void
asAlias()
void
ascendingOrDescending()
void
assignment()
void
atom()
void
betweenList()
protected void
buildTokenTypeASTClassMap()
void
caseExpression()
void
collectionExpr()
void
compoundExpr()
void
concatenation()
void
constant()
void
deleteStatement()
void
elseClause()
void
equalityExpression()
void
exprList()
void
expression()
void
expressionOrVector()
void
fromClassOrOuterQueryPath()
void
fromClause()
void
fromJoin()
void
fromRange()
void
groupByClause()
void
handleDotIdent()
This method looks ahead and converts .
AST
handleIdentifierError(Token token, RecognitionException ex)
This method is overriden in the sub class in order to provide the 'keyword as identifier' hack.
void
havingClause()
void
identPrimary()
void
identifier()
void
inClassDeclaration()
void
inCollectionDeclaration()
void
inCollectionElementsDeclaration()
void
inList()
void
insertStatement()
void
insertablePropertySpec()
void
intoClause()
boolean
isFilter()
Returns true if this is a filter query, false if not.
void
likeEscape()
void
logicalAndExpression()
void
logicalExpression()
void
logicalOrExpression()
void
multiplyExpression()
AST
negateNode(AST x)
Returns the negated equivalent of the expression.
void
negatedExpression()
void
newExpression()
void
newValue()
void
optionalFromTokenFromClause()
void
orderByClause()
void
orderElement()
void
path()
void
primaryExpression()
AST
processEqualityExpression(AST x)
Returns the 'cleaned up' version of a comparison operator sub-tree.
void
processMemberOf(Token n, AST p, ASTPair currentAST)
void
propertyFetch()
void
quantifiedExpression()
void
queryRule()
void
relationalExpression()
void
selectClause()
void
selectFrom()
void
selectObject()
void
selectStatement()
void
selectedPropertiesList()
void
setClause()
void
setFilter(boolean f)
Sets the filter flag.
void
stateField()
void
statement()
void
subQuery()
void
unaryExpression()
void
union()
void
updateStatement()
void
vectorExpr()
void
weakKeywords()
void
whenClause()
void
whereClause()
void
withClause()

Field Details

_tokenNames

public static final String[] _tokenNames

_tokenSet_0

public static final BitSet _tokenSet_0

_tokenSet_1

public static final BitSet _tokenSet_1

_tokenSet_10

public static final BitSet _tokenSet_10

_tokenSet_11

public static final BitSet _tokenSet_11

_tokenSet_12

public static final BitSet _tokenSet_12

_tokenSet_13

public static final BitSet _tokenSet_13

_tokenSet_14

public static final BitSet _tokenSet_14

_tokenSet_15

public static final BitSet _tokenSet_15

_tokenSet_16

public static final BitSet _tokenSet_16

_tokenSet_17

public static final BitSet _tokenSet_17

_tokenSet_18

public static final BitSet _tokenSet_18

_tokenSet_19

public static final BitSet _tokenSet_19

_tokenSet_2

public static final BitSet _tokenSet_2

_tokenSet_20

public static final BitSet _tokenSet_20

_tokenSet_21

public static final BitSet _tokenSet_21

_tokenSet_22

public static final BitSet _tokenSet_22

_tokenSet_23

public static final BitSet _tokenSet_23

_tokenSet_24

public static final BitSet _tokenSet_24

_tokenSet_25

public static final BitSet _tokenSet_25

_tokenSet_26

public static final BitSet _tokenSet_26

_tokenSet_27

public static final BitSet _tokenSet_27

_tokenSet_28

public static final BitSet _tokenSet_28

_tokenSet_29

public static final BitSet _tokenSet_29

_tokenSet_3

public static final BitSet _tokenSet_3

_tokenSet_30

public static final BitSet _tokenSet_30

_tokenSet_31

public static final BitSet _tokenSet_31

_tokenSet_32

public static final BitSet _tokenSet_32

_tokenSet_33

public static final BitSet _tokenSet_33

_tokenSet_34

public static final BitSet _tokenSet_34

_tokenSet_35

public static final BitSet _tokenSet_35

_tokenSet_4

public static final BitSet _tokenSet_4

_tokenSet_5

public static final BitSet _tokenSet_5

_tokenSet_6

public static final BitSet _tokenSet_6

_tokenSet_7

public static final BitSet _tokenSet_7

_tokenSet_8

public static final BitSet _tokenSet_8

_tokenSet_9

public static final BitSet _tokenSet_9

Constructor Details

HqlBaseParser

public HqlBaseParser(ParserSharedInputState state)

HqlBaseParser

public HqlBaseParser(TokenBuffer tokenBuf)

HqlBaseParser

protected HqlBaseParser(TokenBuffer tokenBuf,
                        int k)

HqlBaseParser

public HqlBaseParser(TokenStream lexer)

HqlBaseParser

protected HqlBaseParser(TokenStream lexer,
                        int k)

Method Details

additiveExpression

public final void additiveExpression()
            throws RecognitionException,
                   TokenStreamException

aggregate

public final void aggregate()
            throws RecognitionException,
                   TokenStreamException

alias

public final void alias()
            throws RecognitionException,
                   TokenStreamException

aliasedExpression

public final void aliasedExpression()
            throws RecognitionException,
                   TokenStreamException

altWhenClause

public final void altWhenClause()
            throws RecognitionException,
                   TokenStreamException

asAlias

public final void asAlias()
            throws RecognitionException,
                   TokenStreamException

ascendingOrDescending

public final void ascendingOrDescending()
            throws RecognitionException,
                   TokenStreamException

assignment

public final void assignment()
            throws RecognitionException,
                   TokenStreamException

atom

public final void atom()
            throws RecognitionException,
                   TokenStreamException

betweenList

public final void betweenList()
            throws RecognitionException,
                   TokenStreamException

buildTokenTypeASTClassMap

protected void buildTokenTypeASTClassMap()

caseExpression

public final void caseExpression()
            throws RecognitionException,
                   TokenStreamException

collectionExpr

public final void collectionExpr()
            throws RecognitionException,
                   TokenStreamException

compoundExpr

public final void compoundExpr()
            throws RecognitionException,
                   TokenStreamException

concatenation

public final void concatenation()
            throws RecognitionException,
                   TokenStreamException

constant

public final void constant()
            throws RecognitionException,
                   TokenStreamException

deleteStatement

public final void deleteStatement()
            throws RecognitionException,
                   TokenStreamException

elseClause

public final void elseClause()
            throws RecognitionException,
                   TokenStreamException

equalityExpression

public final void equalityExpression()
            throws RecognitionException,
                   TokenStreamException

exprList

public final void exprList()
            throws RecognitionException,
                   TokenStreamException

expression

public final void expression()
            throws RecognitionException,
                   TokenStreamException

expressionOrVector

public final void expressionOrVector()
            throws RecognitionException,
                   TokenStreamException

fromClassOrOuterQueryPath

public final void fromClassOrOuterQueryPath()
            throws RecognitionException,
                   TokenStreamException

fromClause

public final void fromClause()
            throws RecognitionException,
                   TokenStreamException

fromJoin

public final void fromJoin()
            throws RecognitionException,
                   TokenStreamException

fromRange

public final void fromRange()
            throws RecognitionException,
                   TokenStreamException

groupByClause

public final void groupByClause()
            throws RecognitionException,
                   TokenStreamException

handleDotIdent

public void handleDotIdent()
            throws TokenStreamException
This method looks ahead and converts . into . IDENT when appropriate.

handleIdentifierError

public AST handleIdentifierError(Token token,
                                 RecognitionException ex)
            throws RecognitionException,
                   TokenStreamException
This method is overriden in the sub class in order to provide the 'keyword as identifier' hack.
Parameters:
token - The token to retry as an identifier.
ex - The exception to throw if it cannot be retried as an identifier.

havingClause

public final void havingClause()
            throws RecognitionException,
                   TokenStreamException

identPrimary

public final void identPrimary()
            throws RecognitionException,
                   TokenStreamException

identifier

public final void identifier()
            throws RecognitionException,
                   TokenStreamException

inClassDeclaration

public final void inClassDeclaration()
            throws RecognitionException,
                   TokenStreamException

inCollectionDeclaration

public final void inCollectionDeclaration()
            throws RecognitionException,
                   TokenStreamException

inCollectionElementsDeclaration

public final void inCollectionElementsDeclaration()
            throws RecognitionException,
                   TokenStreamException

inList

public final void inList()
            throws RecognitionException,
                   TokenStreamException

insertStatement

public final void insertStatement()
            throws RecognitionException,
                   TokenStreamException

insertablePropertySpec

public final void insertablePropertySpec()
            throws RecognitionException,
                   TokenStreamException

intoClause

public final void intoClause()
            throws RecognitionException,
                   TokenStreamException

isFilter

public boolean isFilter()
Returns true if this is a filter query, false if not.
Returns:
true if this is a filter query, false if not.

likeEscape

public final void likeEscape()
            throws RecognitionException,
                   TokenStreamException

logicalAndExpression

public final void logicalAndExpression()
            throws RecognitionException,
                   TokenStreamException

logicalExpression

public final void logicalExpression()
            throws RecognitionException,
                   TokenStreamException

logicalOrExpression

public final void logicalOrExpression()
            throws RecognitionException,
                   TokenStreamException

multiplyExpression

public final void multiplyExpression()
            throws RecognitionException,
                   TokenStreamException

negateNode

public AST negateNode(AST x)
Returns the negated equivalent of the expression.
Parameters:
x - The expression to negate.

negatedExpression

public final void negatedExpression()
            throws RecognitionException,
                   TokenStreamException

newExpression

public final void newExpression()
            throws RecognitionException,
                   TokenStreamException

newValue

public final void newValue()
            throws RecognitionException,
                   TokenStreamException

optionalFromTokenFromClause

public final void optionalFromTokenFromClause()
            throws RecognitionException,
                   TokenStreamException

orderByClause

public final void orderByClause()
            throws RecognitionException,
                   TokenStreamException

orderElement

public final void orderElement()
            throws RecognitionException,
                   TokenStreamException

path

public final void path()
            throws RecognitionException,
                   TokenStreamException

primaryExpression

public final void primaryExpression()
            throws RecognitionException,
                   TokenStreamException

processEqualityExpression

public AST processEqualityExpression(AST x)
            throws RecognitionException
Returns the 'cleaned up' version of a comparison operator sub-tree.
Parameters:
x - The comparison operator to clean up.

processMemberOf

public void processMemberOf(Token n,
                            AST p,
                            ASTPair currentAST)

propertyFetch

public final void propertyFetch()
            throws RecognitionException,
                   TokenStreamException

quantifiedExpression

public final void quantifiedExpression()
            throws RecognitionException,
                   TokenStreamException

queryRule

public final void queryRule()
            throws RecognitionException,
                   TokenStreamException

relationalExpression

public final void relationalExpression()
            throws RecognitionException,
                   TokenStreamException

selectClause

public final void selectClause()
            throws RecognitionException,
                   TokenStreamException

selectFrom

public final void selectFrom()
            throws RecognitionException,
                   TokenStreamException

selectObject

public final void selectObject()
            throws RecognitionException,
                   TokenStreamException

selectStatement

public final void selectStatement()
            throws RecognitionException,
                   TokenStreamException

selectedPropertiesList

public final void selectedPropertiesList()
            throws RecognitionException,
                   TokenStreamException

setClause

public final void setClause()
            throws RecognitionException,
                   TokenStreamException

setFilter

public void setFilter(boolean f)
Sets the filter flag.
Parameters:
f - True for a filter query, false for a normal query.

stateField

public final void stateField()
            throws RecognitionException,
                   TokenStreamException

statement

public final void statement()
            throws RecognitionException,
                   TokenStreamException

subQuery

public final void subQuery()
            throws RecognitionException,
                   TokenStreamException

unaryExpression

public final void unaryExpression()
            throws RecognitionException,
                   TokenStreamException

union

public final void union()
            throws RecognitionException,
                   TokenStreamException

updateStatement

public final void updateStatement()
            throws RecognitionException,
                   TokenStreamException

vectorExpr

public final void vectorExpr()
            throws RecognitionException,
                   TokenStreamException

weakKeywords

public void weakKeywords()
            throws TokenStreamException

whenClause

public final void whenClause()
            throws RecognitionException,
                   TokenStreamException

whereClause

public final void whereClause()
            throws RecognitionException,
                   TokenStreamException

withClause

public final void withClause()
            throws RecognitionException,
                   TokenStreamException