Changeset 6682
- Timestamp:
- 09/04/05 09:32:39 (3 years ago)
- Location:
- src/Pugs
- Files:
-
- 3 modified
-
Compile.hs (modified) (2 diffs)
-
Internals.hs (modified) (2 diffs)
-
Parser.hs (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Compile.hs
r6594 r6682 18 18 TParam(..), 19 19 EnterClass(..), 20 die, varText ,20 die, varText 21 21 ) where 22 22 import Pugs.AST … … 390 390 compile val = return $ PVal val 391 391 392 die :: (MonadIO m, Show a) => String -> a -> m b393 die x y = do394 warn x y395 liftIO $ exitFailure396 397 warn :: (MonadIO m, Show a) => String -> a -> m ()398 warn str val = liftIO $ do399 hPutStrLn stderr $ "*** " ++ str ++ ":\n " ++ show val400 401 392 -- utility functions 402 393 padSort :: (Var, [(TVar Bool, TVar VRef)]) -> (String, [(a, b)]) -> Ordering -
src/Pugs/Internals.hs
r5963 r6682 72 72 maybeM, 73 73 safeMode, 74 warn, 75 die, 74 76 ) where 75 77 … … 147 149 "Internal error:\n " ++ s ++ "\nPlease file a bug report." 148 150 151 die :: (MonadIO m, Show a) => String -> a -> m b 152 die x y = do 153 warn x y 154 liftIO $ exitFailure 155 156 warn :: (MonadIO m, Show a) => String -> a -> m () 157 warn str val = liftIO $ do 158 hPutStrLn stderr $ "*** " ++ str ++ ":\n " ++ show val 159 149 160 split :: (Eq a) => [a] -> [a] -> [[a]] 150 161 split [] _ = internalError "splitting by an empty list" -
src/Pugs/Parser.hs
r6673 r6682 34 34 import Pugs.Parser.Number 35 35 import Pugs.Parser.Unsafe 36 37 fixities :: [String] 38 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: " 39 40 isOperatorName :: String -> Bool 41 isOperatorName ('&':opa@(_:opb)) = isOperatorName' opa || isOperatorName' opb 42 where 43 isOperatorName' :: String -> Bool 44 isOperatorName' oper = or (map (flip isPrefixOf oper) fixities) 45 isOperatorName _ = False 36 46 37 47 -- Lexical units -------------------------------------------------- … … 369 379 ruleSubDeclaration :: RuleParser Exp 370 380 ruleSubDeclaration = rule "subroutine declaration" $ do 371 --namePos <- getPosition381 namePos <- getPosition 372 382 (scope, typ, isMulti, styp, name) <- tryChoice 373 383 [ ruleSubScopedWithContext … … 421 431 isBuiltin = ("builtin" `elem` traits) 422 432 isExported = ("export" `elem` traits) 433 434 -- XXX this belongs in semantic analysis, not in the parser 435 -- also, maybe we should only warn when you try to export an 436 -- operator that is "standard" 437 -- XXX I can't figure out how to do this without trace 438 when (isExported && isOperatorName name) $ 439 trace 440 ("You probably don't want to export an operator name; instead\n\ 441 define a new variant on the new operator (eg. multi sub *infix:<+>):" 442 ++ show name ++ " at " ++ show namePos) 443 (return ()) 444 423 445 -- Don't add the sub if it's unsafe and we're in safemode. 424 446 if "unsafe" `elem` traits && safeMode then return emptyExp else case scope of … … 464 486 <|> between (char '\171') (char '\187') (many1 $ satisfy (/= '\187')) 465 487 return $ fixity ++ name 466 where467 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 488 469 489
