 Timestamp:
 Jul 31, 2013, 11:08:35 PM (6 years ago)
 Location:
 proto/RE/demo
 Files:

 4 added
 1 deleted
 1 edited
Legend:
 Unmodified
 Added
 Removed

proto/RE/demo/grep.py
r3415 r3416 1 1 # 2 # grep  A very simple 'streams' languageexample to match lines containing the fixed string 'apple'.2 # grep  A very simple example to match lines containing the fixed string 'apple'. 3 3 # 4 4 # grep Program flow. 5 5 # 6 # StreamInput (STDIN) > Transpose > ClassifyBytes > Match > MatchLines > (FilterMatchLines) > StreamOutput (STDOUT)6 # StreamInput > PrependLF > Transpose > ClassifyBytes > Match > MatchLines > (FilterMatchLines) > StreamOutput 7 7 # 8 8 # Notes/Observations: … … 19 19 # Potential solutions: 20 20 # 21 # a) insert a start of span marker in the source byte stream22 # b) push to the problem onto the developer23 # c) add code to handle this case21 # a) manipulate source input stream, ie. prepend LF 22 # b) compiler code handles 23 # c) developer code handles (shift both 24 24 # 25 25 # … … 56 56 lines = 0 57 57 58 def ClassifyBytes(basis , lex):59 temp1 = (basis .bit_1 &~ basis.bit_0)60 temp2 = (basis .bit_2 &~ basis.bit_3)58 def ClassifyBytes(basis_bits, lex): 59 temp1 = (basis_bits.bit_1 &~ basis_bits.bit_0) 60 temp2 = (basis_bits.bit_2 &~ basis_bits.bit_3) 61 61 temp3 = (temp1 & temp2) 62 temp4 = (basis .bit_4  basis.bit_5)63 temp5 = (basis .bit_7 &~ basis.bit_6)62 temp4 = (basis_bits.bit_4  basis_bits.bit_5) 63 temp5 = (basis_bits.bit_7 &~ basis_bits.bit_6) 64 64 temp6 = (temp5 &~ temp4) 65 65 lex.a = (temp3 & temp6) 66 temp7 = (basis .bit_2 & basis.bit_3)66 temp7 = (basis_bits.bit_2 & basis_bits.bit_3) 67 67 temp8 = (temp1 & temp7) 68 temp9 = (basis .bit_6  basis.bit_7)68 temp9 = (basis_bits.bit_6  basis_bits.bit_7) 69 69 temp10 = (temp4  temp9) 70 70 lex.p = (temp8 &~ temp10) 71 temp11 = (basis .bit_4 & basis.bit_5)71 temp11 = (basis_bits.bit_4 & basis_bits.bit_5) 72 72 temp12 = (temp11 &~ temp9) 73 73 lex.l = (temp3 & temp12) 74 temp13 = (basis .bit_5 &~ basis.bit_4)74 temp13 = (basis_bits.bit_5 &~ basis_bits.bit_4) 75 75 temp14 = (temp13 & temp5) 76 76 lex.e = (temp3 & temp14) 77 temp15 = (basis.bit_0  basis.bit_1) 78 temp16 = (temp2 &~ temp15) 79 temp17 = (basis.bit_6 & basis.bit_7) 80 temp18 = (temp17 &~ temp4) 81 lex.LF = (temp16 & temp18) 77 temp15 = (basis_bits.bit_0  basis_bits.bit_1) 78 temp16 = (basis_bits.bit_2  basis_bits.bit_3) 79 temp17 = (temp15  temp16) 80 temp18 = (basis_bits.bit_4 &~ basis_bits.bit_5) 81 temp19 = (basis_bits.bit_6 &~ basis_bits.bit_7) 82 temp20 = (temp18 & temp19) 83 lex.LF = (temp20 &~ temp17) 82 84 83 85 def Match(lex, matches): … … 129 131 130 132 lgth = len(u8data) 131 print "stream input data: " + u8data 133 print "\nstream input data: \n\n" + u8data 134 print "" 132 135 print "lex.a " + pablo.bitstream2string(lex.a, lgth) 133 136 print "lex.p " + pablo.bitstream2string(lex.p, lgth) … … 137 140 print "matches.all_matches " + pablo.bitstream2string(matches.all_matches, lgth) 138 141 print "lines.all_lines " + pablo.bitstream2string(lines.all_lines, lgth) 139 print " stream output data" + output.lines142 print "\nstream output data: \n\n" + output.lines 140 143 141 144 else:
Note: See TracChangeset
for help on using the changeset viewer.