[antlr-interest] Nondeterministically blind

Edward Povazan epovazan at telus.net
Sat Dec 8 16:18:49 PST 2001


Hello,

I just can't see why this shouldn't work. I am trying to parse Python
strings:
http://www.python.org/doc/current/ref/strings.html

My rule:
STRING_LIT:
    SHORT_STRING | LONG_STRING ;
is the one that gives the warning.

How do you guys normally go about hunting down the non deterministic part of
your grammars. I've been scribbling state diagrams, and just can't see my
error. Then again, I am a relative ANTLR newbie, and it's been a long time
since I wanted to parse something.

Can anyone point out my error?

Thanks
-Ed


The lexer looks like this so far:

----

header {
package pytojava
}

class PyLex extends Lexer ;
options {
    charVocabulary = '\0'..'\377';
    testLiterals = false;
    k = 4;
}

protected
ESCAPE_SEQ:
    '\\'.;

protected
SHORT_STRING_CHAR:
    ~('\\'|'\n'|'\r') ;

protected
LONG_STRING_CHAR:
    ~('\\') ;

protected
SHORT_STRING_ITEM:
    SHORT_STRING_CHAR | ESCAPE_SEQ ;

protected
LONG_STRING_ITEM:
    LONG_STRING_CHAR | ESCAPE_SEQ ;

protected
SHORT_STRING:
    '\'' (SHORT_STRING_ITEM)* '\''
    | '"' (SHORT_STRING_ITEM)* '"' ;

protected
LONG_STRING:
    "'''" (LONG_STRING_ITEM)* "'''"
    | "\"\"\"" (LONG_STRING_ITEM)* "\"\"\"" ;

STRING_LIT:
    SHORT_STRING | LONG_STRING ;

----


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list