Changeset 547 for proto/parabix2


Ignore:
Timestamp:
Jul 28, 2010, 6:41:41 PM (9 years ago)
Author:
cameron
Message:

Inline refs and use if optimization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/parabix2_compilable.py

    r528 r547  
    264264        # Error checks
    265265        # At least one digit required for DecRef, one hex digit for HexRef.
    266         Error = DecRef3 &~ lex.Digit
    267         Error |= HexRef4 &~ lex.Hex
     266        error1 = DecRef3 &~ lex.Digit
     267        error2 = HexRef4 &~ lex.Hex
    268268        # Semicolon terminator required (also covers unterminated at EOF).
    269         Error |= (GenRefEnds | DecRefEnds | HexRefEnds) &~ lex.Semicolon
    270         # Not needed for xmlwf 
     269        error3 = (GenRefEnds | DecRefEnds | HexRefEnds) &~ lex.Semicolon
    271270        CallOuts.GenRefs = GenRefEnds - GenRef2
    272         #CallOuts.DecRefs = DecRefEnds - DecRef3
    273         #CallOuts.HexRefs = HexRefEnds - HexRef4
     271        CallOuts.DecRefs = DecRefEnds - DecRef3
     272        CallOuts.HexRefs = HexRefEnds - HexRef4
    274273        # Mark references for deletion, but leave the trailing semicolon as
    275274        # the point for insertion of the "expansion" text (most often a
    276275        # single character).
    277         #CallOuts.delmask = (GenRefEnds | DecRefEnds | HexRefEnds) - lex.RefStart
    278         CallOuts.error = Error
     276        CallOuts.delmask = (GenRefEnds | DecRefEnds | HexRefEnds) - lex.RefStart
     277        CallOuts.error = error1 | error2 | error3
    279278        return CallOuts
    280279
     
    736735
    737736        # All remaining "&" must be reference start characters; parse them.
    738         refs = parse_refs(lex, CT_callouts.CtCDPI_mask)
     737        # INLINED: refs = parse_refs(lex, CT_callouts.CtCDPI_mask)
     738        refs = ref_callouts()
     739        Ref2 = lex.RefStart_scope &~ CT_callouts.CtCDPI_mask
     740        if Ref2:
     741                NumRef2 = Ref2 & lex.Hash
     742                GenRef2 = Ref2 &~ lex.Hash
     743                NumRef3 = bitutil.Advance(NumRef2)
     744                HexRef3 = NumRef3 & lex.x
     745                DecRef3 = NumRef3 &~ lex.x
     746                HexRef4 = bitutil.Advance(HexRef3)
     747                GenRefEnds = bitutil.ScanThru(GenRef2, lex.NameScan)
     748                DecRefEnds = bitutil.ScanThru(DecRef3, lex.Digit)
     749                HexRefEnds = bitutil.ScanThru(HexRef4, lex.Hex)
     750                # Error checks
     751                # At least one digit required for DecRef, one hex digit for HexRef.
     752                error1 = DecRef3 &~ lex.Digit
     753                error2 = HexRef4 &~ lex.Hex
     754                # Semicolon terminator required (also covers unterminated at EOF).
     755                error3 = (GenRefEnds | DecRefEnds | HexRefEnds) &~ lex.Semicolon
     756                refs.GenRefs = GenRefEnds - GenRef2
     757                refs.DecRefs = DecRefEnds - DecRef3
     758                refs.HexRefs = HexRefEnds - HexRef4
     759                # Mark references for deletion, but leave the trailing semicolon as
     760                # the point for insertion of the "expansion" text (most often a
     761                # single character).
     762                #refs.delmask = (GenRefEnds | DecRefEnds | HexRefEnds) - lex.RefStart
     763                refs.error = error1 | error2 | error3
     764
    739765
    740766        # Ensure that no occurrence of ]]> occurs outside of markup.
Note: See TracChangeset for help on using the changeset viewer.