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

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

Renamed tests.

File size: 22.8 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
14function void Foo() {
15
16}function void StreamStructs() {
17
18        // records
19        temp4 = temp1.temp2;
20        temp4 = temp1.temp2.temp3;
21       
22        temp1.temp2 = temp4;
23        temp1.temp2.temp3 = temp4;
24               
25};function void BasicExpressions() {
26
27        temp4 = temp;
28        temp4 = temp1 | temp2;
29        temp4 = temp1 ^ temp2;
30        temp4 = temp1 & temp2;
31        temp4 = temp1 ^ temp2 | temp3;
32        temp4 = temp1 | temp2 ^ temp3;
33        temp4 = temp1 & temp2 | temp3;
34        temp4 = temp1 | temp2 & temp3;
35        temp4 = temp1 & (temp2 | temp3);
36        temp4 = (temp1 | temp2) & temp3;
37//      temp4 = ~temp;
38       
39};
40
41function struct A FunctionExpressions() {
42         stream<1> a = b.Advance();
43};
44function void Assignments() {
45        stream<1> s;
46        stream<1> a;
47        stream<1> b;
48        stream<1> c;
49        //s |= 0;
50        //s = a | b | c;
51        s |= a;
52        s |= a | b;
53        s |= a | b | c;
54        s |= a | b | c | d;
55        // s = s | a | b | c;
56};function void AssignmentExpressions() {       
57        temp4 = temp;
58        temp4 &= temp1 | temp2;
59        temp4 |= temp1 ^ temp2;
60        temp4 ^= temp1 & temp2;
61};function void Assignments() {
62        stream<1> s;
63        s = 0;
64};function void Function(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};
78function void While() {
79                       
80        stream<1> cursor = 1;
81       
82        while (cursor) {
83          cursor = pablo.Advance(cursor);
84        }
85}
86function void While() {
87       
88        stream<1> cursor;
89       
90        while (cursor) {
91                cursor = pablo.Advance(cursor);
92                cursor = cursor &~ terminator;
93        }
94}
95function void Function() {     
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}
106function void localDecl() {
107        struct BasisBits A;
108        struct BasisBits B;
109        struct BasisBits C;
110};function void Assignments() {
111        stream a;
112        stream<1> s = a;
113}function void localDecl() {
114
115        struct BasisBits A;
116
117} function void localDecl() {
118        stream<1> A;
119        stream B;
120}function void Function() {             
121        stream cursor;
122        if(cursor) {
123
124        }
125}
126function void Function() {     
127       
128        stream cursor;
129       
130        if(cursor & a) {
131                if(cursor & b) {
132               
133                } else {
134               
135                }
136
137        } else {
138
139        }
140       
141}
142function void Function() {     
143       
144        stream cursor;
145       
146        if(cursor & a) {
147                if(cursor & b) {
148               
149                }
150        }
151       
152}
153function void Function() {     
154       
155        stream cursor;
156       
157        if(cursor & a) {
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 U8{
178    stream unibyte;
179    stream prefix;
180    stream prefix2;
181    stream prefix3;
182    stream prefix4;
183    stream suffix;
184    stream badprefix;
185    stream xE0;
186    stream xED;
187    stream xF0;
188    stream xF4;
189    stream xA0_xBF;
190    stream x80_x9F;
191    stream x90_xBF;
192    stream x80_x8F;
193    stream xEF;
194    stream xBF;
195    stream xBE;
196    stream scope22;
197    stream scope32;
198    stream scope33;
199    stream scope42;
200    stream scope43;
201    stream scope44;
202    stream xE0_scope;
203    stream xED_scope;
204    stream xF0_scope;
205    stream xF4_scope;
206    stream xEF_scope;
207};
208
209struct Lex{
210    stream CR;
211    stream LF;
212    stream HT;
213    stream SP;
214    stream CRLF;
215    stream RefStart;
216    stream Semicolon;
217    stream Colon;
218    stream LAngle;
219    stream RAngle;
220    stream LBracket;
221    stream RBracket;
222    stream Exclam;
223    stream QMark;
224    stream Hyphen;
225    stream Equals;
226    stream SQuote;
227    stream DQuote;
228    stream Slash;
229    stream Hash;
230    stream x;
231    stream ASCII_name_start;
232    stream ASCII_name_char;
233    stream NameScan;
234    stream Digit;
235    stream Hex;
236    stream WS;
237};
238
239struct Marker{
240    stream LAngle_scope;
241    stream Ref_opener;
242    stream CD_closer;
243};
244
245struct CtCDPI_Callouts{
246    stream Ct_starts;
247    stream Ct_ends;
248    stream CD_starts;
249    stream CD_ends;
250    stream PI_starts;
251    stream PI_name_starts;
252    stream PI_name_ends;
253    stream PI_ends;
254};
255
256struct Ref_Callouts{
257    stream GenRef_starts;
258    stream GenRef_ends;
259    stream DecRef_starts;
260    stream DecRef_ends;
261    stream HexRef_starts;
262    stream HexRef_ends;
263};
264
265struct Tag_Callouts{
266    stream ElemName_starts;
267    stream ElemName_ends;
268    stream AttName_starts;
269    stream AttName_ends;
270    stream AttVal_starts;
271    stream AttVal_ends;
272    stream AttVal_spans;
273    stream EmptyTag_marks;
274    stream EndTag_marks;
275};
276
277struct Check_streams{
278    stream misc_mask;
279    stream non_ascii_name_starts;
280    stream non_ascii_names;
281    stream tag_marks;
282    stream name_follows;
283    stream att_refs;
284};
285
286function void Classify_bytes_Validate_utf8(struct Basis_bits basis_bits, struct Lex lex, struct U8 u8) {
287    stream temp1 = (basis_bits.bit_0 | basis_bits.bit_1);
288    stream temp2 = (basis_bits.bit_2 & (~ basis_bits.bit_3));
289    stream temp3 = (temp2 & (~ temp1));
290    stream temp4 = (basis_bits.bit_5 & (~ basis_bits.bit_4));
291    stream temp5 = (basis_bits.bit_6 & (~ basis_bits.bit_7));
292    stream temp6 = (temp4 & temp5);
293    lex.RefStart = (temp3 & temp6);
294    stream temp7 = (basis_bits.bit_2 & basis_bits.bit_3);
295    stream temp8 = (temp7 & (~ temp1));
296    stream temp9 = (basis_bits.bit_4 & (~ basis_bits.bit_5));
297    stream temp10 = (basis_bits.bit_6 & basis_bits.bit_7);
298    stream temp11 = (temp9 & temp10);
299    lex.Semicolon = (temp8 & temp11);
300    stream temp12 = (basis_bits.bit_4 & basis_bits.bit_5);
301    stream temp13 = (basis_bits.bit_6 | basis_bits.bit_7);
302    stream temp14 = (temp12 & (~ temp13));
303    lex.LAngle = (temp8 & temp14);
304    stream temp15 = (temp12 & temp5);
305    lex.RAngle = (temp8 & temp15);
306    stream temp16 = (basis_bits.bit_1 & (~ basis_bits.bit_0));
307    stream temp17 = (basis_bits.bit_3 & (~ basis_bits.bit_2));
308    stream temp18 = (temp16 & temp17);
309    lex.LBracket = (temp18 & temp11);
310    stream temp19 = (basis_bits.bit_7 & (~ basis_bits.bit_6));
311    stream temp20 = (temp12 & temp19);
312    lex.RBracket = (temp18 & temp20);
313    stream temp21 = (basis_bits.bit_4 | basis_bits.bit_5);
314    stream temp22 = (temp19 & (~ temp21));
315    lex.Exclam = (temp3 & temp22);
316    stream temp23 = (temp12 & temp10);
317    lex.QMark = (temp8 & temp23);
318    lex.Hyphen = (temp3 & temp20);
319    lex.Equals = (temp8 & temp20);
320    stream temp24 = (temp4 & temp10);
321    lex.SQuote = (temp3 & temp24);
322    stream temp25 = (temp5 & (~ temp21));
323    lex.DQuote = (temp3 & temp25);
324    lex.Slash = (temp3 & temp23);
325    stream temp26 = (temp10 & (~ temp21));
326    lex.Hash = (temp3 & temp26);
327    stream temp27 = (temp16 & temp7);
328    stream temp28 = (temp9 & (~ temp13));
329    lex.x = (temp27 & temp28);
330    stream temp29 = (temp9 & temp5);
331    lex.Colon = (temp8 & temp29);
332    stream temp30 = (temp18 & temp23);
333    stream temp31 = (temp30 | lex.Colon);
334    stream temp32 = (temp16 & (~ basis_bits.bit_2));
335    stream temp33 = (basis_bits.bit_5 | temp10);
336    stream temp34 = (basis_bits.bit_4 & temp33);
337    stream temp35 = (~ temp34);
338    stream temp36 = (temp21 | temp13);
339    stream temp37 = ((basis_bits.bit_3 & temp35) | ((~ basis_bits.bit_3) & temp36));
340    stream temp38 = (temp32 & temp37);
341    stream temp39 = (temp31 | temp38);
342    stream temp40 = (temp16 & basis_bits.bit_2);
343    stream temp41 = (temp40 & temp37);
344    lex.ASCII_name_start = (temp39 | temp41);
345    stream temp42 = (temp30 | lex.Hyphen);
346    stream temp43 = (temp3 & temp15);
347    stream temp44 = (temp42 | temp43);
348    stream temp45 = (temp8 & (~ temp34));
349    stream temp46 = (temp44 | temp45);
350    stream temp47 = (temp46 | temp38);
351    lex.ASCII_name_char = (temp47 | temp41);
352    lex.NameScan = (lex.ASCII_name_char | basis_bits.bit_0);
353    stream temp48 = (temp1 | basis_bits.bit_2);
354    stream x00_x1F = (~ temp48);
355    stream temp49 = (basis_bits.bit_2 | basis_bits.bit_3);
356    stream temp50 = (temp1 | temp49);
357    lex.CR = (temp20 & (~ temp50));
358    lex.LF = (temp29 & (~ temp50));
359    stream temp51 = (temp9 & temp19);
360    lex.HT = (temp51 & (~ temp50));
361    lex.SP = (temp3 & (~ temp36));
362    stream temp52 = (temp20 | temp29);
363    stream temp53 = (temp52 | temp51);
364    stream temp54 = (temp53 & (~ temp50));
365    lex.WS = (temp54 | lex.SP);
366    stream temp55 = (basis_bits.bit_5 | basis_bits.bit_6);
367    stream temp56 = (basis_bits.bit_4 & temp55);
368    lex.Digit = (temp8 & (~ temp56));
369    stream temp57 = (temp16 & (~ temp49));
370    stream temp58 = (temp57 & (~ basis_bits.bit_4));
371    stream temp59 = (~ temp10);
372    stream temp60 = ((basis_bits.bit_5 & temp59) | ((~ basis_bits.bit_5) & temp13));
373    stream temp61 = (temp58 & temp60);
374    stream temp62 = (lex.Digit | temp61);
375    stream temp63 = (temp16 & temp2);
376    stream temp64 = (temp63 & (~ basis_bits.bit_4));
377    stream temp65 = (temp64 & temp60);
378    lex.Hex = (temp62 | temp65);
379    stream lex_error = (x00_x1F & (~ lex.WS));
380    pablo.assert_0(pablo.inFile(lex_error), "Error: illegal character");
381    u8.unibyte = (~ basis_bits.bit_0);
382    u8.suffix = pablo.Mask(1,0);
383    stream u8_error = pablo.Mask(1,0);
384    stream u8_FFFE_FFFF = pablo.Mask(1,0);
385    stream u8anyscope = pablo.Mask(1,0);
386    if (basis_bits.bit_0) {
387        u8.prefix = (basis_bits.bit_0 & basis_bits.bit_1);
388        u8.prefix2 = (u8.prefix & (~ basis_bits.bit_2));
389        u8.prefix3 = (u8.prefix & temp2);
390        u8.prefix4 = (u8.prefix & temp7);
391        u8.suffix = (basis_bits.bit_0 & (~ basis_bits.bit_1));
392        stream temp66 = (u8.prefix & (~ temp49));
393        stream temp67 = (temp21 | basis_bits.bit_6);
394        stream temp68 = (temp66 & (~ temp67));
395        stream temp69 = (basis_bits.bit_5 & temp13);
396        stream temp70 = (basis_bits.bit_4 | temp69);
397        stream temp71 = (u8.prefix4 & temp70);
398        u8.badprefix = (temp68 | temp71);
399        u8_error = u8.badprefix;
400        u8.scope22 = pablo.Advance(u8.prefix2);
401        u8anyscope = u8.scope22;
402        if ((u8.prefix3 | u8.prefix4)) {
403            stream xE0 = (u8.prefix3 & (~ temp36));
404            stream xED = (u8.prefix3 & temp20);
405            stream xF0 = (u8.prefix4 & (~ temp36));
406            stream temp72 = (temp4 & (~ temp13));
407            stream xF4 = (u8.prefix4 & temp72);
408            u8.xA0_xBF = (u8.suffix & basis_bits.bit_2);
409            u8.x80_x9F = (u8.suffix & (~ basis_bits.bit_2));
410            u8.x90_xBF = (u8.suffix & temp49);
411            u8.x80_x8F = (u8.suffix & (~ temp49));
412            stream xEF = (u8.prefix3 & temp23);
413            stream temp73 = (u8.suffix & temp7);
414            u8.xBF = (temp73 & temp23);
415            u8.xBE = (temp73 & temp15);
416            u8.scope32 = pablo.Advance(u8.prefix3);
417            u8.scope33 = pablo.Advance(u8.scope32);
418            u8.scope42 = pablo.Advance(u8.prefix4);
419            u8.scope43 = pablo.Advance(u8.scope42);
420            u8.scope44 = pablo.Advance(u8.scope43);
421            stream E0_F0_scope = pablo.Advance((xE0 | xF0));
422            stream ED_F4_scope = pablo.Advance((xED | xF4));
423            u8.xE0_scope = (u8.scope32 & E0_F0_scope);
424            u8.xED_scope = (u8.scope32 & ED_F4_scope);
425            u8.xF0_scope = (u8.scope42 & E0_F0_scope);
426            u8.xF4_scope = (u8.scope42 & ED_F4_scope);
427            u8.xEF_scope = pablo.Advance(xEF);
428            stream u8lastscope = ((u8.scope22 | u8.scope33) | u8.scope44);
429            u8anyscope = (((u8lastscope | u8.scope32) | u8.scope42) | u8.scope43);
430            stream u8error1 = (u8.xE0_scope & u8.x80_x9F);
431            stream u8error2 = (u8.xED_scope & u8.xA0_xBF);
432            stream u8error3 = (u8.xF0_scope & u8.x80_x8F);
433            stream u8error4 = (u8.xF4_scope & u8.x90_xBF);
434            u8_error |= (((u8error1 | u8error2) | u8error3) | u8error4);
435            stream EF_BF_pending = pablo.Advance((u8.xEF_scope & u8.xBF));
436            u8_FFFE_FFFF = (EF_BF_pending & (u8.xBE | u8.xBF));
437        }
438        stream u8mismatch = (u8anyscope ^ u8.suffix);
439        pablo.assert_0(((u8_error | u8mismatch) | u8_FFFE_FFFF), "UTF-8 error found");
440    }
441}
442
443function void Parse_CtCDPI(struct Lex lex, struct Marker marker, struct CtCDPI_Callouts ctCDPI_Callouts, struct Check_streams check_streams) {
444    ctCDPI_Callouts.Ct_starts = pablo.Mask(1,0);
445    ctCDPI_Callouts.Ct_ends = pablo.Mask(1,0);
446    ctCDPI_Callouts.CD_starts = pablo.Mask(1,0);
447    ctCDPI_Callouts.CD_ends = pablo.Mask(1,0);
448    ctCDPI_Callouts.PI_starts = pablo.Mask(1,0);
449    ctCDPI_Callouts.PI_name_starts = pablo.Mask(1,0);
450    ctCDPI_Callouts.PI_name_ends = pablo.Mask(1,0);
451    ctCDPI_Callouts.PI_ends = pablo.Mask(1,0);
452    stream CtCDPI_starts = pablo.Mask(1,0);
453    stream CtCDPI_ends = pablo.Mask(1,0);
454    stream ctCDPI_mask = pablo.Mask(1,0);
455    stream v = (lex.LAngle | lex.Hyphen);
456    stream w = (lex.Hyphen | lex.QMark);
457    stream v1 = pablo.AdvanceN(v, 1);
458    stream w1 = pablo.AdvanceN(w, 1);
459    stream LAngle_scope = (v1 & (~ w1));
460    stream PI_opener = (LAngle_scope & lex.QMark);
461    stream CtCD_opener = (LAngle_scope & lex.Exclam);
462    stream CtCDPI_opener = (PI_opener | CtCD_opener);
463    stream CD_closer = pablo.Mask(1,0);
464    stream DoubleHyphen = ((v1 & w1) & lex.Hyphen);
465    if (lex.RBracket) {
466        stream DoubleRBracket = (pablo.Advance(lex.RBracket) & lex.RBracket);
467        CD_closer = (pablo.Advance(DoubleRBracket) & lex.RAngle);
468    }
469    stream PI_closer = ((w1 & (~ v1)) & lex.RAngle);
470    stream CtCDPI_Cursor = pablo.ScanToFirst(CtCDPI_opener);
471    while (CtCDPI_Cursor) {
472        CtCDPI_starts |= CtCDPI_Cursor;
473        stream PI_Cursor = (CtCDPI_Cursor & PI_opener);
474        stream CD_Ct_Cursor = pablo.Advance((CtCDPI_Cursor & (~ PI_Cursor)));
475        stream CD_Cursor = (CD_Ct_Cursor & lex.LBracket);
476        stream Ct_Cursor = (CD_Ct_Cursor & lex.Hyphen);
477        if (PI_Cursor) {
478            ctCDPI_Callouts.PI_starts |= PI_Cursor;
479            PI_Cursor = pablo.Advance(PI_Cursor);
480            ctCDPI_Callouts.PI_name_starts |= PI_Cursor;
481            stream PI_name_end = pablo.ScanThru(PI_Cursor, lex.NameScan);
482            stream PI_error = (PI_Cursor & PI_name_end);
483            stream PI_noWS = (PI_name_end & (~ lex.WS));
484            PI_error |= ((PI_noWS & (~ lex.QMark)) | (pablo.Advance(PI_noWS) & (~ PI_closer)));
485            pablo.assert_0(PI_error, "Error in PI syntax");
486            ctCDPI_Callouts.PI_name_ends |= PI_name_end;
487            PI_Cursor = pablo.ScanTo(PI_name_end, PI_closer);
488            ctCDPI_Callouts.PI_ends |= PI_Cursor;
489            CtCDPI_ends |= PI_Cursor;
490        }
491        if (CD_Cursor) {
492            ctCDPI_Callouts.CD_starts |= CD_Cursor;
493            CD_Cursor = pablo.ScanTo(CD_Cursor, CD_closer);
494            ctCDPI_Callouts.CD_ends |= CD_Cursor;
495            CtCDPI_ends |= CD_Cursor;
496        }
497        if (Ct_Cursor) {
498            ctCDPI_Callouts.Ct_starts |= Ct_Cursor;
499            Ct_Cursor = pablo.Advance(Ct_Cursor);
500            stream Ct_error = (Ct_Cursor & (~ lex.Hyphen));
501            Ct_Cursor = pablo.Advance(pablo.Advance(Ct_Cursor));
502            Ct_Cursor = pablo.Advance(pablo.ScanTo(Ct_Cursor, DoubleHyphen));
503            pablo.assert_0((Ct_error | (Ct_Cursor & (~ lex.RAngle))), "Error in comment syntax");
504            ctCDPI_Callouts.Ct_ends |= Ct_Cursor;
505            CtCDPI_ends |= Ct_Cursor;
506        }
507        CtCDPI_Cursor = ((PI_Cursor | CD_Cursor) | Ct_Cursor);
508        ctCDPI_mask = pablo.InclusiveSpan(CtCDPI_starts, CtCDPI_ends);
509        pablo.assert_0(pablo.atEOF(ctCDPI_mask), "Error in comment, CDATA or processing instruction syntax");
510        CtCDPI_Cursor = pablo.ScanTo(CtCDPI_Cursor, CtCDPI_opener);
511    }
512    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);
513    marker.LAngle_scope = (LAngle_scope & (~ ctCDPI_mask));
514    marker.Ref_opener = (lex.RefStart & (~ ctCDPI_mask));
515    marker.CD_closer = (CD_closer & (~ ctCDPI_mask));
516}
517
518function void Parse_tags(struct Lex lex, struct Marker marker, struct Tag_Callouts tag_Callouts) {
519    stream EqExpected = pablo.Mask(1,0);
520    stream AttListEnd = pablo.Mask(1,0);
521    stream DQuoteDelim = (lex.DQuote | lex.LAngle);
522    stream SQuoteDelim = (lex.SQuote | lex.LAngle);
523    stream AttListDelim = (lex.Slash | lex.RAngle);
524    tag_Callouts.ElemName_starts = (marker.LAngle_scope & (~ lex.Slash));
525    tag_Callouts.EndTag_marks = (marker.LAngle_scope & lex.Slash);
526    tag_Callouts.ElemName_ends = pablo.ScanThru(tag_Callouts.ElemName_starts, lex.NameScan);
527    stream ParseError = (tag_Callouts.ElemName_starts & tag_Callouts.ElemName_ends);
528    tag_Callouts.AttName_starts = pablo.Mask(1,0);
529    tag_Callouts.AttName_ends = pablo.Mask(1,0);
530    tag_Callouts.AttVal_starts = pablo.Mask(1,0);
531    tag_Callouts.AttVal_ends = pablo.Mask(1,0);
532    if ((tag_Callouts.ElemName_ends & lex.WS)) {
533        stream AfterWS = pablo.ScanThru(tag_Callouts.ElemName_ends, lex.WS);
534        AttListEnd = (AfterWS & AttListDelim);
535        stream AttNameStart = (AfterWS & (~ AttListDelim));
536        while (AttNameStart) {
537            ParseError |= (AttNameStart & (~ lex.NameScan));
538            tag_Callouts.AttName_starts |= AttNameStart;
539            stream AttNameFollow = pablo.ScanThru(AttNameStart, lex.NameScan);
540            tag_Callouts.AttName_ends |= AttNameFollow;
541            if ((AttNameFollow & lex.WS)) {
542                EqExpected = pablo.ScanThru(AttNameFollow, lex.WS);
543            }
544            else {
545                EqExpected = AttNameFollow;
546            }
547            ParseError |= (EqExpected & (~ lex.Equals));
548            stream AttValPos = pablo.AdvanceThenScanThru(EqExpected, lex.WS);
549            tag_Callouts.AttVal_starts |= AttValPos;
550            stream DQuoteAttVal = (AttValPos & lex.DQuote);
551            stream SQuoteAttVal = (AttValPos & lex.SQuote);
552            stream DQuoteAttEnd = pablo.AdvanceThenScanTo(DQuoteAttVal, DQuoteDelim);
553            stream SQuoteAttEnd = pablo.AdvanceThenScanTo(SQuoteAttVal, SQuoteDelim);
554            stream AttValEnd = (DQuoteAttEnd | SQuoteAttEnd);
555            ParseError |= ((AttValPos | AttValEnd) & (~ (lex.DQuote | lex.SQuote)));
556            stream AttValFollow = pablo.Advance(AttValEnd);
557            tag_Callouts.AttVal_ends |= AttValFollow;
558            if ((AttValFollow & lex.WS)) {
559                AfterWS = pablo.ScanThru(AttValFollow, lex.WS);
560                AttListEnd |= (AfterWS & AttListDelim);
561                AttNameStart = (AfterWS & (~ AttListDelim));
562            }
563            else {
564                AttListEnd |= (AttValFollow & AttListDelim);
565                AttNameStart = (AttValFollow & (~ AttListDelim));
566            }
567            ParseError |= (AttValFollow & AttNameStart);
568        }
569    }
570    else {
571        AttListEnd = (tag_Callouts.ElemName_ends & AttListDelim);
572        ParseError |= (tag_Callouts.ElemName_ends & (~ AttListDelim));
573    }
574    stream STagEnds = (AttListEnd & lex.RAngle);
575    tag_Callouts.EmptyTag_marks = pablo.Advance((AttListEnd & lex.Slash));
576    ParseError |= (tag_Callouts.EmptyTag_marks & (~ lex.RAngle));
577    stream EndTagEnds = pablo.AdvanceThenScanThru(tag_Callouts.EndTag_marks, lex.NameScan);
578    if ((EndTagEnds & lex.WS)) {
579        EndTagEnds = pablo.ScanThru(EndTagEnds, lex.WS);
580    }
581    ParseError |= (EndTagEnds & (~ lex.RAngle));
582    pablo.assert_0(ParseError, "Tag parsing error found");
583    tag_Callouts.AttVal_spans = pablo.SpanUpTo(tag_Callouts.AttVal_starts, tag_Callouts.AttVal_ends);
584}
585
586function void Parse_refs(struct Lex lex, struct Marker marker, struct Ref_Callouts ref_Callouts) {
587    ref_Callouts.GenRef_starts = pablo.Mask(1,0);
588    ref_Callouts.GenRef_ends = pablo.Mask(1,0);
589    ref_Callouts.DecRef_starts = pablo.Mask(1,0);
590    ref_Callouts.DecRef_ends = pablo.Mask(1,0);
591    ref_Callouts.HexRef_starts = pablo.Mask(1,0);
592    ref_Callouts.HexRef_ends = pablo.Mask(1,0);
593    stream ref_error = pablo.Mask(1,0);
594    if (marker.Ref_opener) {
595        stream Ref_scope = pablo.Advance(marker.Ref_opener);
596        stream NumRef2 = (Ref_scope & lex.Hash);
597        ref_Callouts.GenRef_starts = (Ref_scope & (~ lex.Hash));
598        stream NumRef3 = pablo.Advance(NumRef2);
599        stream HexRef3 = (NumRef3 & lex.x);
600        ref_Callouts.DecRef_starts = (NumRef3 & (~ lex.x));
601        ref_Callouts.HexRef_starts = pablo.Advance(HexRef3);
602        ref_Callouts.GenRef_ends = pablo.ScanThru(ref_Callouts.GenRef_starts, lex.NameScan);
603        ref_Callouts.DecRef_ends = pablo.ScanThru(ref_Callouts.DecRef_starts, lex.Digit);
604        ref_Callouts.HexRef_ends = pablo.ScanThru(ref_Callouts.HexRef_starts, lex.Hex);
605        stream ref_error1 = (ref_Callouts.DecRef_starts & (~ lex.Digit));
606        stream ref_error2 = (ref_Callouts.HexRef_starts & (~ lex.Hex));
607        stream ref_ends = ((ref_Callouts.GenRef_ends | ref_Callouts.DecRef_ends) | ref_Callouts.HexRef_ends);
608        stream ref_error3 = (ref_ends & (~ lex.Semicolon));
609        pablo.assert_0(((ref_error1 | ref_error2) | ref_error3), "Reference error found");
610    }
611}
612
613function void 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) {
614    stream PI_names = pablo.SpanUpTo(ctCDPI_Callouts.PI_name_starts, ctCDPI_Callouts.PI_name_ends);
615    stream GenRefs = pablo.SpanUpTo(ref_Callouts.GenRef_starts, ref_Callouts.GenRef_ends);
616    stream ElemNames = pablo.SpanUpTo(tag_Callouts.ElemName_starts, tag_Callouts.ElemName_ends);
617    stream AttNames = pablo.SpanUpTo(tag_Callouts.AttName_starts, tag_Callouts.AttName_ends);
618    stream qname_stream = (ElemNames | AttNames);
619    stream ncname_stream = (PI_names | GenRefs);
620    stream name_stream = (qname_stream | ncname_stream);
621    stream name_start = (name_stream & (~ pablo.Advance(name_stream)));
622    stream name_cursor = (name_stream & (~ pablo.Advance(name_stream)));
623    stream void_prefix_err = (name_cursor & lex.Colon);
624    stream namespace_sep = (pablo.ScanThru(name_cursor, (lex.NameScan & (~ lex.Colon))) & lex.Colon);
625    stream local_part_start = pablo.Advance(namespace_sep);
626    stream local_part_err = (local_part_start & (~ lex.NameScan));
627    stream colon2_err = (pablo.ScanThru(local_part_start, (lex.NameScan & (~ lex.Colon))) & lex.Colon);
628    stream ncname_err = (ncname_stream & lex.Colon);
629    pablo.assert_0((((void_prefix_err | local_part_err) | colon2_err) | ncname_err), "name syntax error");
630    check_streams.non_ascii_name_starts = (name_start & (~ lex.ASCII_name_start));
631    check_streams.non_ascii_names = (((name_stream & (~ name_start)) & (~ lex.ASCII_name_char)) & (~ u8.suffix));
632}
633
634function void Do_check_streams(struct Marker marker, struct Tag_Callouts tag_Callouts, struct Check_streams check_streams) {
635    pablo.assert_0((marker.CD_closer & (~ tag_Callouts.AttVal_spans)), "Error: ]]> in text");
636    check_streams.tag_marks = (((tag_Callouts.EmptyTag_marks | tag_Callouts.ElemName_starts) | tag_Callouts.EndTag_marks) | tag_Callouts.AttName_starts);
637    check_streams.name_follows = (tag_Callouts.ElemName_ends | tag_Callouts.AttName_ends);
638    check_streams.att_refs = (tag_Callouts.AttVal_spans & marker.Ref_opener);
639}
Note: See TracBrowser for help on using the repository browser.