source: proto/s2k/trunk/framework/input/test/s2k/all/all.s2k @ 3767

Last change on this file since 3767 was 3767, checked in by ksherdy, 4 years ago

Replaced function keyword with filter.

File size: 29.4 KB
Line 
1struct BasisBits {
2        stream<1> b1;
3        stream<1> b2;
4        stream<1> b3;
5        stream<1> b4;
6};
7struct BasisBits {
8        stream<1> b1;
9        stream<1> b2;
10        stream<1> b3;
11        stream<1> b4;
12};
13
14filter Foo() {
15
16}filter AssignmentExpressions() {       
17        temp4 = temp;
18        temp4 &= temp1 | temp2;
19        temp4 |= temp1 ^ temp2;
20        temp4 ^= temp1 & temp2;
21};filter BasicExpressions() {
22
23        temp4 = temp;
24        temp4 = temp1 | temp2;
25        temp4 = temp1 ^ temp2;
26        temp4 = temp1 & temp2;
27        temp4 = temp1 ^ temp2 | temp3;
28        temp4 = temp1 | temp2 ^ temp3;
29        temp4 = temp1 & temp2 | temp3;
30        temp4 = temp1 | temp2 & temp3;
31        temp4 = temp1 & (temp2 | temp3);
32        temp4 = (temp1 | temp2) & temp3;
33//      temp4 = ~temp;
34       
35};
36
37filter Assignments() {
38        stream<1> s;
39        s = 0;
40};filter Assignments() {
41        stream<1> s;
42        stream<1> a;
43        stream<1> b;
44        stream<1> c;
45        //s |= 0;
46        //s = a | b | c;
47        s |= a;
48        s |= a | b;
49        s |= a | b | c;
50        s |= a | b | c | d;
51        // s = s | a | b | c;
52};filter StreamStructs() {
53
54        // records
55        temp4 = temp1.temp2;
56        //temp4 = temp1.temp2.temp3;
57       
58        temp1.temp2 = temp4;
59        //temp1.temp2.temp3 = temp4;
60               
61};filter nameExpressions() {
62         stream<1> a = b.Advance();
63};
64filter name(struct TagCallouts tagCallouts, struct Lex lex) {   
65
66        stream<1> starts_accum = 0;
67        stream<1> ends_accum = 0;       
68        stream<1> cursor = pablo.ScanToFirst(lex.opener);
69       
70        while (cursor) {
71                starts_accum |= cursor;
72                cursor = pablo.ScanTo(cursor, lex.marker &~ cursor);
73                ends_accum |= cursor;
74                cursor = pablo.ScanTo(cursor, (lex.marker | lex.terminator) &~ cursor);
75                cursor = cursor & lex.marker;
76        }
77};
78filter While() {       
79                       
80        stream<1> cursor = 1;
81       
82        while (cursor) {
83          cursor = pablo.Advance(cursor);
84        }
85}
86filter While() {       
87       
88        stream<1> cursor;
89       
90        while (cursor) {
91                cursor = pablo.Advance(cursor);
92                cursor = cursor &~ terminator;
93        }
94}
95filter name() {
96        stream<1> cursor1;
97       
98        while (cursor1) {
99                stream<1> cursor2;
100                while(cursor2) {
101                        cursor = pablo.Advance(cursor);
102                        // cursor = cursor &~ terminator;
103                }
104        }
105}
106filter localDecl() {
107        struct BasisBits A;
108        struct BasisBits B;
109        struct BasisBits C;
110};filter Assignments() {
111        stream a;
112        stream<1> s = a;
113}filter localDecl() {
114        stream<1> A;
115        stream B;
116}filter localDecl() {
117
118        struct BasisBits A;
119
120} filter name() {       
121       
122        stream cursor;
123       
124        if(cursor & a) {
125                if(cursor & b) {
126               
127                }
128        }
129       
130}
131filter name() {
132       
133        stream cursor;
134       
135        if(cursor & a) {
136
137        } else {
138
139        }
140       
141}
142filter name() {         
143        stream cursor;
144        if(cursor) {
145
146        }
147}
148filter name() {
149       
150        stream cursor;
151       
152        if(cursor & a) {
153                if(cursor & b) {
154               
155                } else {
156               
157                }
158
159        } else {
160
161        }
162       
163}
164
165
166struct Basis_bits{
167    stream bit_0;
168    stream bit_1;
169    stream bit_2;
170    stream bit_3;
171    stream bit_4;
172    stream bit_5;
173    stream bit_6;
174    stream bit_7;
175};
176
177struct Lex{
178    stream a;
179    stream p;
180    stream l;
181    stream e;
182    stream LF;
183};
184
185struct Output{
186    stream match_follows;
187    stream lines;
188    stream line_starts;
189    stream line_ends;
190};
191
192filter ClassifyBytes(struct Basis_bits basis_bits, struct Lex lex) {
193    stream temp1 = (basis_bits.bit_1 & (~ basis_bits.bit_0));
194    stream temp2 = (basis_bits.bit_2 & (~ basis_bits.bit_3));
195    stream temp3 = (temp1 & temp2);
196    stream temp4 = (basis_bits.bit_4 | basis_bits.bit_5);
197    stream temp5 = (basis_bits.bit_7 & (~ basis_bits.bit_6));
198    stream temp6 = (temp5 & (~ temp4));
199    lex.a = (temp3 & temp6);
200    stream temp7 = (basis_bits.bit_2 & basis_bits.bit_3);
201    stream temp8 = (temp1 & temp7);
202    stream temp9 = (basis_bits.bit_6 | basis_bits.bit_7);
203    stream temp10 = (temp4 | temp9);
204    lex.p = (temp8 & (~ temp10));
205    stream temp11 = (basis_bits.bit_4 & basis_bits.bit_5);
206    stream temp12 = (temp11 & (~ temp9));
207    lex.l = (temp3 & temp12);
208    stream temp13 = (basis_bits.bit_5 & (~ basis_bits.bit_4));
209    stream temp14 = (temp13 & temp5);
210    lex.e = (temp3 & temp14);
211    stream temp15 = (basis_bits.bit_0 | basis_bits.bit_1);
212    stream temp16 = (basis_bits.bit_2 | basis_bits.bit_3);
213    stream temp17 = (temp15 | temp16);
214    stream temp18 = (basis_bits.bit_4 & (~ basis_bits.bit_5));
215    stream temp19 = (basis_bits.bit_6 & (~ basis_bits.bit_7));
216    stream temp20 = (temp18 & temp19);
217    lex.LF = (temp20 & (~ temp17));
218}
219
220filter Match(struct Lex lex, struct Output output) {
221    stream cursor = pablo.Advance(lex.a);
222    cursor = pablo.Advance((cursor & lex.p));
223    cursor = pablo.Advance((cursor & lex.p));
224    cursor = pablo.Advance((cursor & lex.l));
225    cursor = pablo.Advance((cursor & lex.e));
226    output.match_follows = cursor;
227}
228
229filter MatchLines(struct Lex lex, struct Output output) {
230    stream all_line_starts = (pablo.ScanToFirst((~ lex.LF)) | (pablo.Advance(lex.LF) & (~ lex.LF)));
231    stream all_line_ends = lex.LF;
232    stream last_line_start = pablo.ScanToFirst(all_line_starts);
233    stream cursor = last_line_start;
234    while (pablo.inFile(cursor)) {
235        if ((cursor & all_line_starts)) {
236            last_line_start = cursor;
237        }
238        if ((cursor & output.match_follows)) {
239            cursor = pablo.ScanTo(cursor, lex.LF);
240            output.lines |= pablo.InclusiveSpan(last_line_start, cursor);
241        }
242        cursor = pablo.AdvanceThenScanTo(cursor, (all_line_starts | output.match_follows));
243    }
244    output.line_starts = (output.lines & all_line_starts);
245    output.line_ends = pablo.ScanTo(output.line_starts, (output.lines & all_line_ends));
246}
247
248/*
249filter Main(struct Basis_bits basis_bits, struct Lex lex, struct Output output) {
250    Transpose(byte_data, basis_bits);
251    ClassifyBytes(basis_bits, lex);
252    Match(lex, output);
253    MatchLines(lex, output);
254}
255*/
256
257struct Basis_bits{
258    stream bit_0;
259    stream bit_1;
260    stream bit_2;
261    stream bit_3;
262    stream bit_4;
263    stream bit_5;
264    stream bit_6;
265    stream bit_7;
266};
267
268struct U8{
269    stream unibyte;
270    stream prefix;
271    stream prefix2;
272    stream prefix3;
273    stream prefix4;
274    stream suffix;
275    stream badprefix;
276    stream xE0;
277    stream xED;
278    stream xF0;
279    stream xF4;
280    stream xA0_xBF;
281    stream x80_x9F;
282    stream x90_xBF;
283    stream x80_x8F;
284    stream xEF;
285    stream xBF;
286    stream xBE;
287    stream scope22;
288    stream scope32;
289    stream scope33;
290    stream scope42;
291    stream scope43;
292    stream scope44;
293    stream xE0_scope;
294    stream xED_scope;
295    stream xF0_scope;
296    stream xF4_scope;
297    stream xEF_scope;
298};
299
300struct Lex{
301    stream CR;
302    stream LF;
303    stream HT;
304    stream SP;
305    stream CRLF;
306    stream RefStart;
307    stream Semicolon;
308    stream Colon;
309    stream LAngle;
310    stream RAngle;
311    stream LBracket;
312    stream RBracket;
313    stream Exclam;
314    stream QMark;
315    stream Hyphen;
316    stream Equals;
317    stream SQuote;
318    stream DQuote;
319    stream Slash;
320    stream Hash;
321    stream x;
322    stream ASCII_name_start;
323    stream ASCII_name_char;
324    stream NameScan;
325    stream Digit;
326    stream Hex;
327    stream WS;
328};
329
330struct Marker{
331    stream LAngle_scope;
332    stream Ref_opener;
333    stream CD_closer;
334};
335
336struct CtCDPI_Callouts{
337    stream Ct_starts;
338    stream Ct_ends;
339    stream CD_starts;
340    stream CD_ends;
341    stream PI_starts;
342    stream PI_name_starts;
343    stream PI_name_ends;
344    stream PI_ends;
345};
346
347struct Ref_Callouts{
348    stream GenRef_starts;
349    stream GenRef_ends;
350    stream DecRef_starts;
351    stream DecRef_ends;
352    stream HexRef_starts;
353    stream HexRef_ends;
354};
355
356struct Tag_Callouts{
357    stream ElemName_starts;
358    stream ElemName_ends;
359    stream AttName_starts;
360    stream AttName_ends;
361    stream AttVal_starts;
362    stream AttVal_ends;
363    stream AttVal_spans;
364    stream EmptyTag_marks;
365    stream EndTag_marks;
366};
367
368struct Check_streams{
369    stream misc_mask;
370    stream non_ascii_name_starts;
371    stream non_ascii_names;
372    stream tag_marks;
373    stream name_follows;
374    stream att_refs;
375};
376
377filter Classify_bytes_Validate_utf8(struct Basis_bits basis_bits, struct Lex lex, struct U8 u8) {
378    stream temp1 = (basis_bits.bit_0 | basis_bits.bit_1);
379    stream temp2 = (basis_bits.bit_2 & (~ basis_bits.bit_3));
380    stream temp3 = (temp2 & (~ temp1));
381    stream temp4 = (basis_bits.bit_5 & (~ basis_bits.bit_4));
382    stream temp5 = (basis_bits.bit_6 & (~ basis_bits.bit_7));
383    stream temp6 = (temp4 & temp5);
384    lex.RefStart = (temp3 & temp6);
385    stream temp7 = (basis_bits.bit_2 & basis_bits.bit_3);
386    stream temp8 = (temp7 & (~ temp1));
387    stream temp9 = (basis_bits.bit_4 & (~ basis_bits.bit_5));
388    stream temp10 = (basis_bits.bit_6 & basis_bits.bit_7);
389    stream temp11 = (temp9 & temp10);
390    lex.Semicolon = (temp8 & temp11);
391    stream temp12 = (basis_bits.bit_4 & basis_bits.bit_5);
392    stream temp13 = (basis_bits.bit_6 | basis_bits.bit_7);
393    stream temp14 = (temp12 & (~ temp13));
394    lex.LAngle = (temp8 & temp14);
395    stream temp15 = (temp12 & temp5);
396    lex.RAngle = (temp8 & temp15);
397    stream temp16 = (basis_bits.bit_1 & (~ basis_bits.bit_0));
398    stream temp17 = (basis_bits.bit_3 & (~ basis_bits.bit_2));
399    stream temp18 = (temp16 & temp17);
400    lex.LBracket = (temp18 & temp11);
401    stream temp19 = (basis_bits.bit_7 & (~ basis_bits.bit_6));
402    stream temp20 = (temp12 & temp19);
403    lex.RBracket = (temp18 & temp20);
404    stream temp21 = (basis_bits.bit_4 | basis_bits.bit_5);
405    stream temp22 = (temp19 & (~ temp21));
406    lex.Exclam = (temp3 & temp22);
407    stream temp23 = (temp12 & temp10);
408    lex.QMark = (temp8 & temp23);
409    lex.Hyphen = (temp3 & temp20);
410    lex.Equals = (temp8 & temp20);
411    stream temp24 = (temp4 & temp10);
412    lex.SQuote = (temp3 & temp24);
413    stream temp25 = (temp5 & (~ temp21));
414    lex.DQuote = (temp3 & temp25);
415    lex.Slash = (temp3 & temp23);
416    stream temp26 = (temp10 & (~ temp21));
417    lex.Hash = (temp3 & temp26);
418    stream temp27 = (temp16 & temp7);
419    stream temp28 = (temp9 & (~ temp13));
420    lex.x = (temp27 & temp28);
421    stream temp29 = (temp9 & temp5);
422    lex.Colon = (temp8 & temp29);
423    stream temp30 = (temp18 & temp23);
424    stream temp31 = (temp30 | lex.Colon);
425    stream temp32 = (temp16 & (~ basis_bits.bit_2));
426    stream temp33 = (basis_bits.bit_5 | temp10);
427    stream temp34 = (basis_bits.bit_4 & temp33);
428    stream temp35 = (~ temp34);
429    stream temp36 = (temp21 | temp13);
430    stream temp37 = ((basis_bits.bit_3 & temp35) | ((~ basis_bits.bit_3) & temp36));
431    stream temp38 = (temp32 & temp37);
432    stream temp39 = (temp31 | temp38);
433    stream temp40 = (temp16 & basis_bits.bit_2);
434    stream temp41 = (temp40 & temp37);
435    lex.ASCII_name_start = (temp39 | temp41);
436    stream temp42 = (temp30 | lex.Hyphen);
437    stream temp43 = (temp3 & temp15);
438    stream temp44 = (temp42 | temp43);
439    stream temp45 = (temp8 & (~ temp34));
440    stream temp46 = (temp44 | temp45);
441    stream temp47 = (temp46 | temp38);
442    lex.ASCII_name_char = (temp47 | temp41);
443    lex.NameScan = (lex.ASCII_name_char | basis_bits.bit_0);
444    stream temp48 = (temp1 | basis_bits.bit_2);
445    stream x00_x1F = (~ temp48);
446    stream temp49 = (basis_bits.bit_2 | basis_bits.bit_3);
447    stream temp50 = (temp1 | temp49);
448    lex.CR = (temp20 & (~ temp50));
449    lex.LF = (temp29 & (~ temp50));
450    stream temp51 = (temp9 & temp19);
451    lex.HT = (temp51 & (~ temp50));
452    lex.SP = (temp3 & (~ temp36));
453    stream temp52 = (temp20 | temp29);
454    stream temp53 = (temp52 | temp51);
455    stream temp54 = (temp53 & (~ temp50));
456    lex.WS = (temp54 | lex.SP);
457    stream temp55 = (basis_bits.bit_5 | basis_bits.bit_6);
458    stream temp56 = (basis_bits.bit_4 & temp55);
459    lex.Digit = (temp8 & (~ temp56));
460    stream temp57 = (temp16 & (~ temp49));
461    stream temp58 = (temp57 & (~ basis_bits.bit_4));
462    stream temp59 = (~ temp10);
463    stream temp60 = ((basis_bits.bit_5 & temp59) | ((~ basis_bits.bit_5) & temp13));
464    stream temp61 = (temp58 & temp60);
465    stream temp62 = (lex.Digit | temp61);
466    stream temp63 = (temp16 & temp2);
467    stream temp64 = (temp63 & (~ basis_bits.bit_4));
468    stream temp65 = (temp64 & temp60);
469    lex.Hex = (temp62 | temp65);
470    stream lex_error = (x00_x1F & (~ lex.WS));
471    pablo.assert_0(pablo.inFile(lex_error), "Error: illegal character");
472    u8.unibyte = (~ basis_bits.bit_0);
473    u8.suffix = pablo.Mask(1,0);
474    stream u8_error = pablo.Mask(1,0);
475    stream u8_FFFE_FFFF = pablo.Mask(1,0);
476    stream u8anyscope = pablo.Mask(1,0);
477    if (basis_bits.bit_0) {
478        u8.prefix = (basis_bits.bit_0 & basis_bits.bit_1);
479        u8.prefix2 = (u8.prefix & (~ basis_bits.bit_2));
480        u8.prefix3 = (u8.prefix & temp2);
481        u8.prefix4 = (u8.prefix & temp7);
482        u8.suffix = (basis_bits.bit_0 & (~ basis_bits.bit_1));
483        stream temp66 = (u8.prefix & (~ temp49));
484        stream temp67 = (temp21 | basis_bits.bit_6);
485        stream temp68 = (temp66 & (~ temp67));
486        stream temp69 = (basis_bits.bit_5 & temp13);
487        stream temp70 = (basis_bits.bit_4 | temp69);
488        stream temp71 = (u8.prefix4 & temp70);
489        u8.badprefix = (temp68 | temp71);
490        u8_error = u8.badprefix;
491        u8.scope22 = pablo.Advance(u8.prefix2);
492        u8anyscope = u8.scope22;
493        if ((u8.prefix3 | u8.prefix4)) {
494            stream xE0 = (u8.prefix3 & (~ temp36));
495            stream xED = (u8.prefix3 & temp20);
496            stream xF0 = (u8.prefix4 & (~ temp36));
497            stream temp72 = (temp4 & (~ temp13));
498            stream xF4 = (u8.prefix4 & temp72);
499            u8.xA0_xBF = (u8.suffix & basis_bits.bit_2);
500            u8.x80_x9F = (u8.suffix & (~ basis_bits.bit_2));
501            u8.x90_xBF = (u8.suffix & temp49);
502            u8.x80_x8F = (u8.suffix & (~ temp49));
503            stream xEF = (u8.prefix3 & temp23);
504            stream temp73 = (u8.suffix & temp7);
505            u8.xBF = (temp73 & temp23);
506            u8.xBE = (temp73 & temp15);
507            u8.scope32 = pablo.Advance(u8.prefix3);
508            u8.scope33 = pablo.Advance(u8.scope32);
509            u8.scope42 = pablo.Advance(u8.prefix4);
510            u8.scope43 = pablo.Advance(u8.scope42);
511            u8.scope44 = pablo.Advance(u8.scope43);
512            stream E0_F0_scope = pablo.Advance((xE0 | xF0));
513            stream ED_F4_scope = pablo.Advance((xED | xF4));
514            u8.xE0_scope = (u8.scope32 & E0_F0_scope);
515            u8.xED_scope = (u8.scope32 & ED_F4_scope);
516            u8.xF0_scope = (u8.scope42 & E0_F0_scope);
517            u8.xF4_scope = (u8.scope42 & ED_F4_scope);
518            u8.xEF_scope = pablo.Advance(xEF);
519            stream u8lastscope = ((u8.scope22 | u8.scope33) | u8.scope44);
520            u8anyscope = (((u8lastscope | u8.scope32) | u8.scope42) | u8.scope43);
521            stream u8error1 = (u8.xE0_scope & u8.x80_x9F);
522            stream u8error2 = (u8.xED_scope & u8.xA0_xBF);
523            stream u8error3 = (u8.xF0_scope & u8.x80_x8F);
524            stream u8error4 = (u8.xF4_scope & u8.x90_xBF);
525            u8_error |= (((u8error1 | u8error2) | u8error3) | u8error4);
526            stream EF_BF_pending = pablo.Advance((u8.xEF_scope & u8.xBF));
527            u8_FFFE_FFFF = (EF_BF_pending & (u8.xBE | u8.xBF));
528        }
529        stream u8mismatch = (u8anyscope ^ u8.suffix);
530        pablo.assert_0(((u8_error | u8mismatch) | u8_FFFE_FFFF), "UTF-8 error found");
531    }
532}
533
534filter Parse_CtCDPI(struct Lex lex, struct Marker marker, struct CtCDPI_Callouts ctCDPI_Callouts, struct Check_streams check_streams) {
535    ctCDPI_Callouts.Ct_starts = pablo.Mask(1,0);
536    ctCDPI_Callouts.Ct_ends = pablo.Mask(1,0);
537    ctCDPI_Callouts.CD_starts = pablo.Mask(1,0);
538    ctCDPI_Callouts.CD_ends = pablo.Mask(1,0);
539    ctCDPI_Callouts.PI_starts = pablo.Mask(1,0);
540    ctCDPI_Callouts.PI_name_starts = pablo.Mask(1,0);
541    ctCDPI_Callouts.PI_name_ends = pablo.Mask(1,0);
542    ctCDPI_Callouts.PI_ends = pablo.Mask(1,0);
543    stream CtCDPI_starts = pablo.Mask(1,0);
544    stream CtCDPI_ends = pablo.Mask(1,0);
545    stream ctCDPI_mask = pablo.Mask(1,0);
546    stream v = (lex.LAngle | lex.Hyphen);
547    stream w = (lex.Hyphen | lex.QMark);
548    stream v1 = pablo.AdvanceN(v, 1);
549    stream w1 = pablo.AdvanceN(w, 1);
550    stream LAngle_scope = (v1 & (~ w1));
551    stream PI_opener = (LAngle_scope & lex.QMark);
552    stream CtCD_opener = (LAngle_scope & lex.Exclam);
553    stream CtCDPI_opener = (PI_opener | CtCD_opener);
554    stream CD_closer = pablo.Mask(1,0);
555    stream DoubleHyphen = ((v1 & w1) & lex.Hyphen);
556    if (lex.RBracket) {
557        stream DoubleRBracket = (pablo.Advance(lex.RBracket) & lex.RBracket);
558        CD_closer = (pablo.Advance(DoubleRBracket) & lex.RAngle);
559    }
560    stream PI_closer = ((w1 & (~ v1)) & lex.RAngle);
561    stream CtCDPI_Cursor = pablo.ScanToFirst(CtCDPI_opener);
562    while (CtCDPI_Cursor) {
563        CtCDPI_starts |= CtCDPI_Cursor;
564        stream PI_Cursor = (CtCDPI_Cursor & PI_opener);
565        stream CD_Ct_Cursor = pablo.Advance((CtCDPI_Cursor & (~ PI_Cursor)));
566        stream CD_Cursor = (CD_Ct_Cursor & lex.LBracket);
567        stream Ct_Cursor = (CD_Ct_Cursor & lex.Hyphen);
568        if (PI_Cursor) {
569            ctCDPI_Callouts.PI_starts |= PI_Cursor;
570            PI_Cursor = pablo.Advance(PI_Cursor);
571            ctCDPI_Callouts.PI_name_starts |= PI_Cursor;
572            stream PI_name_end = pablo.ScanThru(PI_Cursor, lex.NameScan);
573            stream PI_error = (PI_Cursor & PI_name_end);
574            stream PI_noWS = (PI_name_end & (~ lex.WS));
575            PI_error |= ((PI_noWS & (~ lex.QMark)) | (pablo.Advance(PI_noWS) & (~ PI_closer)));
576            pablo.assert_0(PI_error, "Error in PI syntax");
577            ctCDPI_Callouts.PI_name_ends |= PI_name_end;
578            PI_Cursor = pablo.ScanTo(PI_name_end, PI_closer);
579            ctCDPI_Callouts.PI_ends |= PI_Cursor;
580            CtCDPI_ends |= PI_Cursor;
581        }
582        if (CD_Cursor) {
583            ctCDPI_Callouts.CD_starts |= CD_Cursor;
584            CD_Cursor = pablo.ScanTo(CD_Cursor, CD_closer);
585            ctCDPI_Callouts.CD_ends |= CD_Cursor;
586            CtCDPI_ends |= CD_Cursor;
587        }
588        if (Ct_Cursor) {
589            ctCDPI_Callouts.Ct_starts |= Ct_Cursor;
590            Ct_Cursor = pablo.Advance(Ct_Cursor);
591            stream Ct_error = (Ct_Cursor & (~ lex.Hyphen));
592            Ct_Cursor = pablo.Advance(pablo.Advance(Ct_Cursor));
593            Ct_Cursor = pablo.Advance(pablo.ScanTo(Ct_Cursor, DoubleHyphen));
594            pablo.assert_0((Ct_error | (Ct_Cursor & (~ lex.RAngle))), "Error in comment syntax");
595            ctCDPI_Callouts.Ct_ends |= Ct_Cursor;
596            CtCDPI_ends |= Ct_Cursor;
597        }
598        CtCDPI_Cursor = ((PI_Cursor | CD_Cursor) | Ct_Cursor);
599        ctCDPI_mask = pablo.InclusiveSpan(CtCDPI_starts, CtCDPI_ends);
600        pablo.assert_0(pablo.atEOF(ctCDPI_mask), "Error in comment, CDATA or processing instruction syntax");
601        CtCDPI_Cursor = pablo.ScanTo(CtCDPI_Cursor, CtCDPI_opener);
602    }
603    check_streams.misc_mask = ((((lex.WS | lex.LAngle) | pablo.InclusiveSpan((ctCDPI_Callouts.Ct_starts | ctCDPI_Callouts.PI_starts), (ctCDPI_Callouts.Ct_ends | ctCDPI_Callouts.PI_ends))) | CtCDPI_starts) & EOF_mask);
604    marker.LAngle_scope = (LAngle_scope & (~ ctCDPI_mask));
605    marker.Ref_opener = (lex.RefStart & (~ ctCDPI_mask));
606    marker.CD_closer = (CD_closer & (~ ctCDPI_mask));
607}
608
609filter Parse_tags(struct Lex lex, struct Marker marker, struct Tag_Callouts tag_Callouts) {
610    stream EqExpected = pablo.Mask(1,0);
611    stream AttListEnd = pablo.Mask(1,0);
612    stream DQuoteDelim = (lex.DQuote | lex.LAngle);
613    stream SQuoteDelim = (lex.SQuote | lex.LAngle);
614    stream AttListDelim = (lex.Slash | lex.RAngle);
615    tag_Callouts.ElemName_starts = (marker.LAngle_scope & (~ lex.Slash));
616    tag_Callouts.EndTag_marks = (marker.LAngle_scope & lex.Slash);
617    tag_Callouts.ElemName_ends = pablo.ScanThru(tag_Callouts.ElemName_starts, lex.NameScan);
618    stream ParseError = (tag_Callouts.ElemName_starts & tag_Callouts.ElemName_ends);
619    tag_Callouts.AttName_starts = pablo.Mask(1,0);
620    tag_Callouts.AttName_ends = pablo.Mask(1,0);
621    tag_Callouts.AttVal_starts = pablo.Mask(1,0);
622    tag_Callouts.AttVal_ends = pablo.Mask(1,0);
623    if ((tag_Callouts.ElemName_ends & lex.WS)) {
624        stream AfterWS = pablo.ScanThru(tag_Callouts.ElemName_ends, lex.WS);
625        AttListEnd = (AfterWS & AttListDelim);
626        stream AttNameStart = (AfterWS & (~ AttListDelim));
627        while (AttNameStart) {
628            ParseError |= (AttNameStart & (~ lex.NameScan));
629            tag_Callouts.AttName_starts |= AttNameStart;
630            stream AttNameFollow = pablo.ScanThru(AttNameStart, lex.NameScan);
631            tag_Callouts.AttName_ends |= AttNameFollow;
632            if ((AttNameFollow & lex.WS)) {
633                EqExpected = pablo.ScanThru(AttNameFollow, lex.WS);
634            }
635            else {
636                EqExpected = AttNameFollow;
637            }
638            ParseError |= (EqExpected & (~ lex.Equals));
639            stream AttValPos = pablo.AdvanceThenScanThru(EqExpected, lex.WS);
640            tag_Callouts.AttVal_starts |= AttValPos;
641            stream DQuoteAttVal = (AttValPos & lex.DQuote);
642            stream SQuoteAttVal = (AttValPos & lex.SQuote);
643            stream DQuoteAttEnd = pablo.AdvanceThenScanTo(DQuoteAttVal, DQuoteDelim);
644            stream SQuoteAttEnd = pablo.AdvanceThenScanTo(SQuoteAttVal, SQuoteDelim);
645            stream AttValEnd = (DQuoteAttEnd | SQuoteAttEnd);
646            ParseError |= ((AttValPos | AttValEnd) & (~ (lex.DQuote | lex.SQuote)));
647            stream AttValFollow = pablo.Advance(AttValEnd);
648            tag_Callouts.AttVal_ends |= AttValFollow;
649            if ((AttValFollow & lex.WS)) {
650                AfterWS = pablo.ScanThru(AttValFollow, lex.WS);
651                AttListEnd |= (AfterWS & AttListDelim);
652                AttNameStart = (AfterWS & (~ AttListDelim));
653            }
654            else {
655                AttListEnd |= (AttValFollow & AttListDelim);
656                AttNameStart = (AttValFollow & (~ AttListDelim));
657            }
658            ParseError |= (AttValFollow & AttNameStart);
659        }
660    }
661    else {
662        AttListEnd = (tag_Callouts.ElemName_ends & AttListDelim);
663        ParseError |= (tag_Callouts.ElemName_ends & (~ AttListDelim));
664    }
665    stream STagEnds = (AttListEnd & lex.RAngle);
666    tag_Callouts.EmptyTag_marks = pablo.Advance((AttListEnd & lex.Slash));
667    ParseError |= (tag_Callouts.EmptyTag_marks & (~ lex.RAngle));
668    stream EndTagEnds = pablo.AdvanceThenScanThru(tag_Callouts.EndTag_marks, lex.NameScan);
669    if ((EndTagEnds & lex.WS)) {
670        EndTagEnds = pablo.ScanThru(EndTagEnds, lex.WS);
671    }
672    ParseError |= (EndTagEnds & (~ lex.RAngle));
673    pablo.assert_0(ParseError, "Tag parsing error found");
674    tag_Callouts.AttVal_spans = pablo.SpanUpTo(tag_Callouts.AttVal_starts, tag_Callouts.AttVal_ends);
675}
676
677filter Parse_refs(struct Lex lex, struct Marker marker, struct Ref_Callouts ref_Callouts) {
678    ref_Callouts.GenRef_starts = pablo.Mask(1,0);
679    ref_Callouts.GenRef_ends = pablo.Mask(1,0);
680    ref_Callouts.DecRef_starts = pablo.Mask(1,0);
681    ref_Callouts.DecRef_ends = pablo.Mask(1,0);
682    ref_Callouts.HexRef_starts = pablo.Mask(1,0);
683    ref_Callouts.HexRef_ends = pablo.Mask(1,0);
684    stream ref_error = pablo.Mask(1,0);
685    if (marker.Ref_opener) {
686        stream Ref_scope = pablo.Advance(marker.Ref_opener);
687        stream NumRef2 = (Ref_scope & lex.Hash);
688        ref_Callouts.GenRef_starts = (Ref_scope & (~ lex.Hash));
689        stream NumRef3 = pablo.Advance(NumRef2);
690        stream HexRef3 = (NumRef3 & lex.x);
691        ref_Callouts.DecRef_starts = (NumRef3 & (~ lex.x));
692        ref_Callouts.HexRef_starts = pablo.Advance(HexRef3);
693        ref_Callouts.GenRef_ends = pablo.ScanThru(ref_Callouts.GenRef_starts, lex.NameScan);
694        ref_Callouts.DecRef_ends = pablo.ScanThru(ref_Callouts.DecRef_starts, lex.Digit);
695        ref_Callouts.HexRef_ends = pablo.ScanThru(ref_Callouts.HexRef_starts, lex.Hex);
696        stream ref_error1 = (ref_Callouts.DecRef_starts & (~ lex.Digit));
697        stream ref_error2 = (ref_Callouts.HexRef_starts & (~ lex.Hex));
698        stream ref_ends = ((ref_Callouts.GenRef_ends | ref_Callouts.DecRef_ends) | ref_Callouts.HexRef_ends);
699        stream ref_error3 = (ref_ends & (~ lex.Semicolon));
700        pablo.assert_0(((ref_error1 | ref_error2) | ref_error3), "Reference error found");
701    }
702}
703
704filter Validate_xml_names(struct CtCDPI_Callouts ctCDPI_Callouts, struct Ref_Callouts ref_Callouts, struct Tag_Callouts tag_Callouts, struct Lex lex, struct U8 u8, struct Check_streams check_streams) {
705    stream PI_names = pablo.SpanUpTo(ctCDPI_Callouts.PI_name_starts, ctCDPI_Callouts.PI_name_ends);
706    stream GenRefs = pablo.SpanUpTo(ref_Callouts.GenRef_starts, ref_Callouts.GenRef_ends);
707    stream ElemNames = pablo.SpanUpTo(tag_Callouts.ElemName_starts, tag_Callouts.ElemName_ends);
708    stream AttNames = pablo.SpanUpTo(tag_Callouts.AttName_starts, tag_Callouts.AttName_ends);
709    stream qname_stream = (ElemNames | AttNames);
710    stream ncname_stream = (PI_names | GenRefs);
711    stream name_stream = (qname_stream | ncname_stream);
712    stream name_start = (name_stream & (~ pablo.Advance(name_stream)));
713    stream name_cursor = (name_stream & (~ pablo.Advance(name_stream)));
714    stream void_prefix_err = (name_cursor & lex.Colon);
715    stream namespace_sep = (pablo.ScanThru(name_cursor, (lex.NameScan & (~ lex.Colon))) & lex.Colon);
716    stream local_part_start = pablo.Advance(namespace_sep);
717    stream local_part_err = (local_part_start & (~ lex.NameScan));
718    stream colon2_err = (pablo.ScanThru(local_part_start, (lex.NameScan & (~ lex.Colon))) & lex.Colon);
719    stream ncname_err = (ncname_stream & lex.Colon);
720    pablo.assert_0((((void_prefix_err | local_part_err) | colon2_err) | ncname_err), "name syntax error");
721    check_streams.non_ascii_name_starts = (name_start & (~ lex.ASCII_name_start));
722    check_streams.non_ascii_names = (((name_stream & (~ name_start)) & (~ lex.ASCII_name_char)) & (~ u8.suffix));
723}
724
725filter Do_check_streams(struct Marker marker, struct Tag_Callouts tag_Callouts, struct Check_streams check_streams) {
726    pablo.assert_0((marker.CD_closer & (~ tag_Callouts.AttVal_spans)), "Error: ]]> in text");
727    check_streams.tag_marks = (((tag_Callouts.EmptyTag_marks | tag_Callouts.ElemName_starts) | tag_Callouts.EndTag_marks) | tag_Callouts.AttName_starts);
728    check_streams.name_follows = (tag_Callouts.ElemName_ends | tag_Callouts.AttName_ends);
729    check_streams.att_refs = (tag_Callouts.AttVal_spans & marker.Ref_opener);
730}struct bb {
731        stream<1> a;
732
733};
734
735/*
736filter name(stream<1> a, stream<1> b, stream<1> c) {
737
738
739};
740*/
741struct B
742{
743        stream<1> a;
744        stream<1> a;
745        stream<1> a;
746        stream<1> a;
747};
748
749filter Foo() { }
750filter ClassifyBytes(struct BasisBit basis) {};
751
752
753struct Basis{
754    stream bit_0;
755    stream bit_1;
756    stream bit_2;
757    stream bit_3;
758    stream bit_4;
759    stream bit_5;
760    stream bit_6;
761    stream bit_7;
762};
763
764struct Lex{
765    stream a;
766    stream p;
767    stream l;
768    stream e;
769    stream LF;
770};
771
772struct Matches{
773    stream all_matched;
774};
775
776struct Lines{
777    stream all_matched;
778};
779
780struct Output{
781    stream lines;
782};
783
784filter ClassifyBytes(struct Basis_bits basis_bits, struct Lex lex) {
785    stream temp1 = (basis_bits.bit_1 & (~ basis_bits.bit_0));
786    stream temp2 = (basis_bits.bit_2 & (~ basis_bits.bit_3));
787    stream temp3 = (temp1 & temp2);
788    stream temp4 = (basis_bits.bit_4 | basis_bits.bit_5);
789    stream temp5 = (basis_bits.bit_7 & (~ basis_bits.bit_6));
790    stream temp6 = (temp5 & (~ temp4));
791    lex.a = (temp3 & temp6);
792    stream temp7 = (basis_bits.bit_2 & basis_bits.bit_3);
793    stream temp8 = (temp1 & temp7);
794    stream temp9 = (basis_bits.bit_6 | basis_bits.bit_7);
795    stream temp10 = (temp4 | temp9);
796    lex.p = (temp8 & (~ temp10));
797    stream temp11 = (basis_bits.bit_4 & basis_bits.bit_5);
798    stream temp12 = (temp11 & (~ temp9));
799    lex.l = (temp3 & temp12);
800    stream temp13 = (basis_bits.bit_5 & (~ basis_bits.bit_4));
801    stream temp14 = (temp13 & temp5);
802    lex.e = (temp3 & temp14);
803    stream temp15 = (basis_bits.bit_0 | basis_bits.bit_1);
804    stream temp16 = (basis_bits.bit_2 | basis_bits.bit_3);
805    stream temp17 = (temp15 | temp16);
806    stream temp18 = (basis_bits.bit_4 & (~ basis_bits.bit_5));
807    stream temp19 = (basis_bits.bit_6 & (~ basis_bits.bit_7));
808    stream temp20 = (temp18 & temp19);
809    lex.LF = (temp20 & (~ temp17));
810}
811
812filter Match(struct Lex lex, struct Matches matches) {
813    stream m0 = lex.a;
814    stream m1 = (pablo.Advance(m0) & lex.p);
815    stream m2 = (pablo.Advance(m1) & lex.p);
816    stream m3 = (pablo.Advance(m2) & lex.l);
817    stream m4 = (pablo.Advance(m3) & lex.e);
818    matches.all_matched = m4;
819}
820
821filter MatchLines1(struct Lex lex, struct Matches matches, struct Lines lines) {
822    stream last_start = pablo.First();
823    stream LF_or_match = (lex.LF | matches.all_matched);
824    stream cursor = pablo.ScanToFirst(LF_or_match);
825    while (pablo.inFile(cursor)) {
826        if ((cursor & matches.all_matched)) {
827            stream next_end = pablo.AdvanceThenScanTo(cursor, lex.LF);
828            lines.all_matched |= (pablo.InclusiveSpan(last_start, next_end) | next_end);
829            cursor = next_end;
830        }
831        if ((cursor & lex.LF)) {
832            last_start = pablo.Advance(cursor);
833        }
834        cursor = pablo.AdvanceThenScanTo(cursor, LF_or_match);
835    }
836}
837
838filter MatchLines2(struct Lex lex, struct Matches matches, struct Lines lines) {
839    stream last_start = pablo.Mask(1,0);
840    last_start = (pablo.Advance((~ last_start)) ^ (~ last_start));
841    stream LF_or_match = (lex.LF | matches.all_matched);
842    stream cursor = pablo.ScanToFirst(LF_or_match);
843    while (pablo.inFile(cursor)) {
844        if ((cursor & matches.all_matched)) {
845            stream next_end = pablo.AdvanceThenScanTo(cursor, lex.LF);
846            lines.all_matched |= (pablo.InclusiveSpan(last_start, next_end) | next_end);
847            cursor = next_end;
848        }
849        if ((cursor & lex.LF)) {
850            last_start = pablo.Advance(cursor);
851        }
852        cursor = pablo.AdvanceThenScanTo(cursor, LF_or_match);
853    }
854}
855
856filter nameMatchLines(struct Data data, struct Output output) {
857    output.lines = pablo.filter_bytes(data, (~ lines.all_matched));
858}
859
860filter CountLines(struct Lex lex, struct Lines lines) {
861    return pablo.PopCount((pablo.MatchStar(lines, (~ lex.LF)) & lex.LF)) ;
862}
863/*
864        Block comment.
865*/
866
867// EOL terminated comment.
868
869// Another EOL terminated comment.
870
Note: See TracBrowser for help on using the repository browser.