Changeset 3155 for proto/PDF/cb_pablo.py


Ignore:
Timestamp:
May 18, 2013, 3:14:22 PM (6 years ago)
Author:
lindanl
Message:

Add array parsing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/PDF/cb_pablo.py

    r3129 r3155  
    244244          escape_Callouts.Oct2 &= ~escape_Callouts.Oct3
    245245          out_Callouts.delmask = escape_mark
    246        
    247 def Parse_Comment(lex, escape_Callouts, marker, out_Callouts):
    248   out_Callouts.mask = 0
    249   if lex.Percent:
    250         knownParen = 0
    251         CtCand = lex.Percent
    252         line_start = ~pablo.Advance(~lex.EOL)
    253         knownNonCtReg = pablo.SpanUpTo(line_start, pablo.ScanTo(line_start, lex.EOL | CtCand))
    254         newParen = knownNonCtReg & (escape_Callouts.LParen | escape_Callouts.RParen)
    255         while newParen &~ knownParen:
    256           knownParen |= newParen
    257           pscan = pablo.AdvanceThenScanTo(newParen & escape_Callouts.LParen, escape_Callouts.LParen | escape_Callouts.RParen)
    258           pscanReg = pablo.SpanUpTo(newParen & escape_Callouts.LParen, pscan)
    259           CtCand = CtCand &~ pscanReg
    260           knownNonCtReg = pablo.SpanUpTo(line_start, pablo.ScanTo(line_start, lex.EOL | CtCand))
    261           closed = pscan & escape_Callouts.RParen
    262           opener = pscan & escape_Callouts.LParen
    263           while pablo.inFile(opener):
    264             pscan = pablo.AdvanceThenScanTo(opener, escape_Callouts.RParen &~ closed)
    265             pscanReg = pablo.SpanUpTo(opener, pscan)
    266             CtCand = CtCand &~ pscanReg
    267             closed = pscan & escape_Callouts.RParen
    268             opener = pscan & escape_Callouts.LParen
    269             knownNonCtReg |= pscanReg
    270           newParen = knownNonCtReg & (escape_Callouts.LParen | escape_Callouts.RParen)
    271         comment = CtCand &~ knownNonCtReg
    272         out_Callouts.mask = pablo.InclusiveSpan(comment, pablo.ScanTo(comment, lex.EOL))
    273 
    274 def Parse_String(escape_Callouts, marker, out_Callouts):
    275         unmatched = escape_Callouts.RParen
    276         marker.error = 0
    277         pscan = 0
    278         qscan = 0
    279         pscan = pablo.ScanTo(pablo.Advance(escape_Callouts.LParen), escape_Callouts.LParen | escape_Callouts.RParen)
    280         qscan = pablo.ScanTo(pablo.Advance(escape_Callouts.RParen), escape_Callouts.LParen | escape_Callouts.RParen)
    281         instring = pablo.ExclusiveSpan(escape_Callouts.LParen, pscan)
    282         closed = pscan & escape_Callouts.RParen
    283         unclosed = pscan & escape_Callouts.LParen | qscan & escape_Callouts.RParen
    284         marker.error = pablo.atEOF(pscan)
    285         all_closed = closed
    286         while unclosed:
    287                 pscan = pablo.ScanTo(pablo.Advance(unclosed & escape_Callouts.LParen), unclosed)
    288                 qscan = pablo.ScanTo(pablo.Advance(unclosed & escape_Callouts.RParen), unclosed)
    289                 instring |= pablo.SpanUpTo(unclosed & escape_Callouts.LParen, pscan)
    290                 closed = pscan & escape_Callouts.RParen
    291                 unclosed = pscan & escape_Callouts.LParen | qscan & escape_Callouts.RParen
    292                 all_closed |= closed
    293                 marker.error |= pablo.atEOF(pscan)
    294         #
    295         # Any closing paren that was not actually used to close
    296         # an opener is in error.
    297         out_Callouts.mask |= instring
    298         marker.starts = pablo.Advance(~instring)&instring
    299         marker.ends = pablo.ScanThru(marker.starts, instring)
    300         marker.error |= escape_Callouts.RParen &~ all_closed       
    301        
    302 
    303 #
     246
    304247# Modified version with comment processing
    305248#
     
    369312        marker.error |= escape_Callouts.RParen &~ closed_RParen &~ pablo.SpanUpTo(comment_start, comment_end)
    370313
    371 
    372314         
    373315def Parse_HexStrings(lex, marker, out_Callouts) :
     
    388330        names_follows = pablo.ScanThru(pablo.Advance(name_starts), lex.Regular)
    389331        out_Callouts.names_escapes = lex.Hash & pablo.Lookahead(lex.Hex) & pablo.Lookahead(lex.Hex,2) &~ out_Callouts.mask
    390         out_Callouts.mask |= pablo.InclusiveSpan(name_starts,names_follows)
     332        out_Callouts.mask |= pablo.SpanUpTo(name_starts,names_follows)
    391333        marker.starts |= name_starts
    392334        marker.ends |= names_follows
     
    399341        marker.ends |= numeric_follows
    400342
    401        
     343# Parse everything else: keywords, operators, array brackets   
    402344def Parse_Keywords(lex, marker, out_Callouts) :
    403345        keywords_starts = (lex.Regular &~ pablo.Advance(lex.Regular)) &~ out_Callouts.mask
    404346        keywords_follows = pablo.ScanThru(keywords_starts, lex.Regular)
    405         marker.starts |= keywords_starts       
     347        marker.starts |= keywords_starts | ((lex.LBracket | lex.RBracket)&~ out_Callouts.mask)
    406348        marker.ends |= keywords_follows
     349       
    407350       
    408351       
Note: See TracChangeset for help on using the changeset viewer.