Ignore:
Timestamp:
Apr 16, 2013, 2:48:59 PM (6 years ago)
Author:
cameron
Message:

More tightening of paren match prototypes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/matchparens/parenmatch.py

    r2904 r3031  
    4141       
    4242def Match_Parens(lex, matches):
    43         unmatched = lex.RParen
    44         pscan = {}
    45         qscan = {}
     43        parens = lex.LParen | lex.RParen
     44        Lscan = {}
     45        Rscan = {}
    4646        i = 0
    47         pscan[0] = pablo.ScanTo(pablo.Advance(lex.LParen), lex.LParen | lex.RParen)
    48         qscan[0] = pablo.ScanTo(pablo.Advance(lex.RParen), lex.LParen | lex.RParen)
    49         matches.closed[i] = pscan[i] & lex.RParen
    50         unclosed = pscan[i] & lex.LParen | qscan[i] & lex.RParen
    51         matches.error = pscan[i] &~ pablo.EOF_mask
     47        Lscan[0] = pablo.AdvanceThenScanTo(lex.LParen, parens)
     48        Rscan[0] = pablo.AdvanceThenScanTo(lex.RParen, parens)
     49        matches.closed[0] = Lscan[0] & lex.RParen
     50        matches.error = pablo.atEOF(Lscan[0])
     51        unclosed = Lscan[i] & lex.LParen | Rscan[i] & lex.RParen
    5252        all_closed = matches.closed[i]
    5353        while unclosed:
    5454                i += 1
    55                 pscan[i] = pablo.ScanTo(pablo.Advance(unclosed & lex.LParen), unclosed)
    56                 qscan[i] = pablo.ScanTo(pablo.Advance(unclosed & lex.RParen), unclosed)
    57                 matches.closed[i] = pscan[i] & lex.RParen
    58                 unclosed = pscan[i] & lex.LParen | qscan[i] & lex.RParen
     55                unclosedLParen = unclosed & lex.LParen
     56                unclosedRParen = unclosed & lex.RParen
     57                Lscan[i] = pablo.AdvanceThenScanTo(unclosedLParen, unclosed)
     58                Rscan[i] = pablo.AdvanceThenScanTo(unclosedRParen, unclosed)
     59                matches.closed[i] = Lscan[i] & lex.RParen
     60                matches.error |= pablo.atEOF(Lscan[i])
     61                unclosed = Lscan[i] & lex.LParen | Rscan[i] & lex.RParen
    5962                all_closed |= matches.closed[i]
    60                 matches.error |= pscan[i] &~ pablo.EOF_mask
    6163        #
    6264        # Any closing paren that was not actually used to close
    6365        # an opener is in error.
    6466        matches.error |= lex.RParen &~ all_closed
    65 
    6667
    6768
Note: See TracChangeset for help on using the changeset viewer.