Changeset 528


Ignore:
Timestamp:
Jul 22, 2010, 11:50:11 AM (9 years ago)
Author:
lindanl
Message:

PI target name extraction; error check

Location:
proto/parabix2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/parabix2.py

    r441 r528  
    120120        Ct_span = 0
    121121        PI_mask = 0
     122        PI_name = 0
    122123        CtCDPI_mask = 0
    123124        error = 0
     
    147148        error      : __________________1___________
    148149
     150        >>> demo_CtCDPI("<?PI_target??>")
     151        input data : <?PI_target??>
     152        CD_span    : ______________
     153        Ct_span    : ______________
     154        PI_span    : _111111111111_
     155        CtCDPI_mask: _1111111111111
     156        error      : ____________1__
    149157
    150158
     
    158166        CD_ends = 0
    159167        CtCDPI_starts = 0
     168        PI_name_ends = 0
    160169        # Scanning streams
    161170        CtCDPI_scan = ~(lex.CtCD_start | lex.PI_start) & EOF_mask
     
    179188                Ct_Cursor = bitutil.Advance(Ct_Cursor)
    180189                Ct_end_scan |= Ct_Cursor
    181                 PI_Cursor = bitutil.ScanThru(PI_Cursor, PI_end_scan)
     190                #PI_Cursor = bitutil.ScanThru(PI_Cursor, PI_end_scan)
     191                PI_name_end = bitutil.ScanThru( bitutil.Advance(PI_Cursor), lex.NameScan)
     192                PI_name_ends |= PI_name_end
     193                callouts.PI_name |= PI_name_end - PI_Cursor
     194                PI_Cursor = bitutil.ScanThru(PI_name_end, PI_end_scan)
    182195                CD_Cursor = bitutil.ScanThru(CD_Cursor, CD_end_scan)
    183196                Ct_Cursor = bitutil.Advance(bitutil.ScanThru(Ct_Cursor, Ct_end_scan))
     
    195208        callouts.CtCDPI_mask |= bitutil.Advance(CD_ends | Ct_ends | PI_ends) - CtCDPI_starts
    196209        callouts.error = Ct_ends & ~lex.RAngle | Ct_starts & ~ lex.Hyphen
     210        callouts.error |= bitutil.Advance(PI_name_ends & ~ lex.WS) & ~ lex.PI_end
    197211        # If any of the Comment, CDATA or PI markups are unterminated, it is an error.
    198212        callouts.error |= callouts.CtCDPI_mask &~ EOF_mask
  • proto/parabix2/parabix2_compilable.py

    r518 r528  
    269269        Error |= (GenRefEnds | DecRefEnds | HexRefEnds) &~ lex.Semicolon
    270270        # Not needed for xmlwf 
    271         #CallOuts.GenRefs = GenRefEnds - GenRef2
     271        CallOuts.GenRefs = GenRefEnds - GenRef2
    272272        #CallOuts.DecRefs = DecRefEnds - DecRef3
    273273        #CallOuts.HexRefs = HexRefEnds - HexRef4
     
    591591        CD_ends = 0
    592592        CtCDPI_starts = 0
     593        PI_name_ends = 0
    593594        # Scanning streams
    594595        CtCDPI_scan = ~(lex.CtCD_start | lex.PI_start) & EOF_mask
     
    612613                Ct_Cursor = bitutil.Advance(Ct_Cursor)
    613614                Ct_end_scan |= Ct_Cursor
    614                 PI_Cursor = bitutil.ScanThru(PI_Cursor, PI_end_scan)
     615                #PI_Cursor = bitutil.ScanThru(PI_Cursor, PI_end_scan)
     616                PI_name_end = bitutil.ScanThru( bitutil.Advance(PI_Cursor), lex.NameScan)
     617                PI_name_ends |= PI_name_end
     618                CT_callouts.PI_name |= PI_name_end - PI_Cursor
     619                PI_Cursor = bitutil.ScanThru(PI_name_end, PI_end_scan)
    615620                CD_Cursor = bitutil.ScanThru(CD_Cursor, CD_end_scan)
    616621                Ct_Cursor = bitutil.Advance(bitutil.ScanThru(Ct_Cursor, Ct_end_scan))
     
    629634        CT_callouts.CtCDPI_mask = bitutil.Advance(CD_ends | Ct_ends | PI_ends) - CtCDPI_starts
    630635        CT_callouts.error = Ct_ends & ~lex.RAngle | Ct_starts & ~ lex.Hyphen
     636        CT_callouts.error |= bitutil.Advance(PI_name_ends & ~ lex.WS) & ~ lex.PI_end
    631637        # If any of the Comment, CDATA or PI markups are unterminated, it is an error.
    632638        CT_callouts.error |= CT_callouts.CtCDPI_mask &~ EOF_mask
     
    710716        #callouts.Tags = (STagEnds | callouts.EmptyTagMarks) - ElemNamePositions
    711717       
    712        
    713         name_stream = callouts.ElemNames | callouts.AttNames
    714         name_start = name_stream &~ bitutil.Advance(name_stream)
    715         name_start_check = name_start & ~lex.ASCII_name_start
    716         name_check = (name_stream &~ name_start | nmtoken_stream) & ~lex.ASCII_name_char & ~u8.suffix
    717 
    718718        # Check for errors.
    719719        ParseError |= AttValFollows & AttNameStarts # No intervening WS.
     
    751751        #Not needed for xmlwf
    752752        delmask = control.CRLF | refs.delmask  # | CT_callouts.CDATA_delimiters
     753       
     754        qname_stream =  callouts.ElemNames | callouts.AttNames
     755        ncname_stream = CT_callouts.PI_name | refs.GenRefs
     756        name_stream = qname_stream | ncname_stream
     757        name_start = name_stream &~ bitutil.Advance(name_stream)
     758        name_start_check = name_start & ~lex.ASCII_name_start
     759        name_check = (name_stream &~ name_start | nmtoken_stream) & ~lex.ASCII_name_char & ~u8.suffix
    753760
    754761        #return (CT_callouts, callouts, refs, u16hi, u16lo, delmask, error, lex, u16delmask, EOF_mask)
    755         return (CT_callouts, callouts, refs, delmask, error, lex, EOF_mask, name_check, name_start_check)
     762        return (CT_callouts, callouts, refs, delmask, error, lex, EOF_mask, name_check, name_start_check, control)
    756763
    757764def demo_parabix(u8data):
Note: See TracChangeset for help on using the changeset viewer.