language-Modula2-0.1: Parser, pretty-printer, and more for the Modula-2 programming language
Safe HaskellNone
LanguageHaskell2010

Language.Modula2.ISO.ConstantFolder

Description

The main export of this module is the function foldConstants that folds the constants in an ISO Modula-2 AST using an attribute grammar. Other exports are helper functions and attribute types that can be reused for other languages or attribute grammars.

Synopsis

Documentation

foldConstants :: forall l. (Modula2 l, Nameable l, Ord (QualIdent l), Show (QualIdent l), Atts (Inherited (Auto ConstantFold)) (Block l l Sem Sem) ~ InhCF l, Atts (Inherited (Auto ConstantFold)) (Definition l l Sem Sem) ~ InhCF l, Atts (Inherited (Auto ConstantFold)) (Expression l l Sem Sem) ~ InhCF l, Atts (Synthesized (Auto ConstantFold)) (Block l l Sem Sem) ~ SynCFMod' l (Block l l), Atts (Synthesized (Auto ConstantFold)) (Block l l Placed Placed) ~ SynCFMod' l (Block l l), Atts (Synthesized (Auto ConstantFold)) (Definition l l Sem Sem) ~ SynCFMod' l (Definition l l), Atts (Synthesized (Auto ConstantFold)) (Definition l l Placed Placed) ~ SynCFMod' l (Definition l l), Atts (Synthesized (Auto ConstantFold)) (Expression l l Sem Sem) ~ SynCFExp l l, Atts (Synthesized (Auto ConstantFold)) (Expression l l Placed Placed) ~ SynCFExp l l, Functor (Auto ConstantFold) (Block l l), Functor (Auto ConstantFold) (Definition l l), Functor (Auto ConstantFold) (Expression l l)) => Environment l -> Module l l Placed Placed -> Module l l Placed Placed Source #

Fold the constants in the given collection of Modula-2 modules (a Map of modules keyed by module name). It uses the constant declarations from the modules as well as the given Environment of predefined constants and functions.

Note that the ISO Modula-2 Language satisfies all constraints in the function's type signature.

data InhCF l #

Instances

Instances details
Generic (InhCF l) 
Instance details

Defined in Language.Oberon.ConstantFolder

Associated Types

type Rep (InhCF l) :: Type -> Type #

Methods

from :: InhCF l -> Rep (InhCF l) x #

to :: Rep (InhCF l) x -> InhCF l #

type Rep (InhCF l) 
Instance details

Defined in Language.Oberon.ConstantFolder

