source: proto/pabloj/trunk/input/test/s2k/all/all.s2k @ 3697

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

Renamed tests.

File size: 3.9 KB
Line 
1struct bb {
2        stream<1> a;
3
4};
5
6/*
7function stream<1> Function(stream<1> a, stream<1> b, stream<1> c) {
8
9
10};
11*/
12struct B
13{
14        stream<1> a;
15        stream<1> a;
16        stream<1> a;
17        stream<1> a;
18};
19
20function struct B Foo() { }
21function struct Lex ClassifyBytes(struct BasisBit basis) {};
22
23
24struct Basis{
25    stream bit_0;
26    stream bit_1;
27    stream bit_2;
28    stream bit_3;
29    stream bit_4;
30    stream bit_5;
31    stream bit_6;
32    stream bit_7;
33};
34
35struct Lex{
36    stream a;
37    stream p;
38    stream l;
39    stream e;
40    stream LF;
41};
42
43struct Matches{
44    stream all_matched;
45};
46
47struct Lines{
48    stream all_matched;
49};
50
51struct Output{
52    stream lines;
53};
54
55function void ClassifyBytes(struct Basis_bits basis_bits, struct Lex lex) {
56    stream temp1 = (basis_bits.bit_1 & (~ basis_bits.bit_0));
57    stream temp2 = (basis_bits.bit_2 & (~ basis_bits.bit_3));
58    stream temp3 = (temp1 & temp2);
59    stream temp4 = (basis_bits.bit_4 | basis_bits.bit_5);
60    stream temp5 = (basis_bits.bit_7 & (~ basis_bits.bit_6));
61    stream temp6 = (temp5 & (~ temp4));
62    lex.a = (temp3 & temp6);
63    stream temp7 = (basis_bits.bit_2 & basis_bits.bit_3);
64    stream temp8 = (temp1 & temp7);
65    stream temp9 = (basis_bits.bit_6 | basis_bits.bit_7);
66    stream temp10 = (temp4 | temp9);
67    lex.p = (temp8 & (~ temp10));
68    stream temp11 = (basis_bits.bit_4 & basis_bits.bit_5);
69    stream temp12 = (temp11 & (~ temp9));
70    lex.l = (temp3 & temp12);
71    stream temp13 = (basis_bits.bit_5 & (~ basis_bits.bit_4));
72    stream temp14 = (temp13 & temp5);
73    lex.e = (temp3 & temp14);
74    stream temp15 = (basis_bits.bit_0 | basis_bits.bit_1);
75    stream temp16 = (basis_bits.bit_2 | basis_bits.bit_3);
76    stream temp17 = (temp15 | temp16);
77    stream temp18 = (basis_bits.bit_4 & (~ basis_bits.bit_5));
78    stream temp19 = (basis_bits.bit_6 & (~ basis_bits.bit_7));
79    stream temp20 = (temp18 & temp19);
80    lex.LF = (temp20 & (~ temp17));
81}
82
83function void Match(struct Lex lex, struct Matches matches) {
84    stream m0 = lex.a;
85    stream m1 = (pablo.Advance(m0) & lex.p);
86    stream m2 = (pablo.Advance(m1) & lex.p);
87    stream m3 = (pablo.Advance(m2) & lex.l);
88    stream m4 = (pablo.Advance(m3) & lex.e);
89    matches.all_matched = m4;
90}
91
92function void MatchLines1(struct Lex lex, struct Matches matches, struct Lines lines) {
93    stream last_start = pablo.First();
94    stream LF_or_match = (lex.LF | matches.all_matched);
95    stream cursor = pablo.ScanToFirst(LF_or_match);
96    while (pablo.inFile(cursor)) {
97        if ((cursor & matches.all_matched)) {
98            stream next_end = pablo.AdvanceThenScanTo(cursor, lex.LF);
99            lines.all_matched |= (pablo.InclusiveSpan(last_start, next_end) | next_end);
100            cursor = next_end;
101        }
102        if ((cursor & lex.LF)) {
103            last_start = pablo.Advance(cursor);
104        }
105        cursor = pablo.AdvanceThenScanTo(cursor, LF_or_match);
106    }
107}
108
109function void MatchLines2(struct Lex lex, struct Matches matches, struct Lines lines) {
110    stream last_start = pablo.Mask(1,0);
111    last_start = (pablo.Advance((~ last_start)) ^ (~ last_start));
112    stream LF_or_match = (lex.LF | matches.all_matched);
113    stream cursor = pablo.ScanToFirst(LF_or_match);
114    while (pablo.inFile(cursor)) {
115        if ((cursor & matches.all_matched)) {
116            stream next_end = pablo.AdvanceThenScanTo(cursor, lex.LF);
117            lines.all_matched |= (pablo.InclusiveSpan(last_start, next_end) | next_end);
118            cursor = next_end;
119        }
120        if ((cursor & lex.LF)) {
121            last_start = pablo.Advance(cursor);
122        }
123        cursor = pablo.AdvanceThenScanTo(cursor, LF_or_match);
124    }
125}
126
127function void FilterMatchLines(struct Data data, struct Output output) {
128    output.lines = pablo.filter_bytes(data, (~ lines.all_matched));
129}
130
131function void CountLines(struct Lex lex, struct Lines lines) {
132    return pablo.PopCount((pablo.MatchStar(lines, (~ lex.LF)) & lex.LF)) ;
133}
134/*
135        Block comment.
136*/
137
138// EOL terminated comment.
139
140// Another EOL terminated comment.
141
Note: See TracBrowser for help on using the repository browser.