From e9ed9fe9aae2c0ac913cf1d175166e983e0a1b30 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Sat, 19 Oct 2024 01:05:10 -0600 Subject: Provide more data during qualification about how a path is qualified. Now it includes information about the package a symobl is in. The object its in and the register its in. This allows better code generation in the backend that's somewhat more organized. --- src/Language/Fiddle/Parser.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Language/Fiddle/Parser.hs') diff --git a/src/Language/Fiddle/Parser.hs b/src/Language/Fiddle/Parser.hs index dea2dd5..7ef5ac4 100644 --- a/src/Language/Fiddle/Parser.hs +++ b/src/Language/Fiddle/Parser.hs @@ -190,6 +190,9 @@ objTypeP = do AnonymousObjType Witness <$> defer body (objTypeBodyP t) ) +asConstP :: Pa (Expression u) -> Pa (ConstExpression u) +asConstP fn = withMeta $ ConstExpression . RightV <$> fn + exprInParenP :: Pa (Expression u) exprInParenP = tok TokLParen *> expressionP <* tok TokRParen @@ -258,7 +261,7 @@ registerBitsDeclP = tok KWReserved >> ReservedBits <$> exprInParenP ) <|> (BitsSubStructure <$> registerBodyP <*> optionMaybe ident) - <|> ( DefinedBits Vacant + <|> ( DefinedBits Vacant . Perhaps <$> optionMaybe modifierP <*> ident <*> (tok TokColon >> registerBitsTypeRefP) @@ -282,7 +285,7 @@ registerBitsTypeRefP = do baseTypeRef = withMeta $ - (RegisterBitsJustBits <$> exprInParenP) + (RegisterBitsJustBits <$> asConstP exprInParenP) <|> (RegisterBitsAnonymousType Witness <$> anonymousBitsTypeP) <|> (RegisterBitsReference noQMd <$> name) -- cgit