Changeset 19198

Show
Ignore:
Timestamp:
12/12/07 20:43:02 (10 months ago)
Author:
ferreira
Message:

r185@dracma: perl | 2007-12-12 17:36:17 -0200
added boolean xor infix operator

Location:
src/Pugs
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Parser/Operator.hs

    r18681 r19198  
    7575symbLevel = preSyn (Set.singleton (MkOpName (cast "|"))) ++ preOps symbPreops 
    7676multLevel = leftOps (opWords " * / % +& +< +> ~& ~< ~> ?& ") 
    77 addiLevel = leftOps (opWords " + - +| +^ ~| ~^ ?| ") 
     77addiLevel = leftOps (opWords " + - +| +^ ~| ~^ ?| ?^ ") 
    7878replLevel = leftOps (opWords " x xx ") 
    7979concLevel = leftOps (opWords " ~ ") 
     
    713713defaultInfixOps = opWords $ concat 
    714714    [ " ** * / % x xx +& +< +> ~& ~< ~> " 
    715     , " + - ~ +| +^ ~| ~^ ?| , Z X minmax " 
     715    , " + - ~ +| +^ ~| ~^ ?| ?^ , Z X minmax " 
    716716    , " & ^ | " 
    717717    , " => = " 
  • src/Pugs/Prim.hs

    r19002 r19198  
    958958perlReplicate = genericReplicate . max 0 
    959959 
     960-- XXX only used at    op2 "?^"   because my Haskell is too poor - ferreira  
     961neBool :: VBool -> VBool -> VBool 
     962neBool = (==) . not 
     963 
    960964-- |Implementation of 2-arity primitive operators and functions 
    961965op2 :: String -> Val -> Val -> Eval Val 
     
    985989op2 "?&" = op2Bool (&&) 
    986990op2 "~^" = op2Str $ mapStr2Fill xor 
     991op2 "?^" = op2Bool neBool -- for bools, 'xor' is the same as '!==' 
    987992op2 "=>" = \x y -> return $ castV (x, y) 
    988993op2 "="  = \x y -> evalExp (Syn "=" [Val x, Val y]) 
     
    21222127\\n   Str       left    ~^      safe   (Str, Str)\ 
    21232128\\n   Bool      left    ?|      safe   (Bool, Bool)\ 
     2129\\n   Bool      left    ?^      safe   (Bool, Bool)\ 
    21242130\\n   Bool      left    ?&      safe   (Bool, Bool)\ 
    21252131\\n   Pair      right   =>      safe   (Any, Any)\