summaryrefslogtreecommitdiff
path: root/src/Language/Fiddle/Parser.hs
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-10-11 18:45:34 -0600
committerJosh Rahm <joshuarahm@gmail.com>2024-10-11 18:45:34 -0600
commitda0d596946cf21e2f275dd03b40c0a6c0824f66b (patch)
tree517763d8d0613dc0f1b138eb2434a2a709383227 /src/Language/Fiddle/Parser.hs
parent6ce692d61e8486c103a8492b0ec372858b29de50 (diff)
downloadfiddle-da0d596946cf21e2f275dd03b40c0a6c0824f66b.tar.gz
fiddle-da0d596946cf21e2f275dd03b40c0a6c0824f66b.tar.bz2
fiddle-da0d596946cf21e2f275dd03b40c0a6c0824f66b.zip
Change 'Expression' to use numbers with units.
This helps to catch bugs in the compiler, specifically ones related to mixing up bits and bytes.
Diffstat (limited to 'src/Language/Fiddle/Parser.hs')
-rw-r--r--src/Language/Fiddle/Parser.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Language/Fiddle/Parser.hs b/src/Language/Fiddle/Parser.hs
index 8d2eab2..8070c1c 100644
--- a/src/Language/Fiddle/Parser.hs
+++ b/src/Language/Fiddle/Parser.hs
@@ -190,7 +190,7 @@ objTypeP = do
AnonymousObjType Witness <$> defer body (objTypeBodyP t)
)
-exprInParenP :: Pa Expression
+exprInParenP :: Pa (Expression u)
exprInParenP = tok TokLParen *> expressionP <* tok TokRParen
objTypeBodyP :: BodyType F (Commented SourceSpan) -> Pa ObjTypeBody
@@ -311,12 +311,12 @@ enumConstantDeclP =
(tok KWReserved >> EnumConstantReserved <$> (tok TokEq >> expressionP))
<|> (EnumConstantDecl <$> ident <*> (tok TokEq >> expressionP))
-expressionP :: Pa Expression
+expressionP :: Pa (Expression u)
expressionP =
withMeta $
token
( \case
- (TokLitNum num) -> Just (LitNum num)
+ (TokLitNum num) -> Just (LitNum $ LeftV num)
_ -> Nothing
)
<|> (Var <$> name)