Changeset 862


Ignore:
Timestamp:
Jan 2, 2011, 10:55:38 AM (8 years ago)
Author:
cameron
Message:

Reorganize callouts for start, end and empty tags

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/parabix2_pablo.py

    r861 r862  
    110110        error = 0
    111111
    112 class callouts:
    113         ElemNames = 0
    114         AttNames = 0
    115         AttVals = 0
    116         Tags = 0
    117         EmptyTagMarks = 0
    118         EmptyTagEnds = 0
    119         EndTags = 0
     112class Tag_Callouts(BitStreamSet):
     113        ElemName_starts = 0
     114        ElemName_ends = 0
     115        AttName_starts = 0
     116        AttName_ends = 0
     117        AttVal_starts = 0
     118        AttVal_ends = 0
     119        EmptyTag_marks = 0
     120        EndTag_marks = 0
    120121        error = 0
    121        
    122 
    123122
    124123def main(u8data):
     
    370369        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
    371370
    372         #callouts = tag_callouts()
    373371       
    374372        # Delimiters for scans.
     
    380378        # after the opening "<" of a tag.
    381379        LAngleFollow = scope1.LAngle &~ ctCDPI_Callouts.CtCDPI_mask
    382         ElemNamePositions = LAngleFollow & ~lex.Slash
    383         EndTagSeconds = LAngleFollow & lex.Slash
     380        tag_Callouts.ElemName_starts = LAngleFollow & ~lex.Slash
     381        tag_Callouts.EndTag_marks = LAngleFollow & lex.Slash
    384382       
    385383        # Start Tag/Empty Element Tag Parsing
    386384
    387385        # Advance all cursors by scanning through the tag name.
    388         ElemNameFollows = bitutil.ScanThru(ElemNamePositions, lex.NameScan)
     386        tag_Callouts.ElemName_ends = bitutil.ScanThru(tag_Callouts.ElemName_starts, lex.NameScan)
    389387        # Must have at least one name character for a legal start tag.
    390388        # Mark any occurrences of null names as errors.
    391         ParseError = ElemNamePositions & ElemNameFollows
    392         callouts.ElemNames = ElemNameFollows - ElemNamePositions
     389        ParseError = tag_Callouts.ElemName_starts & tag_Callouts.ElemName_ends
    393390       
    394391        # Initialize the accumulators for attribute name and value positions.
    395         Attname_starts = 0 
    396         AttNameFollows = 0
     392        tag_Callouts.AttName_starts = 0 
     393        tag_Callouts.AttName_ends = 0
    397394        EqToCheck = 0
    398         AttValStarts = 0
     395        tag_Callouts.AttVal_starts = 0
    399396        AttValEnds = 0
    400         AttValFollows = 0
     397        tag_Callouts.AttVal_ends = 0
    401398
    402399        # After the element name, there may or may not be an attlist.
    403         AfterWS = bitutil.ScanThru(ElemNameFollows, lex.WS)
     400        AfterWS = bitutil.ScanThru(tag_Callouts.ElemName_ends, lex.WS)
    404401        AttListEnd = AfterWS & AttListDelim
    405402        AttNameStart = AfterWS & ~AttListDelim
    406403        # At least one WS character is required between ElemNames and AttNames.
    407         ParseError |= ElemNameFollows & AttNameStart
     404        ParseError |= tag_Callouts.ElemName_ends & AttNameStart
    408405
    409406        #
     
    413410        # start tag, plus one.
    414411        while AttNameStart:
    415                 Attname_starts |= AttNameStart
     412                tag_Callouts.AttName_starts |= AttNameStart
    416413                AttNameFollow = bitutil.ScanThru(AttNameStart, lex.NameScan)
    417                 AttNameFollows |= AttNameFollow
     414                tag_Callouts.AttName_ends |= AttNameFollow
    418415                # Scan through WS to the expected '=' delimiter.
    419416                EqExpected = bitutil.ScanThru(AttNameFollow, lex.WS)
    420417                EqToCheck |= EqExpected
    421418                AttValPos = bitutil.ScanThru(EqExpected, EqExpected | lex.WS)
    422                 AttValStarts |= AttValPos
     419                tag_Callouts.AttVal_starts |= AttValPos
    423420                DQuoteAttVal = AttValPos & lex.DQuote
    424421                SQuoteAttVal = AttValPos & lex.SQuote
     
    428425                AttValEnds |= AttValEnd
    429426                AttValFollow = bitutil.Advance(AttValEnd)
    430                 AttValFollows |= AttValFollow
     427                tag_Callouts.AttVal_ends |= AttValFollow
    431428                AfterWS = bitutil.ScanThru(AttValFollow, lex.WS)
    432429                AttListEnd |= AfterWS & AttListDelim
     
    434431
    435432        # No more attribute values to process when AttNameStart == 0.
    436         # Not needed for xmlwf
    437         callouts.AttNames = AttNameFollows - Attname_starts
    438         callouts.AttVals = AttValFollows - AttValStarts
    439433        STagEnds = AttListEnd & lex.RAngle
    440434        # Mark any "/" characters found as the ends of empty element tags.
    441         callouts.EmptyTagMarks = bitutil.Advance(AttListEnd & lex.Slash)
    442         callouts.Tags = (STagEnds | callouts.EmptyTagMarks) - ElemNamePositions
     435        tag_Callouts.EmptyTag_marks = bitutil.Advance(AttListEnd & lex.Slash)
    443436       
    444437        # Check for errors.
    445         ParseError |= AttValFollows & Attname_starts # No intervening WS.
    446         ParseError |= Attname_starts & AttNameFollows # Null AttName
     438        ParseError |= tag_Callouts.AttVal_ends & tag_Callouts.AttName_starts # No intervening WS.
     439        ParseError |= tag_Callouts.AttName_starts & tag_Callouts.AttName_ends # Null AttName
    447440        ParseError |= EqToCheck & ~lex.Equals # = not found where expected.
    448         ParseError |= AttValStarts & ~ (lex.DQuote | lex.SQuote)
     441        ParseError |= tag_Callouts.AttVal_starts & ~ (lex.DQuote | lex.SQuote)
    449442        ParseError |= AttValEnds & ~ (lex.DQuote | lex.SQuote)
    450         ParseError |= callouts.EmptyTagMarks & ~lex.RAngle
     443        ParseError |= tag_Callouts.EmptyTag_marks & ~lex.RAngle
    451444
    452445        # End Tag Parsing
    453         EndTagEnds = bitutil.ScanThru(bitutil.ScanThru(EndTagSeconds, EndTagSeconds | lex.NameScan), lex.WS)
     446        EndTagEnds = bitutil.ScanThru(bitutil.ScanThru(tag_Callouts.EndTag_marks, tag_Callouts.EndTag_marks | lex.NameScan), lex.WS)
    454447        ParseError |= EndTagEnds & ~lex.RAngle
    455         # Not needed for xmlwf
    456         #callouts.EndTags = EndTagEnds - EndTagSeconds
    457         callouts.error = ParseError
    458         ########## END OF MANUAL INLINING
    459 
    460 
    461 
     448        tag_Callouts.error = ParseError
    462449
    463450        # All remaining "&" must be reference start characters; parse them.
     
    493480
    494481
     482        AttVals = tag_Callouts.AttVal_ends - tag_Callouts.AttVal_starts
    495483        # Ensure that no occurrence of ]]> occurs outside of markup.
    496         #CD_end_error = validate_no_CD_end(lex, ctCDPI_Callouts, callouts)
    497         CD_end_error = lex.CD_end & ~(ctCDPI_Callouts.CtCDPI_mask | callouts.Tags)
     484        CD_end_error = lex.CD_end & ~(ctCDPI_Callouts.CtCDPI_mask | AttVals)
    498485       
    499486
     
    502489        PI_names = ctCDPI_Callouts.PI_name_ends - ctCDPI_Callouts.PI_name_starts
    503490        GenRefs = ref_Callouts.GenRef_ends - ref_Callouts.GenRef_starts
    504         qname_stream =  callouts.ElemNames | callouts.AttNames
     491        ElemNames = tag_Callouts.ElemName_ends - tag_Callouts.ElemName_starts
     492        AttNames = tag_Callouts.AttName_ends - tag_Callouts.AttName_starts
     493        qname_stream =  ElemNames | AttNames
    505494        ncname_stream = PI_names | GenRefs
    506495        name_stream = qname_stream | ncname_stream
     
    521510       
    522511        # Consolidate and check for errors
    523         error_mask = u8.error | xmlchar_error | ctCDPI_Callouts.error | callouts.error | CD_end_error | ref_Callouts.error | namespace_error
    524 
    525 
    526         #return (ctCDPI_Callouts, callouts, refs, u16hi, u16lo, delmask, error, lex, u16delmask, EOF_mask)
    527         tag_marks = callouts.EmptyTagMarks | LAngleFollow | Attname_starts
    528         NameFollows = ElemNameFollows | AttNameFollows
    529         AttRef = callouts.AttVals & scope1.RefStart
    530        
     512        error_mask = u8.error | xmlchar_error | ctCDPI_Callouts.error | tag_Callouts.error | CD_end_error | ref_Callouts.error | namespace_error
     513
     514        tag_marks = tag_Callouts.EmptyTag_marks | LAngleFollow | tag_Callouts.AttName_starts
     515        NameFollows = tag_Callouts.ElemName_ends | tag_Callouts.AttName_ends
     516        AttRef = AttVals & scope1.RefStart
     517       
Note: See TracChangeset for help on using the changeset viewer.