Changeset 12317 for src/Pugs/Lexer.hs

Show
Ignore:
Timestamp:
08/16/06 19:28:24 (2 years ago)
Author:
audreyt
Message:

* Glorious refactoring of the Var type.

Previously, Var is type synonym to String, and all package

lookups, OUTER
handling, sigil and twigil parsing etc were done in an extremely adhoc way with String operations.

Now we split Var into several parts.
Take "&Moose::Elk::infix:<antler>" as an example:

v_sigil
VarSigil? -- SScalar
v_twigil
VarTwigil? -- TNone
v_package
Pkg -- ["Moose", "Elk"]
v_categ
VarCateg? -- C_infix
v_name
ID -- "antler"

The names are stored as interned ByteStrings? for fast comparison.

All involved types are changed from String to new types as well,

such as (envPackage
Pkg).
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Lexer.hs

    r12268 r12317  
    3131import Pugs.Types 
    3232import Pugs.Parser.Types 
    33 import qualified Text.ParserCombinators.Parsec.Char as C (satisfy) 
    34  
     33 
     34identStart, identLetter :: RuleParser Char 
    3535identStart  = satisfy isWordAlpha 
    3636identLetter = satisfy isWordAny 
     
    4949maybeParens p = choice [ parens p, p ] 
    5050 
     51parens, braces, angles, brackets :: RuleParser a -> RuleParser a 
    5152parens p        = between (symbol "(") (symbol ")") p 
    5253braces p        = between (symbol "{") (symbol "}") p 
     
    132133 
    133134-- The \b rule. 
    134 ruleWordBoundary :: RuleParser () 
    135 ruleWordBoundary = do 
     135_ruleWordBoundary :: RuleParser () 
     136_ruleWordBoundary = do 
    136137    prev <- getPrevCharClass 
    137138    case prev of 
     
    236237        = homogenConcat (Val (VStr (x ++ y)) : xs) 
    237238    homogenConcat (x:xs) 
    238         = App (Var "&infix:~") Nothing [x, homogenConcat xs] 
     239        = App (_Var "&infix:~") Nothing [x, homogenConcat xs] 
    239240     
    240241    stringList :: Int -> RuleParser [Exp] 
     
    451452----------------------------------------------------------- 
    452453-- naturalOrFloat :: CharParser st (Either Integer Double) 
    453 naturalOrFloat  = lexeme (natFloat) <?> "number" 
     454naturalOrFloat  = lexeme natFloat  <?> "number" 
    454455 
    455456float           = lexeme floating   <?> "float"