Changeset 860 for proto/parabix2


Ignore:
Timestamp:
Jan 2, 2011, 9:24:38 AM (9 years ago)
Author:
cameron
Message:

Reorganize bitstream for CtCDPI processing/call-out.

Location:
proto/parabix2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/pablo_template.c

    r858 r860  
    308308        }
    309309         
    310         if (bitblock_has_bit(PI_namestarts)){
    311           StreamScan((ScanBlock *) &PI_namestarts, sizeof(BitBlock)/sizeof(ScanBlock), PIName_check);
    312         }
    313        
    314         if (bitblock_has_bit(CD_starts)){
    315           StreamScan((ScanBlock *) &CD_starts, sizeof(BitBlock)/sizeof(ScanBlock), CD_check);
     310        if (bitblock_has_bit(ctCDPI_Callouts.PI_name_starts)){
     311          StreamScan((ScanBlock *) &ctCDPI_Callouts.PI_name_starts, sizeof(BitBlock)/sizeof(ScanBlock), PIName_check);
     312        }
     313       
     314        if (bitblock_has_bit(ctCDPI_Callouts.CD_starts)){
     315          StreamScan((ScanBlock *) &ctCDPI_Callouts.CD_starts, sizeof(BitBlock)/sizeof(ScanBlock), CD_check);
    316316        }
    317317       
     
    362362        }
    363363       
    364         if (bitblock_has_bit(PI_namestarts)){
    365           StreamScan((ScanBlock *) &PI_namestarts, sizeof(BitBlock)/sizeof(ScanBlock), PIName_check);
    366         }
    367        
    368         if (bitblock_has_bit(CD_starts)){
    369           StreamScan((ScanBlock *) &CD_starts, sizeof(BitBlock)/sizeof(ScanBlock), CD_check);
     364        if (bitblock_has_bit(ctCDPI_Callouts.PI_name_starts)){
     365          StreamScan((ScanBlock *) &ctCDPI_Callouts.PI_name_starts, sizeof(BitBlock)/sizeof(ScanBlock), PIName_check);
     366        }
     367       
     368        if (bitblock_has_bit(ctCDPI_Callouts.CD_starts)){
     369          StreamScan((ScanBlock *) &ctCDPI_Callouts.CD_starts, sizeof(BitBlock)/sizeof(ScanBlock), CD_check);
    370370        }
    371371       
  • proto/parabix2/parabix2_pablo.py

    r859 r860  
    4646
    4747class Lex (BitStreamSet):
    48   x00_x1F = 0
    49   CR = 0
    50   LF = 0
    51   HT = 0
    52   SP = 0
    53   CRLF = 0
    54   RefStart = 0
    55   Semicolon = 0 
    56   Colon = 0
    57   LAngle = 0
    58   RAngle = 0
    59   LBracket = 0
    60   RBracket = 0
    61   Exclam = 0
    62   QMark = 0
    63   Hyphen = 0
    64   Equals = 0
    65   SQuote = 0
    66   DQuote = 0
    67   Slash = 0
    68   Hash = 0
    69   x = 0
    70   ASCII_name_start = 0
    71   ASCII_name_char = 0
    72   NameScan = 0
    73   Digit = 0
    74   Hex = 0
    75   WS = 0
    76   PI_start = 0
    77   CtCD_start = 0
    78   EndTag_start = 0
    79   CD_end = 0
    80   DoubleHyphen = 0
    81   PI_end = 0
    82   CtCDPI_start = 0
     48        x00_x1F = 0
     49        CR = 0
     50        LF = 0
     51        HT = 0
     52        SP = 0
     53        CRLF = 0
     54        RefStart = 0
     55        Semicolon = 0 
     56        Colon = 0
     57        LAngle = 0
     58        RAngle = 0
     59        LBracket = 0
     60        RBracket = 0
     61        Exclam = 0
     62        QMark = 0
     63        Hyphen = 0
     64        Equals = 0
     65        SQuote = 0
     66        DQuote = 0
     67        Slash = 0
     68        Hash = 0
     69        x = 0
     70        ASCII_name_start = 0
     71        ASCII_name_char = 0
     72        NameScan = 0
     73        Digit = 0
     74        Hex = 0
     75        WS = 0
     76        PI_start = 0
     77        CtCD_start = 0
     78        EndTag_start = 0
     79        CD_end = 0
     80        DoubleHyphen = 0
     81        PI_end = 0
     82        CtCDPI_start = 0
    8383
    8484class Scope1 (BitStreamSet):
    85   RefStart = 0
    86   LAngle = 0
    87   Hyphen = 0
    88   QMark = 0
    89   RBracket = 0
    90 
    91 class cT_callouts:
    92         CD_span = 0
    93         Ct_span = 0
    94         PI_mask = 0
    95         PI_name = 0
     85        RefStart = 0
     86        LAngle = 0
     87        Hyphen = 0
     88        QMark = 0
     89        RBracket = 0
     90
     91class ctCDPI_Callouts(BitStreamSet):
     92        Ct_starts = 0
     93        Ct_ends = 0
     94        CD_starts = 0
     95        CD_ends = 0
     96        PI_starts = 0
     97        PI_name_starts = 0
     98        PI_name_ends = 0
     99        PI_ends = 0
    96100        CtCDPI_mask = 0
    97101        error = 0
     102
    98103
    99104class refs:
     
    303308        lex.PI_end = scope1.QMark & lex.RAngle
    304309
    305        
    306         # THE FOLLOWING FUNCTIONAL CALL IS MANUALLY INLINED
    307         # Parse all comments, CDATA sections and processing instructions.
    308         #markup1 = parse_CtCDPI(lex, EOF_mask)
    309         #cT_callouts = CtCDPI_callouts()
    310         cT_callouts.PI_name = 0
    311         PI_starts = 0
    312         PI_ends = 0
    313         Ct_starts = 0
    314         Ct_ends = 0
    315         CD_starts = 0
    316         CD_ends = 0
     310        ctCDPI_Callouts.Ct_starts = 0
     311        ctCDPI_Callouts.Ct_ends = 0
     312        ctCDPI_Callouts.CD_starts = 0
     313        ctCDPI_Callouts.CD_ends = 0
     314        ctCDPI_Callouts.PI_starts = 0
     315        ctCDPI_Callouts.PI_name_starts = 0
     316        ctCDPI_Callouts.PI_name_ends = 0
     317        ctCDPI_Callouts.PI_ends = 0
     318        ctCDPI_Callouts.CtCDPI_mask = 0
     319        ctCDPI_Callouts.error = 0
     320
    317321        CtCDPI_starts = 0
    318         PI_namestarts = 0
    319         PI_name_ends = 0
    320322
    321323        # Scanning streams
     
    334336                CD_Ct_Cursor = bitutil.Advance(CtCDPI_Cursor & ~PI_Cursor)
    335337                CD_Cursor = CD_Ct_Cursor & lex.LBracket
    336                 #Ct_Cursor = bitutil.Advance(CD_Ct_Cursor & lex.Hyphen)
    337338                Ct_Cursor = CD_Ct_Cursor & lex.Hyphen
    338                 PI_starts |= PI_Cursor
    339                 CD_starts |= CD_Cursor
    340                 Ct_starts |= Ct_Cursor
     339                ctCDPI_Callouts.PI_starts |= PI_Cursor
     340                ctCDPI_Callouts.CD_starts |= CD_Cursor
     341                ctCDPI_Callouts.Ct_starts |= Ct_Cursor
    341342                Ct_Cursor = bitutil.Advance(Ct_Cursor) 
    342343                Ct_errors |= Ct_Cursor & ~ lex.Hyphen
     
    345346                #PI_Cursor = bitutil.ScanThru(PI_Cursor, PI_end_scan)
    346347                PI_Cursor = bitutil.Advance(PI_Cursor)
    347                 PI_namestarts |= PI_Cursor
     348                ctCDPI_Callouts.PI_name_starts |= PI_Cursor
    348349                PI_name_end = bitutil.ScanThru(PI_Cursor, lex.NameScan)
    349                 PI_name_ends |= PI_name_end
    350                 cT_callouts.PI_name |= PI_name_end - PI_Cursor
     350                ctCDPI_Callouts.PI_name_ends |= PI_name_end
    351351                PI_Cursor = bitutil.ScanThru(PI_name_end, PI_end_scan)
    352352                CD_Cursor = bitutil.ScanThru(CD_Cursor, CD_end_scan)
    353353                Ct_Cursor = bitutil.Advance(bitutil.ScanThru(Ct_Cursor, Ct_end_scan))
    354                 PI_ends |= PI_Cursor
    355                 CD_ends |= CD_Cursor
    356                 Ct_ends |= Ct_Cursor
     354                ctCDPI_Callouts.PI_ends |= PI_Cursor
     355                ctCDPI_Callouts.CD_ends |= CD_Cursor
     356                ctCDPI_Callouts.Ct_ends |= Ct_Cursor
    357357                CtCDPI_Cursor = PI_Cursor | CD_Cursor | Ct_Cursor
    358358                CtCDPI_Cursor = bitutil.ScanThru(CtCDPI_Cursor, CtCDPI_scan)
    359359                CtCDPI_Cursor &= EOF_mask
    360360       
    361                 cT_callouts.CtCDPI_mask = bitutil.Advance(CD_ends | Ct_ends | PI_ends) - CtCDPI_starts
    362                 #cT_callouts.error = Ct_ends & ~lex.RAngle | Ct_starts & ~ lex.Hyphen
    363                 cT_callouts.error = Ct_errors | Ct_ends & ~lex.RAngle
    364                 cT_callouts.error |= bitutil.Advance(PI_name_ends & ~ lex.WS) & ~ lex.PI_end
    365                 cT_callouts.error |= PI_namestarts & PI_name_ends
     361                ctCDPI_Callouts.CtCDPI_mask = bitutil.Advance(ctCDPI_Callouts.CD_ends | ctCDPI_Callouts.Ct_ends | ctCDPI_Callouts.PI_ends) - CtCDPI_starts
     362                #ctCDPI_Callouts.error = Ct_ends & ~lex.RAngle | Ct_starts & ~ lex.Hyphen
     363                ctCDPI_Callouts.error = Ct_errors | ctCDPI_Callouts.Ct_ends & ~lex.RAngle
     364                ctCDPI_Callouts.error |= bitutil.Advance(ctCDPI_Callouts.PI_name_ends & ~ lex.WS) & ~ lex.PI_end
     365                ctCDPI_Callouts.error |= ctCDPI_Callouts.PI_name_starts & ctCDPI_Callouts.PI_name_ends
    366366                # If any of the Comment, CDATA or PI markups are unterminated, it is an error.
    367                 cT_callouts.error |= cT_callouts.CtCDPI_mask &~ EOF_mask
     367                ctCDPI_Callouts.error |= ctCDPI_Callouts.CtCDPI_mask &~ EOF_mask
    368368               
    369         Misc_mask = (lex.WS | lex.LAngle | (bitutil.Advance(Ct_ends | PI_ends) - (Ct_starts | PI_starts)) | CtCDPI_starts) & EOF_mask
    370         # End of loop: no remaining CtCDPI_Cursor
    371        
    372         ########## END OF MANUAL INLINING
    373        
    374         # THE FOLLOWING FUNCTIONAL CALL IS MANUALLY INLINED
    375         # All remaining "<" must be tag start characters; parse tags.
    376         #tags = parse_tags(lex, cT_callouts.CtCDPI_mask, EOF_mask)
     369        Misc_mask = (lex.WS | lex.LAngle | (bitutil.Advance(ctCDPI_Callouts.Ct_ends | ctCDPI_Callouts.PI_ends) - (ctCDPI_Callouts.Ct_starts | ctCDPI_Callouts.PI_starts)) | CtCDPI_starts) & EOF_mask
    377370
    378371        #callouts = tag_callouts()
     
    385378        # Start the parallel parsing by inspecting the character
    386379        # after the opening "<" of a tag.
    387         LAngleFollow = scope1.LAngle &~ cT_callouts.CtCDPI_mask
     380        LAngleFollow = scope1.LAngle &~ ctCDPI_Callouts.CtCDPI_mask
    388381        ElemNamePositions = LAngleFollow & ~lex.Slash
    389382        EndTagSeconds = LAngleFollow & lex.Slash
     
    399392       
    400393        # Initialize the accumulators for attribute name and value positions.
    401         AttNameStarts = 0 
     394        Attname_starts = 0 
    402395        AttNameFollows = 0
    403396        EqToCheck = 0
     
    419412        # start tag, plus one.
    420413        while AttNameStart:
    421                 AttNameStarts |= AttNameStart
     414                Attname_starts |= AttNameStart
    422415                AttNameFollow = bitutil.ScanThru(AttNameStart, lex.NameScan)
    423416                AttNameFollows |= AttNameFollow
     
    441434        # No more attribute values to process when AttNameStart == 0.
    442435        # Not needed for xmlwf
    443         callouts.AttNames = AttNameFollows - AttNameStarts
     436        callouts.AttNames = AttNameFollows - Attname_starts
    444437        callouts.AttVals = AttValFollows - AttValStarts
    445438        STagEnds = AttListEnd & lex.RAngle
     
    449442       
    450443        # Check for errors.
    451         ParseError |= AttValFollows & AttNameStarts # No intervening WS.
    452         ParseError |= AttNameStarts & AttNameFollows # Null AttName
     444        ParseError |= AttValFollows & Attname_starts # No intervening WS.
     445        ParseError |= Attname_starts & AttNameFollows # Null AttName
    453446        ParseError |= EqToCheck & ~lex.Equals # = not found where expected.
    454447        ParseError |= AttValStarts & ~ (lex.DQuote | lex.SQuote)
     
    468461
    469462        # All remaining "&" must be reference start characters; parse them.
    470         # INLINED: refs = parse_refs(lex, cT_callouts.CtCDPI_mask)
     463        # INLINED: refs = parse_refs(lex, ctCDPI_Callouts.CtCDPI_mask)
    471464        refs.GenRefs = 0
    472465        refs.error = 0
     
    475468        DecRef3 = 0
    476469        HexRef4 = 0
    477         Ref1 = lex.RefStart &~ cT_callouts.CtCDPI_mask
     470        Ref1 = lex.RefStart &~ ctCDPI_Callouts.CtCDPI_mask
    478471        if Ref1:
    479472                scope1.RefStart = bitutil.Advance(Ref1)
     
    504497
    505498        # Ensure that no occurrence of ]]> occurs outside of markup.
    506         #CD_end_error = validate_no_CD_end(lex, cT_callouts, callouts)
    507         CD_end_error = lex.CD_end & ~(cT_callouts.CtCDPI_mask | callouts.Tags)
     499        #CD_end_error = validate_no_CD_end(lex, ctCDPI_Callouts, callouts)
     500        CD_end_error = lex.CD_end & ~(ctCDPI_Callouts.CtCDPI_mask | callouts.Tags)
    508501       
    509502
     
    511504        #name and name start checking streams
    512505        qname_stream =  callouts.ElemNames | callouts.AttNames
    513         ncname_stream = cT_callouts.PI_name | refs.GenRefs
     506        ncname_stream = ctCDPI_Callouts.PI_name_ends - ctCDPI_Callouts.PI_name_starts | refs.GenRefs
    514507        name_stream = qname_stream | ncname_stream
    515508        name_start = name_stream &~ bitutil.Advance(name_stream)
     
    529522       
    530523        # Consolidate and check for errors
    531         error_mask = u8.error | xmlchar_error | cT_callouts.error | callouts.error | CD_end_error | refs.error | namespace_error
    532 
    533 
    534         #return (cT_callouts, callouts, refs, u16hi, u16lo, delmask, error, lex, u16delmask, EOF_mask)
    535         tag_marks = callouts.EmptyTagMarks | LAngleFollow | AttNameStarts
     524        error_mask = u8.error | xmlchar_error | ctCDPI_Callouts.error | callouts.error | CD_end_error | refs.error | namespace_error
     525
     526
     527        #return (ctCDPI_Callouts, callouts, refs, u16hi, u16lo, delmask, error, lex, u16delmask, EOF_mask)
     528        tag_marks = callouts.EmptyTagMarks | LAngleFollow | Attname_starts
    536529        NameFollows = ElemNameFollows | AttNameFollows
    537530        AttRef = callouts.AttVals & Ref2
Note: See TracChangeset for help on using the changeset viewer.