aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Parser.hs
diff options
context:
space:
mode:
authorMarvin Borner2023-08-25 13:39:04 +0200
committerMarvin Borner2023-09-03 17:18:44 +0200
commit1f985159c3ca5d15a2229a495b2c15a5a1af2dd6 (patch)
tree090a2bee24f169ebafb311199b3ba6838b3f1ac5 /src/Parser.hs
parent06002dd74add24ece55453088e3df0f6c37f0105 (diff)
Added De Bruijn numerals
Diffstat (limited to 'src/Parser.hs')
-rw-r--r--src/Parser.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Parser.hs b/src/Parser.hs
index 12214a0..470c18f 100644
--- a/src/Parser.hs
+++ b/src/Parser.hs
@@ -118,13 +118,14 @@ parseNumeral :: Parser Expression
parseNumeral = do
_ <- string "(" <?> "number start"
num <- number <?> "signed number"
- base <- try (oneOf "ubt") <|> return 't'
+ base <- try (oneOf "dubt") <|> return 't'
_ <- string ")" <?> "number end"
pure $ f base num
where
f 't' = decimalToTernary
f 'b' = decimalToBinary
f 'u' = decimalToUnary
+ f 'd' = decimalToDeBruijn
f _ = invalidProgramState
sign :: Parser (Integer -> Integer)
sign = (char '-' >> return negate) <|> (char '+' >> return id)