Hi,

In my grammar, I can parse expression like this:
(A <= 1 or A >= 6) and (A not in (43,44))

Let's say, it is a kind of sql WHERE clause.

Here is a part of the grammar to understand the problem:

@rulecatch {
catch (RecognitionException re) {
        if (this.errorMessage.isEmpty())
                this.errorMessage = this.getErrorMessage(re,
this.getTokenNames()) +  " [pos: " + (re.charPositionInLine -
errorPosOffset) + "]";
        throw re;
}
}

...

arithexpr:              (arithterm ) (
                                '+' arithterm  | 
                                '-' arithterm  | 
                                CONCAT arithterm)*;

arithterm:              (arithatom | '-' arithatom) 
                                ('*' arithatom 
                                | '/' arithatom)*;

arithatom:              arithvar
                        | ifthenelse
                        | constantorparameter
                        | floorexpr
                        | floatexpr
                        | leftexpr
                        | rightexpr
                        | replaceexpr
                        | dayexpr
                        | monthexpr
                        | yearexpr
                        | yearnoexpr
                        | (arithexprparen)=> arithexprparen 
                        ;

arithexprparen:         '(' arithexpr ')';


You can notice that I'm using syntactic predicate to support nested
expression with parenthesis.

The problem is the following:
If I have a mistake in my expression like this:  (A <= 1 or A >= 6xx)
and (A not in (43,44))
Where 6xx is the mistake,
The error I have is: 'no viable alternative at input 'A' [pos:1]
This is because it doesn't reach the right parentheses while parsing
"(arithexprparen)=> arithexprparen", so the error is triggered for the
beginning of arithatom evaluation.
I would have liked it to tell me that the problem is 'x' and not 'A'.
Is there any way to deal with that ?


Thanks a lot for any help.
Philippe


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to