7
version = sys.version.split()[0]
13
class CharScanner(antlr.CharScanner):
14
def __init__(self,*args):
15
super(CharScanner,self).__init__(*args)
16
self.altcomment = True
17
self.state_with_syntax = False
19
### check whether a string contains a lower case char
20
def haslowerchar(self,s):
21
return (s.upper() != s)
23
def handle_comment(self):
26
self.throw_no_viable_alt_for_char(la1)
34
if self.LA(2) == '\n':
37
elif la1 in u'\u000b' :
40
elif la1 in u'\u000c':
44
self.throw_no_viable_alt_for_char(la1)
47
def throw_no_viable_alt_for_char(self,la1):
48
raise antlr.NoViableAltForCharException(
55
def chr_ws_erase(self,string,*chars):
59
if __name__ == '__main__' :
60
### create my lexer ..
61
### print "reading from test.in .."
62
Lexer = lexer.Lexer("test.in")
65
token = Lexer.nextToken()
66
while not token.isEOF():
67
### Is there a way to simplify this loop??
68
### this looks complicated to me. However, we can't simply
69
### return none to check for EOF as we would like to know
70
### where EOF appeared (file, line, col etc). This would
71
### be lost. Or we could return NIL in case of EOF and, if
72
### we are really want to know more about EOF ask lexer to
73
### provide this information. But this would extend the
74
### lexer's interface. Another idea would be to return EOF
75
### by exception, but EOF is actually not an exception at
79
token = Lexer.nextToken()