From 0a0f200a79a9e78b97addda6bd8e879d8c1c5d3e Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Sat, 19 Oct 2024 02:36:56 -0600 Subject: 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. --- src/Language/Fiddle/Parser.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Language/Fiddle/Parser.hs') 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) -- cgit