diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-10-05 17:13:26 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-10-05 17:13:26 -0600 |
commit | 3ceedaf5f5193fadadcb011c40df1688cfed279d (patch) | |
tree | 772c8a0c607d68e287addc59bdde71172edd10b1 /src/Language/Fiddle/Parser.hs | |
parent | 407e41489cc22fbf0518fd370530f8857b8c3ed0 (diff) | |
download | fiddle-3ceedaf5f5193fadadcb011c40df1688cfed279d.tar.gz fiddle-3ceedaf5f5193fadadcb011c40df1688cfed279d.tar.bz2 fiddle-3ceedaf5f5193fadadcb011c40df1688cfed279d.zip |
Implement qualification.
Big change. Implements qualification, which separates the qualification
concerns from the ConsistencyCheck phase.
I'm getting close to implementing a backend.
Diffstat (limited to 'src/Language/Fiddle/Parser.hs')
-rw-r--r-- | src/Language/Fiddle/Parser.hs | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/Language/Fiddle/Parser.hs b/src/Language/Fiddle/Parser.hs index 00cce27..a2368ed 100644 --- a/src/Language/Fiddle/Parser.hs +++ b/src/Language/Fiddle/Parser.hs @@ -137,15 +137,15 @@ fiddleDeclP = do case t of KWOption -> OptionDecl <$> nextTextP <*> nextTextP KWPackage -> - PackageDecl () + PackageDecl (pure ()) <$> name <*> defer body packageBodyP KWUsing -> UsingDecl (Witness ()) <$> name - KWLocation -> LocationDecl () <$> ident <*> (tok TokEq >> expressionP) - KWBits -> BitsDecl () <$> ident <*> (tok TokColon >> bitTypeP) + KWLocation -> LocationDecl (pure ()) <$> ident <*> (tok TokEq >> expressionP) + KWBits -> BitsDecl (pure ()) <$> ident <*> (tok TokColon >> bitTypeP) KWImport -> ImportDecl <$> importStatementP KWType -> - ObjTypeDecl () + ObjTypeDecl (pure ()) <$> ident <*> ( do tok_ TokColon @@ -153,7 +153,7 @@ fiddleDeclP = do defer body (objTypeBodyP bt) ) KWInstance -> - ObjectDecl () + ObjectDecl (pure ()) <$> ident <*> (tok KWAt *> expressionP) <*> (tok TokColon *> objTypeP) @@ -179,7 +179,7 @@ objTypeP = do baseObjP :: P (A -> ObjType Parsed F A) baseObjP = - (ReferencedObjType () <$> name) + (ReferencedObjType (pure ()) <$> name) <|> ( do t <- bodyTypeP AnonymousObjType (Witness ()) <$> defer body (objTypeBodyP t) @@ -279,7 +279,7 @@ registerBitsTypeRefP = do withMeta $ (RegisterBitsJustBits <$> exprInParenP) <|> (RegisterBitsAnonymousType (Witness ()) <$> anonymousBitsTypeP) - <|> (RegisterBitsReference () <$> name) + <|> (RegisterBitsReference (pure ()) <$> name) anonymousBitsTypeP :: Pa AnonymousBitsType anonymousBitsTypeP = withMeta $ do @@ -307,12 +307,14 @@ enumConstantDeclP = <|> (EnumConstantDecl <$> ident <*> (tok TokEq >> expressionP)) expressionP :: Pa Expression -expressionP = withMeta $ - token $ \case - (TokLitNum num) -> Just (LitNum num) - (TokIdent i) -> Just $ - \(Commented cs s) -> Var (Identifier i (Commented [] s)) (Commented cs s) - _ -> Nothing +expressionP = + withMeta $ + token + ( \case + (TokLitNum num) -> Just (LitNum num) + _ -> Nothing + ) + <|> (Var <$> name) body :: P [Token SourceSpan] body = do |