[antlr-interest] Failed predicate problem [v3]
Terence Parr
parrt at cs.usfca.edu
Mon Nov 6 09:13:19 PST 2006
Perhaps try {...}?=> not just {...}?, which says to gate the rule out
when ultPic is false versus just use sem pred when necessary syntax-
wise.
Ter
On Nov 5, 2006, at 4:25 PM, Alexandre Porcelli wrote:
> Hi People,
>
> I'm getting problems with semantic predicate. I constructed the
> folowing :
>
> pictureClause
> : PIC PIC_VALUE
> ;
>
> PIC_VALUE
> :{ultPic}? ('+'|'-'|'$'|'A'|'B'|','|'E'|
> ('0'..'9')|'X'|'S'|'V'|'Z'|'*'|'('|')'|
> { input.LA(2) != ' ' && input.LA(2) != '\n' && input.LA(2) != '\r' }?
> '.')+
> {
> ultPic = false;
> }
> ;
>
> PIC : 'PIC' 'TURE'?
> {
> ultPic = true;
> }
> ;
>
> It works almost time, but when I have a situation that should escape
> (by semantic predicate) I got an failed predicate error:
>
> mTokens, mPIC_VALUE]: line 6:53 rule PIC_VALUE failed predicate: {
> input.LA(2) != ' ' && input.LA(2) != '\n' && input.LA(2) != '\r' }?
>
> I appreciate any help - I´m getting this problem and I can´t advance
> in my job :(
>
> ps: Attached the sample grammar and a text that generates the problem.
>
>
> Thanks in Advance,
> Alexandre Porcelli
> <sample.txt>
> <Cobol.g>
More information about the antlr-interest
mailing list