sindre 0.1 → 0.2
raw patch · 6 files changed
+15/−15 lines, 6 files
Files
- Sindre/Compiler.hs +4/−4
- Sindre/Parser.hs +7/−7
- Sindre/Runtime.hs +1/−1
- Sindre/Sindre.hs +1/−1
- sindre.1 +1/−1
- sindre.cabal +1/−1
Sindre/Compiler.hs view
@@ -446,7 +446,7 @@ compileExpr (e1 `LessEql` e2) = compileBinop e1 e2 $ \v1 v2 _ -> return $! if v1 <= v2 then truth else falsity-compileExpr (P _ (k `Lookup` e1) `Assign` e2) = do+compileExpr (P _ (P _ (Var k) `Lookup` e1) `Assign` e2) = do e1' <- descend compileExpr e1 e2' <- descend compileExpr e2 k' <- value k@@ -473,13 +473,13 @@ return v _ -> bad "Not an object" compileExpr (_ `Assign` _) = compileError "Cannot assign to rvalue"-compileExpr (k `Lookup` fe) = do+compileExpr (e `Lookup` fe) = do fe' <- descend compileExpr fe- k' <- value k+ e' <- descend compileExpr e bad <- runtimeError return $ do v <- fe'- o <- k'+ o <- e' case o of Dict m -> return $ fromMaybe falsity $! M.lookup v m _ -> bad "Not a dictionary"
Sindre/Parser.hs view
@@ -307,9 +307,13 @@ , postfix "++" PostInc , prefix "--" $ preop Plus (Literal $ Number $ -1)- , postfix "--" PostDec ]- , [ binary "**" RaisedTo AssocRight,- binary "^" RaisedTo AssocRight ]+ , postfix "--" PostDec+ , Postfix $ do p <- position+ brackets $ do+ idx <- expression+ pure (\e -> P p $ e `Lookup` idx)]+ , [ binary "**" RaisedTo AssocRight+ , binary "^" RaisedTo AssocRight ] , [ prefix "-" $ \e -> Times (Literal (Number $ -1) `at` e) e , prefix "+" $ \(P _ e) -> e , prefix "!" Not ]@@ -358,7 +362,6 @@ atomic :: Parser (P Expr) atomic = parens expression <|> node (Literal <$> literal)- <|> dictlookup literal :: Parser Value literal = pure Number <*> decimal@@ -392,9 +395,6 @@ fcall :: Parser (P Expr) fcall = node $ pure Funcall <*> varName <*> parens (sepBy expression comma)-dictlookup :: Parser (P Expr)-dictlookup = node $ pure Lookup <*> varName <*>- brackets expression check :: (a -> Bool) -> a -> Parser a check f x | f x = return x check _ _ = fail "Failed check"
Sindre/Runtime.hs view
@@ -215,7 +215,7 @@ getEvent = maybe popQueue (return . Just) =<< getBackEvent waitForEvent :: MonadBackend m => Sindre m Event-waitForEvent = liftM2 fromMaybe waitForBackEvent popQueue+waitForEvent = maybe waitForBackEvent return =<< popQueue broadcast :: MonadBackend im => Event -> ObjectM o im () broadcast e = sindre $ modify $ \s -> s { evtQueue = evtQueue s |> e }
Sindre/Sindre.hs view
@@ -356,7 +356,7 @@ data Expr = Literal Value | Var Identifier | FieldOf Identifier (P Expr)- | Lookup Identifier (P Expr)+ | Lookup (P Expr) (P Expr) | Not (P Expr) | LessThan (P Expr) (P Expr) | LessEql (P Expr) (P Expr)
sindre.1 view
@@ -1,4 +1,4 @@-.TH SINDRE 1 sindre\-1.0+.TH SINDRE 1 sindre\-0.2 .SH NAME sindre \- GUI programming language .SH SYNOPSIS
sindre.cabal view
@@ -1,5 +1,5 @@ name: sindre-version: 0.1+version: 0.2 homepage: http://sigkill.dk/programs/sindre synopsis: A programming language for simple GUIs description: