Buggy code:
protected Parser betweenExpression ( ) { } private Sequence inExp ; protected Parser inExpression ( ) { } private Sequence likeExp ; protected Parser likeExpression ( ) { } private Sequence nullComparisonExp ; protected Parser nullComparisonExpression ( ) { } private Alternation emptyColCompExp ; protected Parser emptyCollectionComparisonExpression ( ) { } private Sequence colMemExp ; protected Parser collectionMemberExpression ( ) { } private Alternation compExp ; protected Parser comparisonExpression ( ) { } private Alternation arithValue ; protected Parser arithmeticValue ( ) { } protected Parser singleValueDesignator ( ) { } private Alternation compOpp ; protected Parser comparisonOperator ( ) { } protected Parser scalarExpression ( ) { } private Sequence arithExp ; protected Parser arithmeticExpression ( ) { } private Sequence arithTerm ; protected Parser arithmeticTerm ( ) { } private Sequence arithFactor ; protected Parser arithmeticFactor ( ) { } private Alternation arithPrim ; protected Parser arithmeticPrimary ( ) { } private Alternation strValue ; protected Parser stringValue ( ) { } private Alternation strExp ; protected Parser stringExpression ( ) { } private Alternation strPrim ; protected Parser stringPrimary ( ) { } protected Parser datetimeValue ( ) { } private Alternation dateExp ; protected Parser datetimeExpression ( ) { } protected Parser booleanValue ( ) { } private Alternation boolExp ; protected Parser booleanExpression ( ) { } private Alternation entBeanVal ; protected Parser entityBeanValue ( ) { } private Alternation entBeanExp ; protected Parser entityBeanExpression ( ) { } protected Parser valueObjectValue ( ) { } private Alternation valueObjectExp ; protected Parser valueObjectExpression ( ) { } private Alternation funRetStr ; protected Parser functionsReturningStrings ( ) { } private Alternation funRetNum ; protected Parser functionsReturningNumerics ( ) { if ( ( funRetNum ) == null ) { funRetNum = new Alternation ( ) ; Sequence length = new Sequence ( ) ; length . add ( new Literal ( "LENGTH" ) . discard ( ) ) ; length . add ( new Symbol ( "(" ) . discard ( ) ) ; length . add ( stringExpression ( ) ) ; length . add ( new Symbol ( ")" ) . discard ( ) ) ; length . setAssembler ( new Assembler ( ) { public void workOn ( Assembly a ) { SQLTarget target = ( ( SQLTarget ) ( a . getTarget ( ) ) ) ; String param = a . pop ( ) . toString ( ) ; a . push ( target . getLengthFunction ( param ) ) ; } } ) ; funRetNum . add ( length ) ; Sequence locate = new Sequence ( ) ; locate . add ( new Literal ( "LOCATE" ) ) ; locate . add ( new Symbol ( "(" ) . discard ( ) ) ; locate . add ( stringExpression ( ) ) ; locate . add ( new Symbol ( "," ) . discard ( ) ) ; locate . add ( stringExpression ( ) ) ; Sequence start = new Sequence ( ) ; start . add ( new Symbol ( "," ) . discard ( ) ) ; start . add ( arithmeticExpression ( ) ) ; locate . add ( new org . jboss . ejb . plugins . cmp . ejbql . Optional ( start ) ) ; locate . add ( new Symbol ( ")" ) . discard ( ) ) ; locate . setAssembler ( new Assembler ( ) { public void workOn ( Assembly a ) { SQLTarget target = ( ( SQLTarget ) ( a . getTarget ( ) ) ) ; String param3 = a . pop ( ) . toString ( ) ; String param2 = a . pop ( ) . toString ( ) ; String param1 = a . pop ( ) . toString ( ) ; if ( param1 . equalsIgnoreCase ( "LOCATE" ) ) { param1 = param2 ; param2 = param3 ; <START_BUG> param3 = "0" ; <END_BUG> } else { a . pop ( ) ; } a . push ( target . getLocateFunction ( param1 , param2 , param3 ) ) ; } } ) ; funRetNum . add ( locate ) ; Sequence abs = new Sequence ( ) ; abs . add ( new Literal ( "ABS" ) . discard ( ) ) ; abs . add ( new Symbol ( "(" ) . discard ( ) ) ; abs . add ( arithmeticExpression ( ) ) ; abs . add ( new Symbol ( ")" ) . discard ( ) ) ; abs . setAssembler ( new Assembler ( ) { public void workOn ( Assembly a ) { String param = a . pop ( ) . toString ( ) ; SQLTarget target = ( ( SQLTarget ) ( a . getTarget ( ) ) ) ; a . push ( target . getAbsFunction ( param ) ) ; } } ) ; funRetNum . add ( abs ) ; Sequence sqrt = new Sequence ( ) ; sqrt . add ( new Literal ( "SQRT" ) . discard ( ) ) ; sqrt . add ( new Symbol ( "(" ) . discard ( ) ) ; sqrt . add ( arithmeticExpression ( ) ) ; sqrt . add ( new Symbol ( ")" ) . discard ( ) ) ; sqrt . setAssembler ( new Assembler ( ) { public void workOn ( Assembly a ) { SQLTarget target = ( ( SQLTarget ) ( a . getTarget ( ) ) ) ; String param = a . pop ( ) . toString ( ) ; a . push ( target . getSqrtFunction ( param ) ) ; } } ) ; funRetNum . add ( sqrt ) ; } return funRetNum ; } protected Parser abstractSchemaName ( ) { } protected Parser identifier ( ) { } protected Parser cmpField ( ) { } protected Parser singleValuedCmrField ( ) { }

Fix:
param3 = "1" ;