aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2024-12-29 16:14:54 +0100
committerMarvin Borner2024-12-29 16:15:15 +0100
commitac53a2bf106dccd2de463f7c68c2527ee6e08f4e (patch)
treebd575864819c42f3e2e41802cb8ab82fbc95ed71
parent19ba9b16c3bc3cb16caff7025b4bfa79dbd2fe17 (diff)
better
-rw-r--r--lllars/megaparser.hs6
-rw-r--r--lllars/parser.hs2
2 files changed, 5 insertions, 3 deletions
diff --git a/lllars/megaparser.hs b/lllars/megaparser.hs
index 3d1e713..72bf5ce 100644
--- a/lllars/megaparser.hs
+++ b/lllars/megaparser.hs
@@ -95,7 +95,7 @@ call =
LarsCall
<$> ( string "larssral"
*> space
- *> ((string "lars" $> ReadCall) <|> (string "sral" $> WriteCall))
+ *> ((string "lars" $> WriteCall) <|> (string "sral" $> ReadCall))
)
write :: Parser Instr
@@ -215,6 +215,8 @@ compile ((Write address addressation) : ps) =
<> compileAddressation addressation
<> ";\n"
++ compile ps
+compile ((LarsCall WriteCall) : ps) =
+ "printf(\"%x\", heap[8159]); " ++ compile ps
compile ((LarsCall call ) : ps) = compile ps -- TODO
compile ((Label label) : ps) = "" <> label <> ":\n" ++ compile ps
compile ((GoTo label) : ps) = "goto " <> label <> ";\n" ++ compile ps
@@ -241,7 +243,7 @@ preamble =
"#include <stdio.h>\nint main(int argc, char *argv[]) { unsigned int heap[10000] = { 0 }; "
postamble :: String
-postamble = "printf(\"%x\\n\", heap[8159]); }"
+postamble = "printf(\"amen lars\\n\"); }"
preamblify :: String -> String
preamblify amble = preamble ++ amble ++ postamble
diff --git a/lllars/parser.hs b/lllars/parser.hs
index dfee007..f843849 100644
--- a/lllars/parser.hs
+++ b/lllars/parser.hs
@@ -87,7 +87,7 @@ call =
LarsCall
<$> ( string "larssral"
*> space
- *> ((string "lars" $> ReadCall) <|> (string "sral" $> WriteCall))
+ *> ((string "lars" $> WriteCall) <|> (string "sral" $> ReadCall))
)
write :: Parser Instr