Changeset 10356 for src/Pugs/Eval

Show
Ignore:
Timestamp:
05/15/06 21:26:00 (3 years ago)
Author:
gaal
Message:

r10423@sike: roo | 2006-05-15 21:52:25 +0300

  • parse and honor [\] metaoperator
  • produce builtin
  • update tests
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Eval/Var.hs

    r10282 r10356  
    219219            } 
    220220    possiblyBuildMetaopVCode :: String -> Eval (Maybe VCode) 
    221     possiblyBuildMetaopVCode op' | "&prefix:[" `isPrefixOf` op', "]" `isSuffixOf` op' = do  
     221    possiblyBuildMetaopVCode op'' | "&prefix:[" `isPrefixOf` op'', "]" `isSuffixOf` op'' = do  
    222222        -- Strip the trailing "]" from op 
    223         let op = drop 9 (init op') 
     223        let op' = drop 9 (init op'') 
     224        let (op, keep) | '\\':real <- op' = (real, True) 
     225                       | otherwise        = (op', False) 
    224226        -- We try to find the userdefined sub. 
    225227        -- We use the first two elements of invs as invocants, as these are the 
     
    227229            rv = fmap (either (const Nothing) Just) $ findSub ("&infix:" ++ op) Nothing (take 2 $ args ++ [Val undef, Val undef]) 
    228230        maybeM rv $ \code -> return $ mkPrim 
    229             { subName     = "&prefix:[" ++ op ++ "]" 
     231            { subName     = "&prefix:[" ++ (if keep then "\\" else "") ++ op ++ "]" 
    230232            , subType     = SubPrim 
    231233            , subAssoc    = "spre" 
     
    237239            , subBody     = Prim $ \[vs] -> do 
    238240                list_of_args <- fromVal vs 
    239                 op2Reduce list_of_args (VCode code) 
     241                op2Reduce keep list_of_args (VCode code) 
    240242            } 
    241243        -- Now we construct the sub. Is there a more simple way to do it?