Changeset 3388 for src/Pugs/Parser.hs
- Timestamp:
- 05/18/05 16:06:00 (4 years ago)
- svk:copy_cache_prev:
- 4977
- Files:
-
- 1 modified
-
src/Pugs/Parser.hs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Parser.hs
r3372 r3388 810 810 tightOperators = do 811 811 [optionary, namedUnary, preUnary, postUnary] <- currentUnaryFunctions 812 infixOps <- currentInfixOps 812 813 return $ 813 814 [ methOps " . .+ .? .* .+ .() .[] .{} .<<>> .= " -- Method postfix … … 823 824 " >>*<< >>/<< >>x<< >>xx<< >>~<< " ++ 824 825 " * / % x xx +& +< +> ~& ~< ~> " -- Multiplicative 826 , leftOps $ " " ++ unwords infixOps ++ " " -- User defined ops 827 -- XXX: But they shouldn't 828 -- automatically be leftOps, 829 -- right? --iblech 825 830 , leftOps " »+« >>+<< + - ~ +| +^ ~| ~^ ?| " -- Additive 826 831 , listOps " & " -- Junctive And … … 925 930 where 926 931 mapPair f (x, y) = (f x, f y) 932 933 -- Following code is from a Haskell newbie. 934 -- Please check for correctness. --iblech 935 currentInfixOps :: RuleParser [String] 936 currentInfixOps = do 937 -- We retrieve the list of all current functions 938 funs <- currentFunctions 939 -- Then we grep for the &infix:... ones. 940 let (infixs, _) = (`partition` funs) $ \x -> case x of 941 ('i':'n':'f':'i':'x':':':_, _, _) -> True 942 _ -> False 943 -- Finally, we return the names of the ops. 944 -- But we've to s/^infix://, as we've to return (say) "+" instead of "infix:+". 945 return $ map extractName infixs 946 where 947 extractName ('i':'n':'f':'i':'x':':':name, _, _) = encodeUTF8 name 948 -- GHC dies with "non exhaustive patterns" if I omit the following line. 949 -- But as we grep above for /^infix:/, we can't possible branch here. 950 extractName _ = error "Should never happen (Parser.hs:currentInfixOps:extractName)" 927 951 928 952 parseOp :: RuleParser Exp
