Ignore:
Timestamp:
Apr 24, 2012, 7:06:21 AM (7 years ago)
Author:
cameron
Message:

Parabix2 xmlwf prototype with Span, AdvanceThenScan? functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/parabix2_pablo.py

    r1440 r2050  
    393393                CtCDPI_Cursor = PI_Cursor | CD_Cursor | Ct_Cursor
    394394                CtCDPI_Cursor = pablo.ScanTo(CtCDPI_Cursor, CtCDPI_opener)     
    395                 ctCDPI_mask |= (CtCDPI_ends - CtCDPI_starts) | CtCDPI_ends             
     395                ctCDPI_mask |= pablo.InclusiveSpan(CtCDPI_starts, CtCDPI_ends)
     396#               ctCDPI_mask |= (CtCDPI_ends - CtCDPI_starts) | CtCDPI_ends
    396397                # If any of the Comment, CDATA or PI markups are unterminated, it is an error.
    397398                ctCDPI_error = pablo.atEOF(ctCDPI_mask)
     
    400401                        error_tracker.NoteError("Error in comment, CDATA or processing instruction syntax", ctCDPI_error)
    401402               
    402         check_streams.misc_mask = (lex.WS | lex.LAngle | (pablo.Advance(ctCDPI_Callouts.Ct_ends | ctCDPI_Callouts.PI_ends) - (ctCDPI_Callouts.Ct_starts | ctCDPI_Callouts.PI_starts)) | CtCDPI_starts) & EOF_mask
     403        check_streams.misc_mask = (lex.WS | lex.LAngle | (pablo.Advance(ctCDPI_Callouts.Ct_ends | ctCDPI_Callouts.PI_ends)  -(ctCDPI_Callouts.Ct_starts | ctCDPI_Callouts.PI_starts)) | CtCDPI_starts) & EOF_mask
     404#  Following is slow
     405#       check_streams.misc_mask = (lex.WS | lex.LAngle | pablo.InclusiveSpan(ctCDPI_Callouts.Ct_starts | ctCDPI_Callouts.PI_starts, ctCDPI_Callouts.Ct_ends | ctCDPI_Callouts.PI_ends) | CtCDPI_starts) & EOF_mask
    403406
    404407
     
    456459                        else: EqExpected = AttNameFollow
    457460                        ParseError |= EqExpected &~ lex.Equals
    458                         AttValPos = pablo.ScanThru(EqExpected, EqExpected | lex.WS)
     461                        AttValPos = pablo.AdvanceThenScanThru(EqExpected, lex.WS)
     462#                       AttValPos = pablo.ScanThru(EqExpected, EqExpected | lex.WS)
    459463                        tag_Callouts.AttVal_starts |= AttValPos
    460464                        DQuoteAttVal = AttValPos & lex.DQuote
    461465                        SQuoteAttVal = AttValPos & lex.SQuote
    462                         DQuoteAttEnd = pablo.ScanTo(DQuoteAttVal, DQuoteDelim &~ DQuoteAttVal)
    463                         SQuoteAttEnd = pablo.ScanTo(SQuoteAttVal, SQuoteDelim &~ SQuoteAttVal)
     466#                       DQuoteAttEnd = pablo.ScanTo(DQuoteAttVal, DQuoteDelim &~ DQuoteAttVal)
     467#                       SQuoteAttEnd = pablo.ScanTo(SQuoteAttVal, SQuoteDelim &~ SQuoteAttVal)
     468                        DQuoteAttEnd = pablo.AdvanceThenScanTo(DQuoteAttVal, DQuoteDelim)
     469                        SQuoteAttEnd = pablo.AdvanceThenScanTo(SQuoteAttVal, SQuoteDelim)
    464470                        AttValEnd = DQuoteAttEnd | SQuoteAttEnd
    465471                        ParseError |= (AttValPos | AttValEnd) &~ (lex.DQuote | lex.SQuote)
     
    488494        # End Tag Parsing
    489495
    490         EndTagEnds = pablo.ScanThru(tag_Callouts.EndTag_marks, tag_Callouts.EndTag_marks | lex.NameScan)
     496        EndTagEnds = pablo.AdvanceThenScanThru(tag_Callouts.EndTag_marks, lex.NameScan)
    491497        if EndTagEnds & lex.WS:
    492498                EndTagEnds = pablo.ScanThru(EndTagEnds, lex.WS)
     
    497503               
    498504        # Attribute value spans
    499         tag_Callouts.AttVal_spans = tag_Callouts.AttVal_ends - tag_Callouts.AttVal_starts
     505#       tag_Callouts.AttVal_spans = tag_Callouts.AttVal_ends - tag_Callouts.AttVal_starts
     506        tag_Callouts.AttVal_spans = pablo.SpanUpTo(tag_Callouts.AttVal_starts, tag_Callouts.AttVal_ends)
    500507
    501508def Parse_refs(lex, marker, ref_Callouts):
     
    534541
    535542def Validate_xml_names(ctCDPI_Callouts, ref_Callouts, tag_Callouts, lex, u8, check_streams):
    536         PI_names = ctCDPI_Callouts.PI_name_ends - ctCDPI_Callouts.PI_name_starts
    537         GenRefs = ref_Callouts.GenRef_ends - ref_Callouts.GenRef_starts
    538         ElemNames = tag_Callouts.ElemName_ends - tag_Callouts.ElemName_starts
    539         AttNames = tag_Callouts.AttName_ends - tag_Callouts.AttName_starts
     543#       PI_names = ctCDPI_Callouts.PI_name_ends - ctCDPI_Callouts.PI_name_starts
     544#       GenRefs = ref_Callouts.GenRef_ends - ref_Callouts.GenRef_starts
     545#       ElemNames = tag_Callouts.ElemName_ends - tag_Callouts.ElemName_starts
     546#       AttNames = tag_Callouts.AttName_ends - tag_Callouts.AttName_starts
     547        PI_names = pablo.SpanUpTo(ctCDPI_Callouts.PI_name_starts, ctCDPI_Callouts.PI_name_ends)
     548        GenRefs = pablo.SpanUpTo(ref_Callouts.GenRef_starts, ref_Callouts.GenRef_ends)
     549        ElemNames = pablo.SpanUpTo(tag_Callouts.ElemName_starts, tag_Callouts.ElemName_ends)
     550        AttNames = pablo.SpanUpTo(tag_Callouts.AttName_starts, tag_Callouts.AttName_ends)
    540551        qname_stream =  ElemNames | AttNames
    541552        ncname_stream = PI_names | GenRefs
Note: See TracChangeset for help on using the changeset viewer.