summaryrefslogtreecommitdiff
path: root/DSL/StdLib.hs
diff options
context:
space:
mode:
Diffstat (limited to 'DSL/StdLib.hs')
-rw-r--r--DSL/StdLib.hs37
1 files changed, 37 insertions, 0 deletions
diff --git a/DSL/StdLib.hs b/DSL/StdLib.hs
new file mode 100644
index 0000000..6483433
--- /dev/null
+++ b/DSL/StdLib.hs
@@ -0,0 +1,37 @@
+module DSL.StdLib (stdlib) where
+
+import DSL.Types
+import DSL.BaseParsers (parse, mult, chain)
+import DSL.Parsing (tokenizer, procP)
+
+stdlib :: [ProcSpec]
+stdlib = procs
+ where
+ p = tokenizer `chain` mult procP
+ procs = case parse p (unlines sources) of
+ Nothing -> error "Failed to parse standard library"
+ Just (_, ps) -> ps
+
+sources :: [String]
+sources = [ div'
+ , mod'
+ , lteq
+ , gteq
+ , neq
+ ]
+
+div' :: String
+div' = "PROC / /% DROP END"
+
+mod' :: String
+mod' = "PROC % /% SWAP DROP END"
+
+lteq :: String
+lteq = "PROC <= OVER OVER == ROT < || END"
+
+gteq :: String
+gteq = "PROC >= OVER OVER == ROT > || END"
+
+neq :: String
+neq = "PROC != == ! END"
+