Last change
on this file since 1 was
1,
checked in by lnalod, 15 years ago
|
Initial import of YAO sources
|
File size:
912 bytes
|
Line | |
---|
1 | // This file is part of PyANTLR. See LICENSE.txt for license |
---|
2 | // details..........Copyright (C) Wolfgang Haefelinger, 2004. |
---|
3 | // |
---|
4 | // $Id$ |
---|
5 | |
---|
6 | header "Lexer.__main__" { |
---|
7 | // main - create and run lexer from stdin |
---|
8 | if __name__ == "__main__": |
---|
9 | import sys |
---|
10 | import antlr |
---|
11 | import rulefilter_l |
---|
12 | |
---|
13 | // create lexer - shall read from stdin |
---|
14 | L = rulefilter_l.Lexer() |
---|
15 | |
---|
16 | try: |
---|
17 | token = L.nextToken() |
---|
18 | while not token.isEOF(): |
---|
19 | print token |
---|
20 | token = L.nextToken() |
---|
21 | |
---|
22 | except antlr.TokenStreamException, e: |
---|
23 | print "error: exception caught while lexing:", e |
---|
24 | |
---|
25 | // end of main |
---|
26 | } |
---|
27 | |
---|
28 | options { |
---|
29 | language=Python; |
---|
30 | } |
---|
31 | |
---|
32 | class rulefilter_l extends Lexer; |
---|
33 | |
---|
34 | options { |
---|
35 | k=2; |
---|
36 | filter=IGNORE; |
---|
37 | charVocabulary = '\3'..'\177'; |
---|
38 | } |
---|
39 | |
---|
40 | P : "<p>" ; |
---|
41 | BR: "<br>" ; |
---|
42 | |
---|
43 | protected |
---|
44 | IGNORE |
---|
45 | : '<' (~'>')* '>' { print "invalid tag: "+ $getText} |
---|
46 | | ( "\r\n" | '\r' | '\n' ) { $newline } |
---|
47 | | . |
---|
48 | ; |
---|
Note: See
TracBrowser
for help on using the repository browser.