[antlr-interest] help
Sinan
sinan.karasu at boeing.com
Wed Jun 12 08:27:09 PDT 2002
Balvinder Singh wrote:
>
> Hi...
>
> I have a rule, which has 3 conflicts. plz help me to resolve it.
>
> If I change it to context free grammar and use some syntactic predicate,
> will be a right way or not.
>
> parser rule
> picture_string : (currency)? ((picChar)+ (repeat)?)+ (Punctuation
> ((picChar)+ (repeat)?)+)*
>
> currency and picChar is alphabet
>
> repeat : "(" Integer ")"
> ;
>
> lexer rule
> Punctuation : ('/' | ',' | '.' | ':')
> ;
>
> so I have conflict in picture_string.
>
> balvinder
If currency and picChar are alphabet with no distinguishing properties,
then obviously
no way to disambiguate exists.
However , othwerwise, you can always use
picture_string : ((currency)=>currency| ) ...
I wrote ( and posted ) a Fortran 77 parser at one time. Due to the free
form
nature of the language, I had to only parse characters as tokens, and
made
everything else a parser rule. The problem with that approach is of
course, you don't
know what you've got until you parse the statement , and then re-parse
it ....
Wreaks havoc with error statements.
so basically you do
statement: (dostatement)=> dostatement
| (writestatement)=> writestatement
...
| assignstatement
;
Now when you run into a bad statement ( say a bad write statement)
e.g. " write(6,7("
it will always say that you have a bad assignstatement.
sinan
sinan
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list