Changeset 8724
- Timestamp:
- 01/17/06 12:55:27 (3 years ago)
- Files:
-
- 3 modified
-
src/Pugs/Lexer.hs (modified) (4 diffs)
-
src/Pugs/Parser.hs (modified) (2 diffs)
-
t/syntax/interpolation/strings.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Lexer.hs
r8722 r8724 22 22 rule, verbatimRule, literalRule, 23 23 tryRule, tryVerbatimRule, 24 tryChoice, 24 tryChoice, ruleComma, 25 25 26 26 ruleScope, ruleTrait, ruleTraitName, ruleBareTrait, ruleType, … … 61 61 maybeParens :: CharParser st a -> CharParser st a 62 62 maybeParens p = choice [ parens p, p ] 63 64 maybeVerbatimBrackets :: CharParser st a -> CharParser st a65 maybeVerbatimBrackets p = choice [ verbatimBrackets p, p ]66 63 67 64 parens :: CharParser st a -> CharParser st a … … 197 194 198 195 -- | Backslashed non-alphanumerics (except for @\^@) translate into themselves. 199 escapeCode :: GenParser Char st Char200 escapeCode = ch arEsc <|> charNum <|> charAscii <|> charControl <|>anyChar196 escapeCode :: GenParser Char st String 197 escapeCode = ch charEsc <|> charNum <|> ch charAscii <|> ch charControl <|> ch anyChar 201 198 <?> "escape code" 199 where 200 ch = fmap (:[]) 202 201 203 202 charControl :: GenParser Char st Char … … 207 206 } 208 207 209 charNum :: GenParser Char st Char 208 -- This is currently the only escape that can return multiples. 209 charNum :: GenParser Char st String 210 210 charNum = do 211 code <- choice212 [ decimal211 codes <- choice 212 [ fmap (:[]) decimal 213 213 , based 'o' 8 octDigit 214 214 , based 'x' 16 hexDigit 215 215 , based 'd' 10 digit 216 216 ] 217 return . toEnum $ fromInteger code217 return $ map (toEnum . fromInteger) codes 218 218 where 219 219 based ch num p = do 220 220 char ch 221 maybeVerbatimBrackets (number num p) 221 choice [ verbatimBrackets (number num p `sepEndBy1` ruleComma) 222 , fmap (:[]) (number num p) 223 ] 224 225 ruleComma :: GenParser Char st () 226 ruleComma = do 227 lexeme (char ',') 228 return () 222 229 223 230 number :: Integer -> GenParser tok st Char -> GenParser tok st Integer -
src/Pugs/Parser.hs
r8717 r8724 2061 2061 return (x:a, ruleComma) 2062 2062 2063 ruleComma :: RuleParser ()2064 ruleComma = do2065 lexeme (char ',')2066 return ()2067 2068 2063 ruleCommaOrSemicolon :: RuleParser () 2069 2064 ruleCommaOrSemicolon = do … … 2286 2281 char '\\' 2287 2282 nextchar <- escapeCode -- see Lexer.hs 2288 return (Val $ VStr [nextchar])2283 return (Val $ VStr nextchar) 2289 2284 2290 2285 qInterpolateDelimiter :: Char -> RuleParser Exp -
t/syntax/interpolation/strings.t
r7978 r8724 12 12 =cut 13 13 14 plan 3 2;14 plan 30; 15 15 16 16 my $world = "World"; … … 68 68 is("x \d[65,66,000067] x", "x ABC x", "\\d[] allows multiple chars (2)"); 69 69 70 is("x \x[41,42,43]] x", "x ABC] x", "\\ d[] should not eat following ]s");71 is("x \d[65,66,67]] x", "x ABC] x", "\\ x[] should not eat following ]s");70 is("x \x[41,42,43]] x", "x ABC] x", "\\x[] should not eat following ]s"); 71 is("x \d[65,66,67]] x", "x ABC] x", "\\d[] should not eat following ]s");
