Changeset 3416 for proto/RE


Ignore:
Timestamp:
Jul 31, 2013, 11:08:35 PM (6 years ago)
Author:
ksherdy
Message:

Updated demo.

Location:
proto/RE/demo
Files:
4 added
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • proto/RE/demo/grep.py

    r3415 r3416  
    11#
    2 # grep - A very simple 'streams' language example to match lines containing the fixed string 'apple'.
     2# grep - A very simple example to match lines containing the fixed string 'apple'.
    33#
    44# grep Program flow.
    55#
    6 # StreamInput (STDIN) -> Transpose -> ClassifyBytes -> Match -> MatchLines -> (FilterMatchLines) -> StreamOutput (STDOUT)
     6# StreamInput -> PrependLF -> Transpose -> ClassifyBytes -> Match -> MatchLines -> (FilterMatchLines) -> StreamOutput
    77#                                                                     
    88# Notes/Observations:
     
    1919#       Potential solutions:
    2020#
    21 #       a) insert a start of span marker in the source byte stream
    22 #       b) push to the problem onto the developer
    23 #       c) add code to handle this case
     21#       a) manipulate source input stream, ie. prepend LF
     22#       b) compiler code handles
     23#       c) developer code handles (shift both
    2424#
    2525#
     
    5656        lines = 0
    5757
    58 def ClassifyBytes(basis, lex): 
    59         temp1 = (basis.bit_1 &~ basis.bit_0)
    60         temp2 = (basis.bit_2 &~ basis.bit_3)
     58def ClassifyBytes(basis_bits, lex): 
     59        temp1 = (basis_bits.bit_1 &~ basis_bits.bit_0)
     60        temp2 = (basis_bits.bit_2 &~ basis_bits.bit_3)
    6161        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)
    6464        temp6 = (temp5 &~ temp4)
    6565        lex.a = (temp3 & temp6)
    66         temp7 = (basis.bit_2 & basis.bit_3)
     66        temp7 = (basis_bits.bit_2 & basis_bits.bit_3)
    6767        temp8 = (temp1 & temp7)
    68         temp9 = (basis.bit_6 | basis.bit_7)
     68        temp9 = (basis_bits.bit_6 | basis_bits.bit_7)
    6969        temp10 = (temp4 | temp9)
    7070        lex.p = (temp8 &~ temp10)
    71         temp11 = (basis.bit_4 & basis.bit_5)
     71        temp11 = (basis_bits.bit_4 & basis_bits.bit_5)
    7272        temp12 = (temp11 &~ temp9)
    7373        lex.l = (temp3 & temp12)
    74         temp13 = (basis.bit_5 &~ basis.bit_4)
     74        temp13 = (basis_bits.bit_5 &~ basis_bits.bit_4)
    7575        temp14 = (temp13 & temp5)
    7676        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)
    8284       
    8385def Match(lex, matches):
     
    129131
    130132                lgth = len(u8data)
    131                 print "stream input data:       " + u8data
     133                print "\nstream input data:     \n\n" + u8data
     134                print ""
    132135                print "lex.a                    " + pablo.bitstream2string(lex.a, lgth)
    133136                print "lex.p                    " + pablo.bitstream2string(lex.p, lgth)
     
    137140                print "matches.all_matches      " + pablo.bitstream2string(matches.all_matches, lgth)
    138141                print "lines.all_lines          " + pablo.bitstream2string(lines.all_lines, lgth)
    139                 print "stream output data       " + output.lines
     142                print "\nstream output data:    \n\n" + output.lines
    140143               
    141144        else:
Note: See TracChangeset for help on using the changeset viewer.