Ignore:
Timestamp:
Jul 30, 2011, 10:47:52 AM (8 years ago)
Author:
cameron
Message:

Optimize empty-attlist case.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/parabix2_pablo.py

    r1232 r1243  
    411411
    412412        # After the element name, there may or may not be an attlist.
    413         AfterWS = bitutil.ScanThru(tag_Callouts.ElemName_ends, lex.WS)
    414         AttListEnd = AfterWS & AttListDelim
    415         AttNameStart = AfterWS & ~AttListDelim
    416         # At least one WS character is required between ElemNames and AttNames.
    417         ParseError |= tag_Callouts.ElemName_ends & AttNameStart
    418 
    419         #
    420         # The following loop iterates through attributes within a start tag.
    421         # Because all start tags are processed in parallel, the number of
    422         # iterations is the maximum number of attributes found in any one
    423         # start tag, plus one.
    424         while AttNameStart:
    425                 tag_Callouts.AttName_starts |= AttNameStart
    426                 AttNameFollow = bitutil.ScanThru(AttNameStart, lex.NameScan)
    427                 tag_Callouts.AttName_ends |= AttNameFollow
    428                 # Scan through WS to the expected '=' delimiter.
    429                 # EqExpected = bitutil.ScanThru(AttNameFollow, lex.WS)
    430                 # But use if test to optimize.
    431                 if AttNameFollow & lex.WS:
    432                         EqExpected = bitutil.ScanThru(AttNameFollow, lex.WS)
    433                 else: EqExpected = AttNameFollow
    434                 EqToCheck |= EqExpected
    435                 AttValPos = bitutil.ScanThru(EqExpected, EqExpected | lex.WS)
    436                 tag_Callouts.AttVal_starts |= AttValPos
    437                 DQuoteAttVal = AttValPos & lex.DQuote
    438                 SQuoteAttVal = AttValPos & lex.SQuote
    439                 DQuoteAttEnd = bitutil.ScanTo(DQuoteAttVal, DQuoteDelim &~ DQuoteAttVal)
    440                 SQuoteAttEnd = bitutil.ScanTo(SQuoteAttVal, SQuoteDelim &~ SQuoteAttVal)
    441                 AttValEnd = DQuoteAttEnd | SQuoteAttEnd
    442                 AttValEnds |= AttValEnd
    443                 AttValFollow = bitutil.Advance(AttValEnd)
    444                 tag_Callouts.AttVal_ends |= AttValFollow
    445                 AfterWS = bitutil.ScanThru(AttValFollow, lex.WS)
    446                 if AttValFollow & lex.WS:
     413        if tag_Callouts.ElemName_ends & lex.WS:
     414                AfterWS = bitutil.ScanThru(tag_Callouts.ElemName_ends, lex.WS)
     415                AttListEnd = AfterWS & AttListDelim
     416                AttNameStart = AfterWS & ~AttListDelim
     417                #
     418                # The following loop iterates through attributes within a start tag.
     419                # Because all start tags are processed in parallel, the number of
     420                # iterations is the maximum number of attributes found in any one
     421                # start tag, plus one.
     422                while AttNameStart:
     423                        tag_Callouts.AttName_starts |= AttNameStart
     424                        AttNameFollow = bitutil.ScanThru(AttNameStart, lex.NameScan)
     425                        tag_Callouts.AttName_ends |= AttNameFollow
     426                        # Scan through WS to the expected '=' delimiter.
     427                        # EqExpected = bitutil.ScanThru(AttNameFollow, lex.WS)
     428                        # But use if test to optimize.
     429                        if AttNameFollow & lex.WS:
     430                                EqExpected = bitutil.ScanThru(AttNameFollow, lex.WS)
     431                        else: EqExpected = AttNameFollow
     432                        EqToCheck |= EqExpected
     433                        AttValPos = bitutil.ScanThru(EqExpected, EqExpected | lex.WS)
     434                        tag_Callouts.AttVal_starts |= AttValPos
     435                        DQuoteAttVal = AttValPos & lex.DQuote
     436                        SQuoteAttVal = AttValPos & lex.SQuote
     437                        DQuoteAttEnd = bitutil.ScanTo(DQuoteAttVal, DQuoteDelim &~ DQuoteAttVal)
     438                        SQuoteAttEnd = bitutil.ScanTo(SQuoteAttVal, SQuoteDelim &~ SQuoteAttVal)
     439                        AttValEnd = DQuoteAttEnd | SQuoteAttEnd
     440                        AttValEnds |= AttValEnd
     441                        AttValFollow = bitutil.Advance(AttValEnd)
     442                        tag_Callouts.AttVal_ends |= AttValFollow
     443                        #  AfterWS = bitutil.ScanThru(AttValFollow, lex.WS)
     444                        if AttValFollow & lex.WS:
     445                                AfterWS = bitutil.ScanThru(AttValFollow, lex.WS)
     446                        else: AfterWS = AttValFollow
    447447                        AfterWS = bitutil.ScanThru(AttValFollow, lex.WS)
    448                 else: AfterWS = AttValFollow
    449                 AfterWS = bitutil.ScanThru(AttValFollow, lex.WS)
    450                 AttListEnd |= AfterWS & AttListDelim
    451                 AttNameStart = AfterWS & ~AttListDelim
     448                        AttListEnd |= AfterWS & AttListDelim
     449                        AttNameStart = AfterWS & ~AttListDelim
     450        else:
     451                # At least one WS character is required between ElemNames and AttNames.
     452                AttListEnd = tag_Callouts.ElemName_ends & AttListDelim
     453                AttNameStart = tag_Callouts.ElemName_ends & ~AttListDelim
     454                ParseError |= AttNameStart
     455
    452456
    453457        # No more attribute values to process when AttNameStart == 0.
Note: See TracChangeset for help on using the changeset viewer.