Changeset 2908 for proto/PDF


Ignore:
Timestamp:
Feb 11, 2013, 2:58:52 PM (6 years ago)
Author:
lindanl
Message:

Add string parsing

Location:
proto/PDF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/PDF/cb_pablo.py

    r2905 r2908  
    7474    name_starts = 0
    7575    numeric_starts = 0
     76    instring = 0
     77    error = 0
    7678   
    7779   
     
    258260        out_Callouts.mask = pablo.InclusiveSpan(out_Callouts.comment, pablo.ScanTo(out_Callouts.comment, lex.EOL))
    259261
    260 #def Parse_String(lex, escape_Callouts, marker, out_Callouts):
    261        
    262        
    263        
     262def Parse_String(escape_Callouts, marker, out_Callouts):
     263        unmatched = escape_Callouts.RParen
     264        marker.error = 0
     265        pscan = 0
     266        qscan = 0
     267        pscan = pablo.ScanTo(pablo.Advance(escape_Callouts.LParen), escape_Callouts.LParen | escape_Callouts.RParen)
     268        qscan = pablo.ScanTo(pablo.Advance(escape_Callouts.RParen), escape_Callouts.LParen | escape_Callouts.RParen)
     269        marker.instring = pablo.ExclusiveSpan(escape_Callouts.LParen, pscan)
     270        closed = pscan & escape_Callouts.RParen
     271        unclosed = pscan & escape_Callouts.LParen | qscan & escape_Callouts.RParen
     272        marker.error = pablo.atEOF(pscan)
     273        all_closed = closed
     274        while unclosed:
     275                pscan = pablo.ScanTo(pablo.Advance(unclosed & escape_Callouts.LParen), unclosed)
     276                qscan = pablo.ScanTo(pablo.Advance(unclosed & escape_Callouts.RParen), unclosed)
     277                marker.instring |= pablo.SpanUpTo(unclosed & escape_Callouts.LParen, pscan)
     278                closed = pscan & escape_Callouts.RParen
     279                unclosed = pscan & escape_Callouts.LParen | qscan & escape_Callouts.RParen
     280                all_closed |= closed
     281                marker.error |= pablo.atEOF(pscan)
     282        #
     283        # Any closing paren that was not actually used to close
     284        # an opener is in error.
     285        out_Callouts.mask |= marker.instring
     286        marker.error |= escape_Callouts.RParen &~ all_closed       
    264287       
    265288         
     
    267290        hexString_starts = lex.LAngle &~ out_Callouts.mask
    268291        hexString_ends = pablo.ScanThru(pablo.Advance(hexString_starts),lex.Hex|lex.WS)
    269         #error = hexString_ends &~ lex.RAngle
     292        marker.error |= hexString_ends &~ lex.RAngle
    270293        out_Callouts.hexString_mask = pablo.InclusiveSpan(hexString_starts,hexString_ends)
    271294        out_Callouts.mask |= out_Callouts.hexString_mask
  • proto/PDF/cb_template.cpp

    r2905 r2908  
    303303      parse_Escaped.do_block(lex[i], parity, escape_Callouts, out_Callouts, lex[i+1]);
    304304      parse_Comment.do_block(lex[i], escape_Callouts, marker, out_Callouts);
     305      parse_String.do_block(escape_Callouts, marker, out_Callouts);
    305306      parse_HexStrings.do_block(lex[i], marker, out_Callouts);
    306307      parse_Names.do_block(lex[i], marker, out_Callouts, lex[i+1]);
     
    315316    parse_Escaped.do_final_block(lex[BLOCKS-1], parity, escape_Callouts, out_Callouts, EOF_mask);
    316317    parse_Comment.do_final_block(lex[BLOCKS-1], escape_Callouts, marker, out_Callouts, EOF_mask);
     318    parse_String.do_final_block(escape_Callouts, marker, out_Callouts, EOF_mask);
    317319    parse_HexStrings.do_final_block(lex[BLOCKS-1], marker, out_Callouts, EOF_mask);
    318320    parse_Names.do_final_block(lex[BLOCKS-1], marker, out_Callouts, EOF_mask);
     
    323325    Postprocessing(&srcbuf[(BLOCKS-1)*BLOCK_SIZE], marker);
    324326
    325 //     print_register("out_Callouts.comment",out_Callouts.comment);
     327//      print_register("marker.error",marker.error);
    326328   
    327329//     for(int i=0;i<num_idx;i++)
Note: See TracChangeset for help on using the changeset viewer.