Changeset 6673
- Timestamp:
- 09/03/05 21:49:59 (3 years ago)
- Files:
-
- 2 modified
-
src/Pugs/Parser.hs (modified) (2 diffs)
-
t/subroutines/lexical_subs.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Parser.hs
r6656 r6673 453 453 ruleSubName = verbatimRule "subroutine name" $ do 454 454 twigil <- ruleTwigil 455 fixity <- option "" $ choice (map (try . string) $ fixities) 456 name <- ruleQualifiedIdentifier 457 <|> try (between (string "<<") (string ">>") 458 (many1 (satisfy (/= '>') <|> lookAhead (satisfy (/= '>'))))) 459 <|> between (char '<') (char '>') (many1 $ satisfy (/= '>')) 460 <|> between (char '\171') (char '\187') (many1 $ satisfy (/= '\187')) 461 return $ "&" ++ twigil ++ fixity ++ name 455 name <- ruleOperatorName <|> ruleQualifiedIdentifier 456 return $ "&" ++ twigil ++ name 457 458 ruleOperatorName :: RuleParser String 459 ruleOperatorName = do 460 fixity <- choice (map (try . string) fixities) 461 name <- try (between (string "<<") (string ">>") 462 (many1 (satisfy (/= '>') <|> lookAhead (satisfy (/= '>'))))) 463 <|> between (char '<') (char '>') (many1 $ satisfy (/= '>')) 464 <|> between (char '\171') (char '\187') (many1 $ satisfy (/= '\187')) 465 return $ fixity ++ name 462 466 where 463 467 fixities = words " prefix: postfix: infix: circumfix: coerce: self: term: postcircumfix: rule_modifier: trait_verb: trait_auxiliary: scope_declarator: statement_control: infix_postfix_meta_operator: postfix_prefix_meta_operator: prefix_postfix_meta_operator: infix_circumfix_meta_operator: " 468 464 469 465 470 ruleSubParameters :: ParensOption -> RuleParser (Maybe [Param]) … … 1733 1738 -- Valid param names: $foo, @bar, &baz, %grtz, ::baka 1734 1739 sigil <- choice [ oneOf "$@%&" >>= return . (:""), string "::" ] 1735 twigil <- ruleTwigil 1736 name <- many1 wordAny 1737 return $ sigil ++ twigil ++ name 1740 if sigil == "&" 1741 then ruleSubName 1742 else do twigil <- ruleTwigil 1743 name <- many1 wordAny 1744 return $ sigil ++ twigil ++ name 1738 1745 1739 1746 ruleVarName :: RuleParser String -
t/subroutines/lexical_subs.t
r6654 r6673 4 4 use Test; 5 5 6 plan 3;6 plan 5; 7 7 8 8 sub f() { … … 21 21 is(callit({ $^x + 2 }), 3, "lexical subs get precedence over package subs"); 22 22 23 sub infix:<@@> ($x, $y) { $x + $y } 23 24 25 sub foo2(&infix:<@@>) { 26 2 @@ 3; 27 } 28 29 is(2 @@ 3, 5); 30 is(foo2({ $^x * $^y }), 6); 24 31 25 32 # vim: ft=perl6 :
