source: proto/RE/output/re_pablo.py @ 3744

Last change on this file since 3744 was 3744, checked in by ksherdy, 5 years ago

Consolidated s2k demos.

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# (at)pbs_debug - Parallel bit stream debug statements.
14#
15#----------------------------------------------------------------------------
16
17#import sys
18#import bitutil
19
20
21class Basis_bits():
22        bit_0 = 0
23        bit_1 = 0
24        bit_2 = 0
25        bit_3 = 0 
26        bit_4 = 0
27        bit_5 = 0
28        bit_6 = 0
29        bit_7 = 0 
30 
31class Lex():
32
33        cc0 = (0)
34        cc1 = (0)
35        cc2 = (0)
36        cc3 = (0)
37        LF = (0) 
38
39class Output():
40        matches = (0)
41
42def Classify_bytes(basis_bits,lex):
43@cc_code
44
45def Demo(lex, output):
46        m0=0
47        m0=~0
48        m0 = pablo.Advance((m0 & lex.cc0))
49        m0 = pablo.Advance((m0 & lex.cc1))
50        m0 = pablo.Advance((m0 & lex.cc1))
51        m0 = pablo.Advance((m0 & lex.cc2))
52        m0 = pablo.Advance((m0 & lex.cc3))
53        output.matches = 0
54        all_matches = m0
55        if all_matches:
56                # Find the last match on each line and filter out all others
57                output.matches = pablo.MatchStar(all_matches, ~lex.LF) & lex.LF
58       
59def Main(u8data, lex, output):
60        Classify_bytes(basis_bits,lex)
61        Demo(lex,output)
62
Note: See TracBrowser for help on using the repository browser.