Changeset 14062 for src/Pugs/Lexer.hs

Show
Ignore:
Timestamp:
10/08/06 12:38:10 (2 years ago)
Author:
audreyt
Message:

* Don't actually keep track of prevChar, instead keep track

of the last time we've seen a whitespace character.
This makes parsing quite a bit faster.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Lexer.hs

    r13634 r14062  
    2121    rule, verbatimRule, literalRule, 
    2222    tryRule, tryVerbatimRule, 
    23     tryChoice, ruleComma, ruleWs, 
     23    tryChoice, ruleComma,  
    2424 
    2525    ruleScope, ruleTrait, ruleTraitName, ruleBareTrait, ruleType, 
     
    3232import Pugs.Parser.Types 
    3333import Pugs.Parser.Charnames 
     34import Text.ParserCombinators.Parsec.Pos (sourceColumn, sourceLine) 
    3435 
    3536identStart, identLetter :: RuleParser Char 
     
    133134    return contents 
    134135 
     136{- 
    135137-- The \b rule. 
    136138_ruleWordBoundary :: RuleParser () 
     
    154156                SpaceClass  -> whiteSpace 
    155157                _           -> return () 
     158-} 
    156159 
    157160{-| 
     
    200203symbol s = try $ do 
    201204    rv <- string s 
    202     let ahead  = if isWordAny lastCh then aheadWord else aheadSym 
    203         lastCh = last rv 
     205    let lastCh = last s 
     206        ahead  = if isWordAny lastCh then aheadWord else aheadSym 
    204207    choice [ lookAhead (satisfy (ahead lastCh)), eof >> return ' ' ] 
    205208    whiteSpace 
     
    530533simpleSpace :: RuleParser () 
    531534simpleSpace = do 
    532     skipMany1 (satisfy (isSpace)) 
     535    skipMany1 (satisfy isSpace) 
     536    pos <- getPosition 
     537    modify (\s -> s{ s_wsLine = sourceLine pos, s_wsColumn = sourceColumn pos }) 
    533538 
    534539multiLineComment :: RuleParser ()