diff options
| author | Matthew Hall <hallmatthew314@gmail.com> | 2023-02-18 16:58:51 +1300 |
|---|---|---|
| committer | Matthew Hall <hallmatthew314@gmail.com> | 2023-02-18 16:58:51 +1300 |
| commit | 8c33b3d2c69b6800ca34155d62c000250980e47e (patch) | |
| tree | 3e3b5a090de5e0bc5e73e0a81271361e1ffe4e3d /DSL/StdLib.hs | |
| parent | f8a928d18371e0b67741f5d75b8154d1c105327b (diff) | |
Introduce stdlib and fix lexing bug
Diffstat (limited to 'DSL/StdLib.hs')
| -rw-r--r-- | DSL/StdLib.hs | 37 |
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" + |