type Rep (InhCF l) = D1 ('MetaData "InhCF" "Language.Oberon.ConstantFolder" "language-oberon-0.3-9UwQStBT68GEv7WM30Tf5c" 'False) (C1 ('MetaCons "InhCF" 'PrefixI 'True) (S1 ('MetaSel ('Just "env") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Environment l)) :*: S1 ('MetaSel ('Just "currentModule") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Ident)))

data SynCF a #

Constructors

SynCF 

Fields

Instances

Instances details
Generic (SynCF a) 
Instance details

Defined in Language.Oberon.ConstantFolder

Associated Types

type Rep (SynCF a) :: Type -> Type #

Methods

from :: SynCF a -> Rep (SynCF a) x #

to :: Rep (SynCF a) x -> SynCF a #

type Rep (SynCF a) 
Instance details

Defined in Language.Oberon.ConstantFolder

type Rep (SynCF a) = D1 ('MetaData "SynCF" "Language.Oberon.ConstantFolder" "language-oberon-0.3-9UwQStBT68GEv7WM30Tf5c" 'False) (C1 ('MetaCons "SynCF" 'PrefixI 'True) (S1 ('MetaSel ('Just "folded") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Mapped Placed a))))

data SynCFDesignator l #

Instances

Instances details
Generic (SynCFDesignator l) 
Instance details

Defined in Language.Oberon.ConstantFolder

Associated Types

type Rep (SynCFDesignator l) :: Type -> Type #

type Rep (SynCFDesignator l) 
Instance details

Defined in Language.Oberon.ConstantFolder

type Rep (SynCFDesignator l) = D1 ('MetaData "SynCFDesignator" "Language.Oberon.ConstantFolder" "language-oberon-0.3-9UwQStBT68GEv7WM30Tf5c" 'False) (C1 ('MetaCons "SynCFDesignator" 'PrefixI 'True) (S1 ('MetaSel ('Just "folded") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Mapped Placed (Designator l l Placed Placed))) :*: S1 ('MetaSel ('Just "designatorValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Placed (Value l l Placed Placed))))))

data SynCFExp λ l #

type SynCFMod' l (node :: (Type -> Type) -> (Type -> Type) -> Type) = SynCFMod l (node Placed Placed) #

Orphan instances

(Nameable l, k ~ QualIdent l, v ~ Value l l Placed Placed, Ord k, Atts (Synthesized (Auto ConstantFold)) (Declaration l l Sem Sem) ~ SynCFMod' l (Declaration l l)) => SynthesizedField "moduleEnv" (Map k (Maybe v)) (Auto ConstantFold) (Block l l) Sem Placed Source # 
Instance details

Methods

synthesizedField :: forall (sem :: Type -> Type). sem ~ Semantics (Auto ConstantFold) => Proxy "moduleEnv" -> Auto ConstantFold -> Placed (Block l l Sem Sem) -> Atts (Inherited (Auto ConstantFold)) (Block l l sem sem) -> Block l l sem (Synthesized (Auto ConstantFold)) -> Map k (Maybe v) #

(Modula2 l, Nameable l, k ~ QualIdent l, Ord k, v ~ Value l l Placed Placed, Export l ~ Export l, Value l ~ Value l, Atts (Synthesized (Auto ConstantFold)) (Declaration l l Sem Sem) ~ SynCFMod' l (Declaration l l), Atts (Synthesized (Auto ConstantFold)) (Type l l Sem Sem) ~ SynCF' (Type l l), Atts (Synthesized (Auto ConstantFold)) (ProcedureHeading l l Sem Sem) ~ SynCF' (ProcedureHeading l l), Atts (Synthesized (Auto ConstantFold)) (FormalParameters l l Sem Sem) ~ SynCF' (FormalParameters l l), Atts (Synthesized (Auto ConstantFold)) (Block l l Sem Sem) ~ SynCFMod' l (Block l l), Atts (Synthesized (Auto ConstantFold)) (ConstExpression l l Sem Sem) ~ SynCFExp l l) => SynthesizedField "moduleEnv" (Map k (Maybe v)) (Auto ConstantFold) (Declaration full l l) Sem Placed Source # 
Instance details

Methods

synthesizedField :: forall (sem :: Type -> Type). sem ~ Semantics (Auto ConstantFold) => Proxy "moduleEnv" -> Auto ConstantFold -> Placed (Declaration full l l Sem Sem) -> Atts (Inherited (Auto ConstantFold)) (Declaration full l l sem sem) -> Declaration full l l sem (Synthesized (Auto ConstantFold)) -> Map k (Maybe v) #

(Functor (Auto ConstantFold) (Statement l l), At (Auto ConstantFold) (Statement l l (Codomain (Auto ConstantFold)) (Codomain (Auto ConstantFold)))) => Functor (Auto ConstantFold) (Statement l l) Source # 
Instance details

(Functor (Auto ConstantFold) (Block l l), At (Auto ConstantFold) (Block l l (Codomain (Auto ConstantFold)) (Codomain (Auto ConstantFold)))) => Functor (Auto ConstantFold) (Block l l) Source # 
Instance details

(Functor (Auto ConstantFold) (Variant l l), At (Auto ConstantFold) (Variant l l (Codomain (Auto ConstantFold)) (Codomain (Auto ConstantFold)))) => Functor (Auto ConstantFold) (Variant l l) Source # 
Instance details

(Functor (Auto ConstantFold) (Item l l), At (Auto ConstantFold) (Item l l (Codomain (Auto ConstantFold)) (Codomain (Auto ConstantFold)))) => Functor (Auto ConstantFold) (Item l l) Source # 
Instance details

(Functor (Auto ConstantFold) (Expression l l), At (Auto ConstantFold) (Expression l l (Codomain (Auto ConstantFold)) (Codomain (Auto ConstantFold)))) => Functor (Auto ConstantFold) (Expression l l) Source # 
Instance details

(Functor (Auto ConstantFold) (Type l l), At (Auto ConstantFold) (Type l l (Codomain (Auto ConstantFold)) (Codomain (Auto ConstantFold)))) => Functor (Auto ConstantFold) (Type l l) Source # 
Instance details

(Functor (Auto ConstantFold) (AddressedIdent l l), At (Auto ConstantFold) (AddressedIdent l l (Codomain (Auto ConstantFold)) (Codomain (Auto ConstantFold)))) => Functor (Auto ConstantFold) (AddressedIdent l l) Source # 
Instance details

(Nameable l, Ord (QualIdent l), Atts (Synthesized (Auto ConstantFold)) (Declaration l l Sem Sem) ~ SynCFMod' l (Declaration l l), Atts (Inherited (Auto ConstantFold)) (StatementSequence l l Sem Sem) ~ InhCF l, Atts (Inherited (Auto ConstantFold)) (Declaration l l Sem Sem) ~ InhCF l) => Bequether (Auto ConstantFold) (Block l l) Sem Placed Source # 
Instance details

Methods

bequest :: forall (sem :: Type -> Type). sem ~ Semantics (Auto ConstantFold) => Auto ConstantFold -> Placed (Block l l Sem Sem) -> Atts (Inherited (Auto ConstantFold)) (Block l l sem sem) -> Block l l sem (Synthesized (Auto ConstantFold)) -> Block l l sem (Inherited (Auto ConstantFold)) #

(Nameable l, Ord (QualIdent l), QualIdent l ~ QualIdent l, Value l ~ Value l, λ ~ Language, Coercible (QualIdent Language) (QualIdent l), Coercible (Value Language Language) (Value l l), InhCF l ~ InhCF λ, Pretty (Value l l Identity Identity), Atts (Synthesized (Auto ConstantFold)) (Expression l l Sem Sem) ~ SynCFExp l l, Atts (Synthesized (Auto ConstantFold)) (Element l l Sem Sem) ~ SynCF' (Element l l), Atts (Synthesized (Auto ConstantFold)) (Item l l Sem Sem) ~ SynCF' (Item l l), Atts (Synthesized (Auto ConstantFold)) (Designator l l Sem Sem) ~ SynCFDesignator l) => Synthesizer (Auto ConstantFold) (Expression λ l) Sem Placed Source # 
Instance details

Methods

synthesis :: forall (sem :: Type -> Type). sem ~ Semantics (Auto ConstantFold) => Auto ConstantFold -> Placed (Expression λ l Sem Sem) -> Atts (Inherited (Auto ConstantFold)) (Expression λ l sem sem) -> Expression λ l sem (Synthesized (Auto ConstantFold)) -> Atts (Synthesized (Auto ConstantFold)) (Expression λ l sem sem) #

(Functor (Auto ConstantFold) (Declaration full l l), At (Auto ConstantFold) (Declaration full l l (Codomain (Auto ConstantFold)) (Codomain (Auto ConstantFold)))) => Functor (Auto ConstantFold) (Declaration full l l) Source # 
Instance details

Attribution (Auto ConstantFold) (Statement l l) Sem Placed => At (Auto ConstantFold) (Statement l l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))) Source # 
Instance details

Attribution (Auto ConstantFold) (Block l l) Sem Placed => At (Auto ConstantFold) (Block l l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))) Source # 
Instance details

Attribution (Auto ConstantFold) (Variant l l) Sem Placed => At (Auto ConstantFold) (Variant l l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))) Source # 
Instance details

Attribution (Auto ConstantFold) (Item l l) Sem Placed => At (Auto ConstantFold) (Item l l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))) Source # 
Instance details

Attribution (Auto ConstantFold) (Expression l l) Sem Placed => At (Auto ConstantFold) (Expression l l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))) Source # 
Instance details

Attribution (Auto ConstantFold) (Type l l) Sem Placed => At (Auto ConstantFold) (Type l l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))) Source # 
Instance details

Attribution (Auto ConstantFold) (AddressedIdent l l) Sem Placed => At (Auto ConstantFold) (AddressedIdent l l (Semantics (Auto ConstantFold)) (Semantics (Auto ConstantFold))) Source # 
Instance details

Attribution (Auto ConstantFold) (Declaration full l l) Sem Placed => At (Auto ConstantFold) (Declaration full l l Sem Sem) Source # 
Instance details