Changeset 2905 for proto


Ignore:
Timestamp:
Feb 11, 2013, 1:48:29 PM (7 years ago)
Author:
lindanl
Message:

Add Comment Parsing. Compiler for nested while loop needs to be fixed.

Location:
proto/PDF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/PDF/cb_pablo.py

    r2903 r2905  
    4646       
    4747class Escape_Callouts():
    48     UELParen = 0
    49     UERParen = 0
     48    LParen = 0
     49    RParen = 0
    5050    Oct1 = 0
    5151    Oct2 = 0
     
    5656class Out_Callouts():
    5757    mask = 0
     58    comment = 0
    5859    zeromask = 0
    5960    delmask = 0
     
    197198def Parse_Escaped(lex, parity, escape_Callouts, out_Callouts):
    198199 
    199         escape_Callouts.UELParen = lex.LParen
    200         escape_Callouts.UERParen = lex.RParen
     200        escape_Callouts.LParen = lex.LParen
     201        escape_Callouts.RParen = lex.RParen
    201202        escape_Callouts.Nonoct = 0
    202203        escape_Callouts.Oct1 = 0
     
    222223          escape_char |= (odd & pablo.SpanUpTo(odd_start, odd_final))
    223224
    224           escape_Callouts.UELParen = lex.LParen &~ escape
    225           escape_Callouts.UERParen = lex.RParen &~ escape
     225          escape_Callouts.LParen = lex.LParen &~ escape
     226          escape_Callouts.RParen = lex.RParen &~ escape
    226227          escape_Callouts.Nonoct = lex.Nonoct & escape 
    227228          escape_Callouts.Oct1 = lex.Oct & escape
     
    231232          escape_Callouts.Oct2 &= ~escape_Callouts.Oct3
    232233          out_Callouts.delmask = escape_char
    233 
    234 #def Parse_CommentsLiteralStrings(lex, escaped_Callouts, marker, comments_Callouts, literalStrings_Callouts) :
    235        
    236 
    237        
     234       
     235def Parse_Comment(lex, escape_Callouts, marker, out_Callouts):
     236        knownParen = 0
     237        CtCand = lex.Percent
     238        line_start = ~pablo.Advance(~lex.EOL)
     239        knownNonCtReg = pablo.SpanUpTo(line_start, pablo.ScanTo(line_start, lex.EOL | CtCand))
     240        newParen = knownNonCtReg & (escape_Callouts.LParen | escape_Callouts.RParen)
     241        while newParen &~ knownParen:
     242          knownParen |= newParen
     243          pscan = pablo.AdvanceThenScanTo(newParen & escape_Callouts.LParen, escape_Callouts.LParen | escape_Callouts.RParen)
     244          pscanReg = pablo.SpanUpTo(newParen & escape_Callouts.LParen, pscan)
     245          CtCand = CtCand &~ pscanReg
     246          knownNonCtReg = pablo.SpanUpTo(line_start, pablo.ScanTo(line_start, lex.EOL | CtCand))
     247          closed = pscan & escape_Callouts.RParen
     248          opener = pscan & escape_Callouts.LParen
     249          while pablo.inFile(opener):
     250            pscan = pablo.AdvanceThenScanTo(opener, escape_Callouts.RParen &~ closed)
     251            pscanReg = pablo.SpanUpTo(opener, pscan)
     252            CtCand = CtCand &~ pscanReg
     253            closed = pscan & escape_Callouts.RParen
     254            opener = pscan & escape_Callouts.LParen
     255            knownNonCtReg |= pscanReg
     256          newParen = knownNonCtReg & (escape_Callouts.LParen | escape_Callouts.RParen)
     257        out_Callouts.comment = CtCand &~ knownNonCtReg
     258        out_Callouts.mask = pablo.InclusiveSpan(out_Callouts.comment, pablo.ScanTo(out_Callouts.comment, lex.EOL))
     259
     260#def Parse_String(lex, escape_Callouts, marker, out_Callouts):
     261       
     262       
     263       
     264       
     265         
    238266def Parse_HexStrings(lex, marker, out_Callouts) :
    239         hexString_starts = lex.LAngle #&~marker.mask
     267        hexString_starts = lex.LAngle &~ out_Callouts.mask
    240268        hexString_ends = pablo.ScanThru(pablo.Advance(hexString_starts),lex.Hex|lex.WS)
    241269        #error = hexString_ends &~ lex.RAngle
    242270        out_Callouts.hexString_mask = pablo.InclusiveSpan(hexString_starts,hexString_ends)
    243         out_Callouts.mask = out_Callouts.hexString_mask
     271        out_Callouts.mask |= out_Callouts.hexString_mask
    244272        marker.hex_opener = hexString_starts
    245273
    246274def Parse_Names(lex, marker, out_Callouts) :
    247         name_starts =lex.Slash #&~marker.mask
     275        name_starts =lex.Slash &~ out_Callouts.mask
    248276        names_follows = pablo.ScanThru(pablo.Advance(name_starts), lex.Regular)
    249277        out_Callouts.names_escapes = lex.Hash & pablo.Lookahead(lex.Hex) & pablo.Lookahead(lex.Hex,2)   
  • proto/PDF/cb_template.cpp

    r2903 r2905  
    302302    for (int i = 0; i < BLOCKS-1; i++){
    303303      parse_Escaped.do_block(lex[i], parity, escape_Callouts, out_Callouts, lex[i+1]);
     304      parse_Comment.do_block(lex[i], escape_Callouts, marker, out_Callouts);
    304305      parse_HexStrings.do_block(lex[i], marker, out_Callouts);
    305306      parse_Names.do_block(lex[i], marker, out_Callouts, lex[i+1]);
     
    313314    EOF_mask = bitblock::srl(simd<1>::constant<1>(), convert(BLOCK_SIZE-chars_avail));
    314315    parse_Escaped.do_final_block(lex[BLOCKS-1], parity, escape_Callouts, out_Callouts, EOF_mask);
     316    parse_Comment.do_final_block(lex[BLOCKS-1], escape_Callouts, marker, out_Callouts, EOF_mask);
    315317    parse_HexStrings.do_final_block(lex[BLOCKS-1], marker, out_Callouts, EOF_mask);
    316318    parse_Names.do_final_block(lex[BLOCKS-1], marker, out_Callouts, EOF_mask);
     
    321323    Postprocessing(&srcbuf[(BLOCKS-1)*BLOCK_SIZE], marker);
    322324
    323    
     325//     print_register("out_Callouts.comment",out_Callouts.comment);
     326   
    324327//     for(int i=0;i<num_idx;i++)
    325328//       printf("%i,%i\n",numbers[i],dec_pl[i]);
Note: See TracChangeset for help on using the changeset viewer.