Changeset 7949

Show
Ignore:
Timestamp:
11/13/05 17:31:09 (3 years ago)
Author:
autrijus
svk:copy_cache_prev:
10363
Message:

* luqui's \d[] patch eats the trailing space after the bracket;

change "brackets" to "verbatimBrackets" to solve this.

* moreover, fix the old bug of "&foo() &bar()" eating the

whitespace inbetween, due to the same cause.

* test for both in t/syntax/interpolation/strings.t

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Lexer.hs

    r7943 r7949  
    6161maybeParens :: CharParser st a -> CharParser st a 
    6262maybeParens p = choice [ parens p, p ] 
    63 maybeBrackets :: CharParser st a -> CharParser st a 
    64 maybeBrackets p = choice [ brackets p, p ] 
     63 
     64maybeVerbatimBrackets :: CharParser st a -> CharParser st a 
     65maybeVerbatimBrackets p = choice [ verbatimBrackets p, p ] 
    6566 
    6667parens     :: CharParser st a -> CharParser st a 
     
    205206 
    206207charNum :: GenParser Char st Char                     
    207 charNum         = do{ code <- decimal  
    208                               <|> do{ char 'o'; maybeBrackets $ number 8 octDigit } 
    209                               <|> do{ char 'x'; maybeBrackets $ number 16 hexDigit } 
    210                               <|> do{ char 'd'; maybeBrackets $ number 10 digit } 
    211                     ; return (toEnum (fromInteger code)) 
    212                     } 
     208charNum = do 
     209    code <- choice 
     210        [ decimal  
     211        , based 'o'  8 octDigit 
     212        , based 'x' 16 hexDigit 
     213        , based 'd' 10 digit 
     214        ] 
     215    return . toEnum $ fromInteger code 
     216    where 
     217    based ch num p = do 
     218        char ch 
     219        let p' = number num p 
     220        choice [ verbatimBrackets p', p' ] 
    213221 
    214222number :: Integer -> GenParser tok st Char -> GenParser tok st Integer 
  • src/Pugs/Parser.hs

    r7946 r7949  
    16601660ruleCodeSubscript :: RuleParser (Exp -> Exp) 
    16611661ruleCodeSubscript = tryVerbatimRule "code subscript" $ do 
    1662     (invs,args) <- parens $ parseParamList 
     1662    (invs, args) <- verbatimParens parseParamList 
    16631663    -- FAILED PARSER PATCH 
    16641664    --(invs, args) <- parseHasParenParamList -- XXX doesn't handle trailing  
  • t/syntax/interpolation/strings.t

    r7771 r7949  
    1212=cut 
    1313 
    14 plan 25; 
     14plan 26; 
    1515 
    1616my $world = "World"; 
     
    2828is("Wont you take me to &func()", 'Wont you take me to func-y town', 'closure interpolation'); 
    2929is("2 + 2 = { 2+2 }", '2 + 2 = 4', 'double quoted closure interpolation works'); 
    30 is("&func() is where I live", 'func-y town is where I live', "make sure function interpolation doesn't eat all trailing whitespace", :todo<bug>); 
     30is("&func() is where I live", 'func-y town is where I live', "make sure function interpolation doesn't eat all trailing whitespace"); 
    3131 
    3232# L<S02/Names and Variables /except when interpolating/> 
     
    5959is(qb"$world \\\"\n\t", "\$world \\\"\n\t", "only interpolate backslash"); 
    6060is('$world \qq[@list[]] %hash{}', '$world 1 2 %hash{}', "interpolate quoting constructs in ''"); 
     61 
     62is(" \d[111] \d[107] ", ' o k ', "\\d[] respects whitespaces around it")