Changeset 13183 for src/Pugs/Lexer.hs
- Timestamp:
- 09/11/06 16:31:53 (2 years ago)
- Files:
-
- 1 modified
-
src/Pugs/Lexer.hs (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Lexer.hs
r13177 r13183 31 31 import Pugs.Types 32 32 import Pugs.Parser.Types 33 import Pugs.Parser.Charnames 33 34 34 35 identStart, identLetter :: RuleParser Char … … 265 266 266 267 charControl :: RuleParser Char 267 charControl = do{ char 'c' 268 ; code <- upper <|> char '@' 269 ; return (toEnum (fromEnum code - fromEnum '@')) 270 } 268 charControl = do 269 char 'c' 270 code <- upper <|> oneOf "@[" 271 case code of 272 '[' -> do 273 charName <- many (satisfy (/= ']')) 274 char ']' 275 case nameToCode charName of 276 Just c -> return (chr c) 277 _ -> error $ "Invalid unicode character name: " ++ charName 278 _ -> return (toEnum (fromEnum code - fromEnum '@')) 271 279 272 280 -- This is currently the only escape that can return multiples. … … 483 491 484 492 fractExponent n = do{ fract <- fraction 485 ; expo <- option 1.0exponent'493 ; expo <- option (1.0 :: Double) exponent' 486 494 ; return ((fromInteger n + fract)*expo) 487 495 } … … 493 501 fraction = do{ char '.' 494 502 ; digits <- many1 digit <?> "fraction" 495 ; return (foldr op 0.0digits)503 ; return (foldr op (0.0 :: Double) digits) 496 504 } 497 505 <?> "fraction" 498 506 where 499 op d f = (f + fromIntegral (digitToInt d)) /10.0507 op d f = (f + fromIntegral (digitToInt d)) / (10.0 :: Double) 500 508 501 509 exponent' = do{ oneOf "eE"
