Ignore:
Timestamp:
Feb 6, 2011, 11:01:20 AM (8 years ago)
Author:
cameron
Message:

Eliminate Add_multiliterals and associated storage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/parabix2_pablo.py

    r881 r896  
    7878        Hex = 0
    7979        WS = 0
    80         PI_start = 0
    81         CtCD_start = 0
    8280        EndTag_start = 0
    83         CD_end = 0
    8481        DoubleHyphen = 0
    85         PI_end = 0
    86         CtCDPI_start = 0
    8782
    8883class Scope1 ():
     
    9489
    9590class CtCDPI_Callouts():
     91        CD_end = 0
    9692        Ct_starts = 0
    9793        Ct_ends = 0
     
    312308        u8.error |= u8mismatch
    313309       
    314 def Add_multiliterals(scope1, lex):
     310def Add_scope_streams(lex, scope1):
    315311        scope1.LAngle = bitutil.Advance(lex.LAngle)
    316312        scope1.Hyphen = bitutil.Advance(lex.Hyphen)
    317313        scope1.QMark = bitutil.Advance(lex.QMark)
    318         lex.CD_end = 0
    319         if lex.RBracket:
    320                 scope1.RBracket = bitutil.Advance(lex.RBracket)
    321                 lex.CD_end = bitutil.Advance(scope1.RBracket & lex.RBracket) & lex.RAngle
    322         lex.PI_start = scope1.LAngle & lex.QMark
    323         lex.CtCD_start = scope1.LAngle & lex.Exclam
    324         lex.CtCDPI_start = lex.PI_start | lex.CtCD_start
    325         lex.EndTag_start = scope1.LAngle & lex.Slash
    326 
    327         #if lex.CtCDPI_start:
    328         lex.DoubleHyphen = scope1.Hyphen & lex.Hyphen
    329         lex.PI_end = scope1.QMark & lex.RAngle
    330 
    331 def Parse_CtCDPI(ctCDPI_Callouts, lex, masks, post_process):
     314
     315def Parse_CtCDPI(ctCDPI_Callouts, lex, scope1, masks, post_process):
     316        ctCDPI_Callouts.CD_end = 0
    332317        ctCDPI_Callouts.Ct_starts = 0
    333318        ctCDPI_Callouts.Ct_ends = 0
     
    342327        CtCDPI_starts = 0
    343328
     329        if lex.RBracket:
     330                scope1.RBracket = bitutil.Advance(lex.RBracket)
     331                ctCDPI_Callouts.CD_end = bitutil.Advance(scope1.RBracket & lex.RBracket) & lex.RAngle
     332        PI_start = scope1.LAngle & lex.QMark
     333        CtCD_start = scope1.LAngle & lex.Exclam
     334        CtCDPI_start = PI_start | CtCD_start
     335
     336        DoubleHyphen = scope1.Hyphen & lex.Hyphen
     337        PI_end = scope1.QMark & lex.RAngle
     338
     339
    344340        # Scanning streams
    345         CtCDPI_scan = ~lex.CtCDPI_start & masks.EOF_mask
    346         Ct_end_scan = ~lex.DoubleHyphen & masks.EOF_mask
    347         CD_end_scan = ~lex.CD_end & masks.EOF_mask
    348         PI_end_scan = ~lex.PI_end & masks.EOF_mask
     341        CtCDPI_scan = ~CtCDPI_start & masks.EOF_mask
     342        Ct_end_scan = ~DoubleHyphen & masks.EOF_mask
     343        CD_end_scan = ~ctCDPI_Callouts.CD_end & masks.EOF_mask
     344        PI_end_scan = ~PI_end & masks.EOF_mask
    349345        #
    350346        # Initiate the scan
     
    354350        while CtCDPI_Cursor:
    355351                CtCDPI_starts |= CtCDPI_Cursor
    356                 PI_Cursor = CtCDPI_Cursor & lex.PI_start
     352                PI_Cursor = CtCDPI_Cursor & PI_start
    357353                CD_Ct_Cursor = bitutil.Advance(CtCDPI_Cursor & ~PI_Cursor)
    358354                CD_Cursor = CD_Ct_Cursor & lex.LBracket
     
    383379                #ctCDPI_Callouts.error = Ct_ends & ~lex.RAngle | Ct_starts & ~ lex.Hyphen
    384380                ctCDPI_Callouts.error = Ct_errors | ctCDPI_Callouts.Ct_ends & ~lex.RAngle
    385                 ctCDPI_Callouts.error |= bitutil.Advance(ctCDPI_Callouts.PI_name_ends & ~ lex.WS) & ~ lex.PI_end
     381                ctCDPI_Callouts.error |= bitutil.Advance(ctCDPI_Callouts.PI_name_ends & ~ lex.WS) & ~ PI_end
    386382                ctCDPI_Callouts.error |= ctCDPI_Callouts.PI_name_starts & ctCDPI_Callouts.PI_name_ends
    387383                # If any of the Comment, CDATA or PI markups are unterminated, it is an error.
     
    391387
    392388def Parse_tags(lex, scope1, ctCDPI_Callouts, tag_Callouts, masks):
     389
    393390       
    394391        # Delimiters for scans.
     
    541538        xml_char.error |= u8.FFFE_FFFF
    542539
    543         ### Compute XML multiliterals such as <?, </, --, ]]>
    544         Add_multiliterals(scope1, lex)
     540        Add_scope_streams(lex, scope1)
    545541   
    546     # Parse all comments, CDATA sections and processing instructions.
    547         Parse_CtCDPI(ctCDPI_Callouts, lex, masks, post_process)
     542        # Parse all comments, CDATA sections and processing instructions.
     543        Parse_CtCDPI(ctCDPI_Callouts, lex, scope1, masks, post_process)
    548544               
    549545        # All remaining '<' must be tag start characters; parse tags.
     
    554550       
    555551        # Ensure that no occurrence of ]]> occurs outside of markup.
    556         CD_end_error = lex.CD_end & ~(ctCDPI_Callouts.CtCDPI_mask | tag_Callouts.AttVal_spans)
     552        CD_end_error = ctCDPI_Callouts.CD_end & ~(ctCDPI_Callouts.CtCDPI_mask | tag_Callouts.AttVal_spans)
    557553       
    558554        # Validate XML namespaces and generate bit streams to post validate non-ascii range XML names
Note: See TracChangeset for help on using the changeset viewer.