source: trunk/yao/share/antlr-2.7.7/examples/python/filterWithRule/rulefilter.g @ 1

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
6header "Lexer.__main__" {
7// main - create and run lexer from stdin
8if __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
28options {
29    language=Python;
30}
31
32class rulefilter_l extends Lexer;
33
34options {
35        k=2;
36        filter=IGNORE;
37        charVocabulary = '\3'..'\177';
38}
39
40P : "<p>" ;
41BR: "<br>" ;
42
43protected
44IGNORE
45        :       '<' (~'>')* '>' { print "invalid tag: "+ $getText}
46        |       ( "\r\n" | '\r' | '\n' ) { $newline }
47        |       .
48        ;
Note: See TracBrowser for help on using the repository browser.