diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-10-03 12:58:38 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-10-03 12:58:38 -0600 |
commit | 5d0b8e6371d1e365ff9b10e0160a39f0f1d9f359 (patch) | |
tree | 7a4afc937e94365e486bf978dc7d91e5a20ef04e /src/Language/Fiddle/Ast/Internal/SyntaxTree.hs | |
parent | ae5ea355a32eff2b1b1762f4ac2389d94f388df7 (diff) | |
download | fiddle-5d0b8e6371d1e365ff9b10e0160a39f0f1d9f359.tar.gz fiddle-5d0b8e6371d1e365ff9b10e0160a39f0f1d9f359.tar.bz2 fiddle-5d0b8e6371d1e365ff9b10e0160a39f0f1d9f359.zip |
Make changes to AST for qualification step.
Diffstat (limited to 'src/Language/Fiddle/Ast/Internal/SyntaxTree.hs')
-rw-r--r-- | src/Language/Fiddle/Ast/Internal/SyntaxTree.hs | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/src/Language/Fiddle/Ast/Internal/SyntaxTree.hs b/src/Language/Fiddle/Ast/Internal/SyntaxTree.hs index 8eb8c8e..9c6718c 100644 --- a/src/Language/Fiddle/Ast/Internal/SyntaxTree.hs +++ b/src/Language/Fiddle/Ast/Internal/SyntaxTree.hs @@ -11,6 +11,7 @@ module Language.Fiddle.Ast.Internal.SyntaxTree NumberType, ImportInterface, FiddleUnitInterface, + QualificationMetadata, -- Witness Types Witness (..), WitnessType, @@ -75,6 +76,14 @@ import Language.Fiddle.Internal.UnitInterface (UnitInterface) type TreeType t stage = t stage (StageFunctor stage) (StageAnnotation stage) +type FullyQualifiedName = String + +type family QualificationMetadata stage t where + QualificationMetadata stage t = + If (stage < Qualified) () t + +-- | The type attached to import statements which describe the imported file's +-- unit interface type family FiddleUnitInterface (s :: Stage) :: Type where FiddleUnitInterface s = If (s < Checked) () UnitInterface @@ -328,7 +337,10 @@ data FiddleDecl :: StagedSynTree where FiddleDecl stage f a -- | A using declaration. UsingDecl :: - { -- | The name being used. + { -- Using decls should be removed during qualification. + disableUsingDeclAfterQualification :: Witness True, -- TODO change to < Qualified. + + -- | The name being used. usingName :: Name f a, -- | Annotation for the using declaration. usingAnnot :: a @@ -336,7 +348,9 @@ data FiddleDecl :: StagedSynTree where FiddleDecl stage f a -- | A package declaration. PackageDecl :: - { -- | The package name. + { -- | Qualification metadata about this package statement. + packageQualificationMetadata :: QualificationMetadata stage (), + -- | The package name. packageName :: Name f a, -- | The body of the package. packageBody :: f (PackageBody stage f a), @@ -346,7 +360,9 @@ data FiddleDecl :: StagedSynTree where FiddleDecl stage f a -- | A location declaration in the form 'location <identifier> = <expr>'. LocationDecl :: - { -- | The location identifier. + { -- | qualified metadata about this location. + locationQualificationMetadata :: QualificationMetadata stage (), + -- | The location identifier. locationIdent :: Identifier f a, -- | The associated expression. locationExpr :: Expression stage f a, @@ -356,7 +372,9 @@ data FiddleDecl :: StagedSynTree where FiddleDecl stage f a -- | A bits declaration in the form 'bits <identifier> : <type>'. BitsDecl :: - { -- | The identifier of the bits. + { -- | Qualification metadata about this "bits" declaration. + bitsQualificationMetadata :: QualificationMetadata stage (), + -- | The identifier of the bits. bitsIdent :: Identifier f a, -- | The type of the bits. bitsType :: BitType stage f a, @@ -366,7 +384,9 @@ data FiddleDecl :: StagedSynTree where FiddleDecl stage f a -- | An object type declaration. ObjTypeDecl :: - { -- | The identifier of the object type. + { -- | Qualification metadata about this object type. + objTypeQualificationMetadata :: QualificationMetadata stage (), + -- | The identifier of the object type. objTypeIdent :: Identifier f a, -- | The body of the object type. objTypeBody :: f (ObjTypeBody stage f a), @@ -376,7 +396,9 @@ data FiddleDecl :: StagedSynTree where FiddleDecl stage f a -- | An object declaration in the form 'object <ident> at <expr> : <type>'. ObjectDecl :: - { -- | The identifier of the object. + { -- | Qualification metadata about this object. + objectQualificationMetadata :: QualificationMetadata stage (), + -- | The identifier of the object. objectIdent :: Identifier f a, -- | The location expression. objectLocation :: Expression stage f a, @@ -408,7 +430,7 @@ data ObjType stage f a where -- | An anonymous object type, allowed only in Parsed. AnonymousObjType :: { -- | Witness for stage constraint. - anonWitness :: Witness (stage < Expanded), + disableAnonymousTypesAfterExpansion :: Witness (stage < Expanded), -- | The body of the anonymous type. anonBody :: f (ObjTypeBody stage f a), -- | Annotation for the anonymous type. @@ -427,7 +449,8 @@ data ObjType stage f a where ObjType stage f a -- | A reference to an existing type by name. ReferencedObjType :: - { -- | The name of the referenced type. + { refQualificationMetadata :: QualificationMetadata stage (), + -- | The name of the referenced type. refName :: Name f a, -- | Annotation for the referenced type. refAnnot :: a @@ -441,7 +464,7 @@ data ObjTypeDecl stage f a where -- | An assertion statement for a specific position. AssertPosStatement :: { -- | Witness for stage constraint. - assertWitness :: Witness (stage < Checked), + disableAssertStatementsAfterConsistencyCheck :: Witness (stage < Checked), -- | The expression for the assertion. assertExpr :: Expression stage f a, -- | Annotation for the assertion. @@ -586,7 +609,9 @@ data RegisterBitsTypeRef stage f a where RegisterBitsTypeRef stage f a -- | A reference to another type by name. RegisterBitsReference :: - { -- | The name of the referenced type. + { -- | Qualification metadata about this Bits reference. + bitsRefQualificationMetadata :: QualificationMetadata stage (), + -- | The name of the referenced type. bitsRefName :: Name f a, -- | Annotation for the reference. bitsRefAnnot :: a @@ -595,7 +620,7 @@ data RegisterBitsTypeRef stage f a where -- | An anonymous type for register bits, used in Parsed. RegisterBitsAnonymousType :: { -- | Witness for stage constraint. - anonBitsWitness :: Witness (stage < Expanded), + disableAnonymousBitsAfterExpansion :: Witness (stage < Expanded), -- | The anonymous type. anonBitsType :: AnonymousBitsType stage f a, -- | Annotation for the anonymous type. |