13 Apr 2011 19:38
your lexer rules are ambiguous [was Re: PEG Digest, Vol 40, Issue 4]
Terence Parr <parrt <at> cs.usfca.edu>
2011-04-13 17:38:55 GMT
2011-04-13 17:38:55 GMT
On Apr 12, 2011, at 11:19 AM, Yury Euceda wrote:
> Another thing: For Terence
>
> I was trying to do the next with ANTLR and it takes me to a mistake
That's because, as you've defined them, integer and real are ambiguous. per the usual convention, it
chooses to match an integer for 5 not real.
> grammar polinomy;
> INTEGER : ('+'|'-')? '0'..'9'+;
> REAL : ('+'|'-')? '0'..'9'+ ('.' '0'..'9'*)?;
> VARIABLE: ('A'..'Z'|'a'..'z')+;
> monomy : REAL ('*' VARIABLE ('^' INTEGER)?)?;
>
> if you try to recognize the string 5 it brings me an error.
The parser will fail when it attempts rule monomy because it is looking for a real number not an integer.
> But my algorithm solves it well. I'm sending you a pic showing it
If the algorithm you are using is scannerless, then I would expect a PEG to work correctly. With a lexer, that
resolved ambiguities normally, I would expect a peg or any other person strategy to fail due to mismatched token.
You are making some fairly grand claims on this list. I think we would all appreciate some details of your
algorithm so we can evaluate your claims.
Ter
PS also please do not use subject lines like "PEG Digest, Vol 40, Issue 4"
RSS Feed