summaryrefslogtreecommitdiff
path: root/src/Language/Fiddle/Parser.hs
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-10-19 02:36:56 -0600
committerJosh Rahm <joshuarahm@gmail.com>2024-10-19 02:36:56 -0600
commit0a0f200a79a9e78b97addda6bd8e879d8c1c5d3e (patch)
treec0c58bc9d4ae044624c039b3004b86fdc7cbbdc7 /src/Language/Fiddle/Parser.hs
parente9ed9fe9aae2c0ac913cf1d175166e983e0a1b30 (diff)
downloadfiddle-0a0f200a79a9e78b97addda6bd8e879d8c1c5d3e.tar.gz
fiddle-0a0f200a79a9e78b97addda6bd8e879d8c1c5d3e.tar.bz2
fiddle-0a0f200a79a9e78b97addda6bd8e879d8c1c5d3e.zip
Change the AST to use Names instead of Identifiers for ObjDecls and BitsDecls
This is to make anonymous expansion better and cleaner. It gets rid of the hash-mark hack introduced earlier.
Diffstat (limited to 'src/Language/Fiddle/Parser.hs')
-rw-r--r--src/Language/Fiddle/Parser.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Language/Fiddle/Parser.hs b/src/Language/Fiddle/Parser.hs
index 7ef5ac4..ad96724 100644
--- a/src/Language/Fiddle/Parser.hs
+++ b/src/Language/Fiddle/Parser.hs
@@ -135,6 +135,9 @@ importStatementP =
<*> optionMaybe importListP
<*> pure Vacant
+nameToIdent :: PaS Identifier -> PaS Name
+nameToIdent ifn = withMeta $ Name . pure <$> ident
+
fiddleDeclP :: Pa FiddleDecl
fiddleDeclP = do
withMeta $ do
@@ -147,11 +150,11 @@ fiddleDeclP = do
<*> defer body packageBodyP
KWUsing -> UsingDecl Witness <$> name
KWLocation -> LocationDecl noQMd <$> ident <*> (tok TokEq >> constExpressionP)
- KWBits -> BitsDecl noQMd <$> ident <*> (tok TokColon >> bitTypeP)
+ KWBits -> BitsDecl noQMd <$> nameToIdent ident <*> (tok TokColon >> bitTypeP)
KWImport -> ImportDecl <$> importStatementP
KWType ->
ObjTypeDecl noQMd
- <$> ident
+ <$> nameToIdent ident
<*> ( do
tok_ TokColon
bt <- bodyTypeP
@@ -190,7 +193,7 @@ objTypeP = do
AnonymousObjType Witness <$> defer body (objTypeBodyP t)
)
-asConstP :: Pa (Expression u) -> Pa (ConstExpression u)
+asConstP :: Pa (Expression u) -> Pa (ConstExpression u)
asConstP fn = withMeta $ ConstExpression . RightV <$> fn
exprInParenP :: Pa (Expression u)