Changeset 1265 for proto/pebble


Ignore:
Timestamp:
Aug 3, 2011, 12:05:47 PM (8 years ago)
Author:
shermer
Message:

Trying to make xwlwf.pbl compliant with v0.6.4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/pebble/trunk/inputs/xmlwf.pbl

    r1246 r1265  
    77//
    88
    9 // note: user structs are not handled by pebble yet. 
    10 //       so these two structs do nothing.
    11 //
    12 struct u8 {
    13         xEF_scope,
    14         xBF,
    15         id3,
    16         id4,
    17 }
    18 struct control {        // why no FF in control?
     9struct Control {        // why no FF in control?
    1910  x00_x1F,
    2011  CR,
     
    5445
    5546macro normalize_line_breaks {
    56         CRLF = "\r\n"
     47        new<Control> control
     48        control.CRLF = "\r\n"
    5749       
    5850        # pebble converts a$x to a[x].
     
    7365}
    7466
     67struct CtCDPI_callouts {
     68        CD_span,        // def, no use
     69        Ct_span,        // def, no use
     70        PI_span,        // def, no use
     71        PI_name,        // def, no use
     72        CtCDPI_mask,            // used a fair amount.
     73        x_error,
     74        Misc_mask,
     75}
    7576macro parse_CtCDPI {
    76         CD_span = 0
    77         Ct_span = 0
    78         PI_mask = 0
    79         PI_name = 0
    80         CtCDPI_mask = 0
    81         x_error = 0
    82        
     77        new<CtCDPI_callouts> callouts
     78
    8379        PI_starts = 0
    8480        PI_ends = 0
     
    9793        CD_end_scan = ~CD_end & EOF_mask
    9894        PI_end_scan = ~PI_end & EOF_mask
    99         //
     95       
    10096        // Initiate the scan
    10197        CtCDPI_Cursor = 1
     
    114110               
    115111                Ct_Cursor >=
    116                 Ct_errors |= Ct_Cursor & ~ "-"
     112                Ct_errors |= Ct_Cursor & ~ [^-]
    117113                Ct_Cursor >=
    118114                Ct_end_scan |= Ct_Cursor
     
    144140       
    145141        callouts.CtCDPI_mask |= CtCDPI_starts <> >(CD_ends | Ct_ends | PI_ends)
    146         callouts.error = Ct_errors | Ct_ends & [^>]
    147         callouts.error |= >(PI_name_ends &~ whitespace) &~ PI_end
    148         callouts.error |= PI_namestarts & PI_name_ends
     142    callouts.x_error = Ct_errors | Ct_ends & [^>]
     143    callouts.x_error |= >(PI_name_ends &~ whitespace) &~ PI_end
     144    callouts.x_error |= PI_namestarts & PI_name_ends
    149145
    150146        // If any of the Comment, CDATA or PI markups are unterminated, it is an error.
    151         callouts.error |= callouts.CtCDPI_mask &~ EOF_mask
     147        callouts.x_error |= callouts.CtCDPI_mask &~ EOF_mask
    152148        callouts.Misc_mask = whitespace | [<] | ( (Ct_starts | PI_starts) <> >(Ct_ends | PI_ends)) | CtCDPI_starts
    153149}
    154150
    155 
     151struct RefCallouts {
     152        GenRefs,
     153        DecRefs,
     154        HexRefs,
     155        delmask,
     156}
    156157macro parse_refs {
    157         GenRefs = 0
    158         DecRefs = 0
    159         HexRefs = 0
    160         delmask = 0
    161 #       error = 0
     158        new<RefCallouts> refCallouts
    162159
    163160    GenRef2 = "&[^#]"
     
    181178        error <<malformed character reference>>
    182179   
    183         CallOuts.GenRefs = GenRef2 <> GenRefEnds 
    184         CallOuts.DecRefs = DecRef3 <> DecRefEnds 
    185         CallOuts.HexRefs = HexRef4 <> HexRefEnds 
     180        refCallouts.GenRefs = GenRef2 <> GenRefEnds 
     181        refCallouts.DecRefs = DecRef3 <> DecRefEnds 
     182        refCallouts.HexRefs = HexRef4 <> HexRefEnds 
    186183
    187184        # Mark references for deletion, but leave the trailing semicolon as
    188185        # the point for insertion of the "expansion" text (most often a
    189186        # single character).
    190         CallOuts.delmask = RefStart <> (GenRefEnds | DecRefEnds | HexRefEnds)
    191 }
    192 
     187        refCallouts.delmask = RefStart <> (GenRefEnds | DecRefEnds | HexRefEnds)
     188}
     189
     190struct TagCallouts {
     191        ElemNames,
     192        AttNames,
     193        AttVals,
     194        Tags,
     195        EmptyTagMarks,
     196        EndTags,
     197        x_error,
     198}
    193199
    194200macro parse_tags {
    195         ElemNames = 0
    196         AttNames = 0
    197         AttVals = 0
    198         Tags = 0
    199         EmptyTagEnds = 0
    200         EndTags = 0
    201 #       error = 0
    202        
     201        new<TagCallouts> tagCallouts
     202
    203203        # Start the parallel parsing by inspecting the character
    204204        # after the opening [<] of a tag.
     
    214214        # Mark any occurrences of null names as errors.
    215215        ParseError = ElemNamePositions &~ nameScan
    216         callouts.ElemNames = ElemNamePositions <> ElemNameFollows
     216        tagCallouts.ElemNames = ElemNamePositions <> ElemNameFollows
    217217       
    218218        # Initialize the accumulators for attribute name and value positions.
     
    265265        # No more attribute values to process when AttNameStart == 0.
    266266
    267         callouts.AttNames = AttNameStarts <> AttNameFollows
    268         callouts.AttVals  = AttValStarts <> AttValFollows
     267        tagCallouts.AttNames = AttNameStarts <> AttNameFollows
     268        tagCallouts.AttVals  = AttValStarts <> AttValFollows
    269269        STagEnds = AttListEnd & [>]
    270270       
    271271        # Mark any [/] characters found as the ends of empty element tags.
    272         callouts.EmptyTagMarks = >AttListEnd & [/]
    273         callouts.Tags = ElemNamePositions <> (STagEnds | callouts.EmptyTagMarks)
     272        tagCallouts.EmptyTagMarks = >AttListEnd & [/]
     273        tagCallouts.Tags = ElemNamePositions <> (STagEnds | tagCallouts.EmptyTagMarks)
    274274
    275275        # Check for errors.
     
    279279        ParseError |= AttValStarts & [^'"]
    280280        ParseError |= AttValEnds & [^'"]
    281         ParseError |= callouts.EmptyTagMarks & [^>]
     281        ParseError |= tagCallouts.EmptyTagMarks & [^>]
    282282        if ParseError not allzero
    283283                error <<Attribute parsing error>>
     
    286286        EndTagEnds = >EndTagSeconds +> nameScan +> whitespace
    287287        ParseError |= EndTagEnds & [^>]
    288         callouts.EndTags = EndTagSeconds <> EndTagEnds
    289         callouts.error = ParseError
     288        tagCallouts.EndTags = EndTagSeconds <> EndTagEnds
     289        tagCallouts.x_error = ParseError
    290290}
    291291
    292292
    293293macro validate_no_CD_end {
    294          if CD_end & ~(markup1.CtCDPI_mask | tags.Tags) not allzero
     294         if CD_end & ~(callouts.CtCDPI_mask | tagCallouts.Tags) not allzero
    295295                error <<unterminated CDATA block>>                              #TS: just a guess
    296296}
     
    343343
    344344        # All remaining [<] must be tag start characters; parse tags.
    345         expand parse_tags # (lex, markup1.CtCDPI_mask, EOF_mask)
     345        expand parse_tags # (lex, callouts.CtCDPI_mask, EOF_mask)
    346346
    347347        # All remaining "&" must be reference start characters; parse them.
    348         expand parse_refs  # (lex, markup1.CtCDPI_mask)
     348        expand parse_refs  # (lex, callouts.CtCDPI_mask)
    349349
    350350        # Ensure that no occurrence of ]]> occurs outside of markup.
    351         expand validate_no_CD_end # (lex, markup1, tags)
     351        expand validate_no_CD_end # (lex, callouts, tagCallouts)
    352352
    353353        # Convert to UTF-16 bit streams.
     
    355355
    356356        # Consolidate and check for errors
    357         xerror = u8.error | xmlchar_error | markup1.error | tags.error | CD_end_error | refs.error
     357        xerror = xmlchar_error | callouts.x_error | tagCallouts.x_error | CD_end_error
    358358
    359359        # Consolidate the deletion_masks
    360         delmask = CRLF | refs.delmask | u16delmask # | markup1.CDATA_delimiters
    361 
    362 #       return (markup1, tags, refs, u16hi, u16lo, delmask, error, lex, u16delmask, EOF_mask)
    363 }
    364 
     360        delmask = control.CRLF | refCallouts.delmask # | u16delmask # | callouts.CDATA_delimiters
     361
     362#       return (callouts, tagCallouts, refCallouts, u16hi, u16lo, delmask, xerror, lex, u16delmask, EOF_mask)
     363}
     364
Note: See TracChangeset for help on using the changeset viewer.