source: proto/RE2PBS/prototype_template.py @ 1149

Last change on this file since 1149 was 1149, checked in by ksherdy, 8 years ago

Add prototype

File size: 1.2 KB
Line 
1# -*- coding: utf-8 -*-
2#
3# prototype.py template
4#
5# Ken Herdy
6# April 20, 2010
7#
8#----------------------------------------------------------------------------
9#
10# (at)lex_strms - Lexical Item Streams.
11# (at)cc_code   - Character Class compiler equations.
12# (at)pbs_code  - Parallel bit stream equations.
13#
14#----------------------------------------------------------------------------
15
16u8data = ""
17lgth = 0
18
19class Basis_bits():
20        bit_0 = 0
21        bit_1 = 0
22        bit_2 = 0
23        bit_3 = 0 
24        bit_4 = 0
25        bit_5 = 0
26        bit_6 = 0
27        bit_7 = 0 
28 
29class Lex():
30@lex_strms
31
32def classify_bytes(bit):
33        lex = Lex()
34
35@cc_code
36        return lex
37
38def demo(u8data):
39        global lgth
40        lgth = len(u8data)
41       
42@pbs_code
43@pbs_debug
44
45        return
46
47if __name__ == "__main__":
48        import doctest
49        doctest.testmod()
50
51        if len(sys.argv) < 2:
52                sys.stderr.write("Usage: python " + __file__ + " <filename>" "\n")
53                sys.exit(2)
54
55        u8data = bitutil.readfile(sys.argv[1])
56        (bits, EOF_mask) = bitutil.transpose_streams(u8data)
57       
58        basis_bits.bit_0 = bits[0]
59        basis_bits.bit_1 = bits[1]
60        basis_bits.bit_2 = bits[2]
61        basis_bits.bit_3 = bits[3]
62        basis_bits.bit_4 = bits[4]
63        basis_bits.bit_5 = bits[5]
64        basis_bits.bit_6 = bits[6]
65        basis_bits.bit_7 = bits[7]
66       
67        lex = classify_bytes(basis_bits)
68        demo(u8data, lex)
Note: See TracBrowser for help on using the repository browser.