Ignore:
Timestamp:
Apr 18, 2014, 2:35:35 AM (4 years ago)
Author:
ksherdy
Message:

Added launchers, test cases.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/s2k/trunk/framework/input/test/s2k/test.s2k

    r3767 r3834  
     1filter Test() {
    12
    2 
    3 struct Basis{
    4     stream bit_0;
    5     stream bit_1;
    6     stream bit_2;
    7     stream bit_3;
    8     stream bit_4;
    9     stream bit_5;
    10     stream bit_6;
    11     stream bit_7;
    12 };
    13 
    14 struct Lex{
    15     stream a;
    16     stream p;
    17     stream l;
    18     stream e;
    19     stream LF;
    20 };
    21 
    22 struct Matches{
    23     stream all_matched;
    24 };
    25 
    26 struct Lines{
    27     stream all_matched;
    28 };
    29 
    30 struct Output{
    31     stream lines;
    32 };
    33 
    34 filter ClassifyBytes(struct Basis_bits basis_bits, struct Lex lex) {
    35     stream temp1 = (basis_bits.bit_1 & (~ basis_bits.bit_0));
    36     stream temp2 = (basis_bits.bit_2 & (~ basis_bits.bit_3));
    37     stream temp3 = (temp1 & temp2);
    38     stream temp4 = (basis_bits.bit_4 | basis_bits.bit_5);
    39     stream temp5 = (basis_bits.bit_7 & (~ basis_bits.bit_6));
    40     stream temp6 = (temp5 & (~ temp4));
    41     lex.a = (temp3 & temp6);
    42     stream temp7 = (basis_bits.bit_2 & basis_bits.bit_3);
    43     stream temp8 = (temp1 & temp7);
    44     stream temp9 = (basis_bits.bit_6 | basis_bits.bit_7);
    45     stream temp10 = (temp4 | temp9);
    46     lex.p = (temp8 & (~ temp10));
    47     stream temp11 = (basis_bits.bit_4 & basis_bits.bit_5);
    48     stream temp12 = (temp11 & (~ temp9));
    49     lex.l = (temp3 & temp12);
    50     stream temp13 = (basis_bits.bit_5 & (~ basis_bits.bit_4));
    51     stream temp14 = (temp13 & temp5);
    52     lex.e = (temp3 & temp14);
    53     stream temp15 = (basis_bits.bit_0 | basis_bits.bit_1);
    54     stream temp16 = (basis_bits.bit_2 | basis_bits.bit_3);
    55     stream temp17 = (temp15 | temp16);
    56     stream temp18 = (basis_bits.bit_4 & (~ basis_bits.bit_5));
    57     stream temp19 = (basis_bits.bit_6 & (~ basis_bits.bit_7));
    58     stream temp20 = (temp18 & temp19);
    59     lex.LF = (temp20 & (~ temp17));
    60 }
    61 
    62 filter Match(struct Lex lex, struct Matches matches) {
    63     stream m0 = lex.a;
    64     stream m1 = (pablo.Advance(m0) & lex.p);
    65     stream m2 = (pablo.Advance(m1) & lex.p);
    66     stream m3 = (pablo.Advance(m2) & lex.l);
    67     stream m4 = (pablo.Advance(m3) & lex.e);
    68     matches.all_matched = m4;
    69 }
    70 
    71 filter MatchLines1(struct Lex lex, struct Matches matches, struct Lines lines) {
    72     stream last_start = pablo.First();
    73     stream LF_or_match = (lex.LF | matches.all_matched);
    74     stream cursor = pablo.ScanToFirst(LF_or_match);
    75     while (pablo.inFile(cursor)) {
    76         if ((cursor & matches.all_matched)) {
    77             stream next_end = pablo.AdvanceThenScanTo(cursor, lex.LF);
    78             lines.all_matched |= (pablo.InclusiveSpan(last_start, next_end) | next_end);
    79             cursor = next_end;
    80         }
    81         if ((cursor & lex.LF)) {
    82             last_start = pablo.Advance(cursor);
    83         }
    84         cursor = pablo.AdvanceThenScanTo(cursor, LF_or_match);
     3    for (stream s) in (stream m) {
     4   
    855    }
    866}
    87 
    88 filter MatchLines2(struct Lex lex, struct Matches matches, struct Lines lines) {
    89     stream last_start = pablo.Mask(1,0);
    90     last_start = (pablo.Advance((~ last_start)) ^ (~ last_start));
    91     stream LF_or_match = (lex.LF | matches.all_matched);
    92     stream cursor = pablo.ScanToFirst(LF_or_match);
    93     while (pablo.inFile(cursor)) {
    94         if ((cursor & matches.all_matched)) {
    95             stream next_end = pablo.AdvanceThenScanTo(cursor, lex.LF);
    96             lines.all_matched |= (pablo.InclusiveSpan(last_start, next_end) | next_end);
    97             cursor = next_end;
    98         }
    99         if ((cursor & lex.LF)) {
    100             last_start = pablo.Advance(cursor);
    101         }
    102         cursor = pablo.AdvanceThenScanTo(cursor, LF_or_match);
    103     }
    104 }
    105 
    106 filter nameMatchLines(struct Data data, struct Output output) {
    107     output.lines = pablo.filter_bytes(data, (~ lines.all_matched));
    108 }
    109 
    110 filter CountLines(struct Lex lex, struct Lines lines) {
    111     return pablo.PopCount((pablo.MatchStar(lines, (~ lex.LF)) & lex.LF)) ;
    112 }
Note: See TracChangeset for help on using the changeset viewer.