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

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

Added graph to b2k. Updated grammars. Added S2K to B2K support.

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