Changeset 7943

Show
Ignore:
Timestamp:
11/13/05 04:54:04 (3 years ago)
Author:
luqui
Message:

Fixed '$foo'.perl (wasn't properly escaping the $).
In the process, I blessed and implemented "\d[123]".

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Lexer.hs

    r7901 r7943  
    6161maybeParens :: CharParser st a -> CharParser st a 
    6262maybeParens p = choice [ parens p, p ] 
     63maybeBrackets :: CharParser st a -> CharParser st a 
     64maybeBrackets p = choice [ brackets p, p ] 
    6365 
    6466parens     :: CharParser st a -> CharParser st a 
     
    204206charNum :: GenParser Char st Char                     
    205207charNum         = do{ code <- decimal  
    206                               <|> do{ char 'o'; number 8 octDigit } 
    207                               <|> do{ char 'x'; number 16 hexDigit } 
    208                               <|> do{ char 'd'; number 10 digit } 
     208                              <|> do{ char 'o'; maybeBrackets $ number 8 octDigit } 
     209                              <|> do{ char 'x'; maybeBrackets $ number 16 hexDigit } 
     210                              <|> do{ char 'd'; maybeBrackets $ number 10 digit } 
    209211                    ; return (toEnum (fromInteger code)) 
    210212                    } 
  • src/Pugs/Pretty.hs

    r7872 r7943  
    187187quoted '\r' = "\\r" 
    188188quoted '\n' = "\\n" 
    189 quoted x | x < ' ' = "{chr " ++ show (ord x) ++ "}" 
    190 -- XXX is there a more elegant way? Remember that 
    191 --   my $str = chr(12) ~ "3"; $str.perl 
    192 -- may not perlify to "\123"... 
     189quoted '$'  = "\\$" 
     190quoted '@'  = "\\@" 
     191quoted '%'  = "\\%" 
     192quoted '&'  = "\\&" 
     193quoted x | x < ' ' || x > '~' = "\\d[" ++ show (ord x) ++ "]" 
    193194quoted x = [x] 
    194195 
  • t/builtins/perl.t

    r7804 r7943  
    99    # Basic scalar values 
    1010    42, 42/10, 4.2, sqrt(2), 3e5, Inf, -Inf, NaN, 
    11     "a string", "", "\0", "\t", "\n", "\r\n", "\7", '{', '}', "\123", 
     11    "a string", "", "\0", "\t", "\n", "\r\n", "\7", '{', '}', "\123", '$a @string %with &sigils()', 
    1212    ?1, ?0, 
    1313    undef,