source: proto/pebble/trunk/inputs/input-10.pbl @ 1242

Last change on this file since 1242 was 1242, checked in by shermer, 8 years ago

Pebble v0.6.0 initial commit

File size: 1.8 KB
Line 
1
2// first attempt at parabix2.
3
4struct u8 {
5        xEF_scope,
6        xBF,
7        id3,
8        id4,
9}
10
11macro first {
12        ccc = ddd
13        eee = fff
14        while eee not allzero {
15                ggg = hhh
16                iii = jjj
17        }
18}
19macro validate_xmlchar {
20        if "\xEF\xBF[\xBE\xBF]" | ([\x00-\x1F] &~ lex.WS & EOF_mask) not allzero
21                error <<improperly-ended xEFBF, or non-whitespace control character>> 
22}
23
24macro normalize_line_breaks {
25        control.CRLF = "\r\n"
26       
27        # Convert CRs to LFs (flip bits 5, 6 and 7 with xor).
28        basis_bits.bit_5 ^= [\r]
29        basis_bits.bit_6 ^= [\r]
30        basis_bits.bit_7 ^= [\r]
31}
32
33macro add_multiliterals {
34        PI_start = "<?"
35        CtCD_start = "<!"
36        EndTag_start = "</"
37        CD_End = "]]>"
38        DoubleHyphen = "--"
39        PI_end = "?>"
40}
41
42macro parse_CtCDPI {
43        CD_span = 0
44        Ct_span = 0
45       
46        while CtCDPI_Cursor not allzero {
47                CtCDPI_starts |= CtCDPI_Cursor
48                PI_Cursor = CtCDPI_Cursor & "<?"
49                CD_Ct_Cursor = >(CtCDPI_Cursor & ~PI_Cursor)
50                CD_Cursor = CD_Ct_Cursor & [<]
51
52                PI_Cursor = PI_name_end +> PI_end_scan
53                CD_Cursor +>= CD_end_scan
54                Ct_Cursor = >(Ct_Cursor +> Ct_end_scan)
55               
56                PI_ends |= PI_Cursor
57                CD_ends |= CD_Cursor
58                Ct_ends |= Ct_Cursor
59        }
60}
61
62
63macro validate_no_CD_end {
64         e = lex.CD_end & ~(markup1.CtCDPI_mask | tags.Tags)
65}
66
67
68
69defblock main {
70        aaa = bbb
71        expand first
72
73        # Rule out the illegal characters for XML.
74//      expand validate_xmlchar # (u8, control, lex, EOF_mask)
75
76        # Find and normalize bare CR or CRLF combinations.
77//      expand normalize_line_breaks # (control, bit)
78
79        # Compute XML multilterals such as <?, </, --, ]]>.
80//      expand add_multiliterals
81
82        # Parse all comments, CDATA sections and processing instructions.
83//      expand parse_CtCDPI # (lex, EOF_mask)
84       
85        # Ensure that no occurrence of ]]> occurs outside of markup.
86//      expand validate_no_CD_end # (lex, markup1, tags)
87}
88
Note: See TracBrowser for help on using the repository browser.