| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Language.Oberon.ConstantFolder
Description
The main export of this module is the function foldConstants that folds the constants in Oberon AST using a attribute grammar. Other exports are helper functions and attribute types that can be reused for other languages or attribute grammars.
This module expects the ambiguities in the AST to be already resolved by the Language.Oberon.Resolver module.
Synopsis
- foldConstants :: (Oberon l, Nameable l, Ord (QualIdent l), Show (QualIdent l), Atts (Inherited (Auto ConstantFold)) (Block l l Sem Sem) ~ InhCF l, Atts (Synthesized (Auto ConstantFold)) (Block l l Sem Sem) ~ SynCFMod' l (Block l l), Functor (Auto ConstantFold) (Block l l), Functor (Auto ConstantFold) (Block l l)) => Environment l -> Map Ident (Placed (Module l l Placed Placed)) -> Map Ident (Placed (Module l l Placed Placed))
- type Placed = (,) (Int, ParsedLexemes, Int)
- type Environment l = Map (QualIdent l) (Maybe (Value l l Placed Placed))
- newtype Modules l f' f = Modules {
- getModules :: Map Ident (f (Module l l f' f'))
- data ConstantFold = ConstantFold
- type Sem = Semantics (Auto ConstantFold)
- data InhCFRoot l = InhCFRoot {
- rootEnv :: Environment l
- data InhCF l = InhCF {
- env :: Environment l
- currentModule :: Ident
- data SynCF a = SynCF {}
- data SynCFMod l a = SynCFMod {
- moduleEnv :: Environment l
- folded :: Mapped Placed a
- data SynCFExp λ l = SynCFExp {}
- data SynCFDesignator l = SynCFDesignator {}
- data SynCFRoot a = SynCFRoot {
- modulesFolded :: a
- type SynCF' node = SynCF (node Placed Placed)
- type SynCFMod' l node = SynCFMod l (node Placed Placed)
- folded' :: SynCF' node -> Mapped Placed (node Placed Placed)
- foldedExp :: SynCFExp λ l -> Mapped Placed (Expression λ l Placed Placed)
- foldedExp' :: SynCFExp λ l -> Placed (Expression λ l Placed Placed)
- foldedMod :: SynCFMod' l node -> Mapped Placed (node Placed Placed)
- literalSynthesis :: (Wirthy λ, Functor (Map Placed Identity) (Value l l), Pretty (Value l l Identity Identity)) => Placed (Value l l Placed Placed) -> SynCFExp λ l
- maxInteger :: Integer
- minInteger :: Integer
- maxInt32 :: Integer
- minInt32 :: Integer
- maxSet :: Integer
- minSet :: Integer
- doubleSize :: Integer
- floatSize :: Integer
- intSize :: Integer
- int32Size :: Integer
- maxReal :: Double
- minReal :: Double
- foldBinaryArithmetic :: forall λ l f. (f ~ Placed, Value l ~ Value l, Wirthy λ, Pretty (Value l l Identity Identity)) => (Int, ParsedLexemes, Int) -> (f (Expression l l f f) -> f (Expression l l f f) -> Expression λ l f f) -> (forall n. Num n => n -> n -> n) -> SynCFExp l l -> SynCFExp l l -> SynCFExp λ l
- foldBinaryFractional :: forall λ l f. (f ~ Placed, Value l ~ Value l, Wirthy λ, Pretty (Value l l Identity Identity)) => (Int, ParsedLexemes, Int) -> (f (Expression l l f f) -> f (Expression l l f f) -> Expression λ l f f) -> (forall n. Fractional n => n -> n -> n) -> SynCFExp l l -> SynCFExp l l -> SynCFExp λ l
- foldBinaryInteger :: forall λ l f. (f ~ Placed, Value l ~ Value l, Wirthy λ, Pretty (Value l l Identity Identity)) => (Int, ParsedLexemes, Int) -> (f (Expression l l f f) -> f (Expression l l f f) -> Expression λ l f f) -> (forall n. Integral n => n -> n -> n) -> SynCFExp l l -> SynCFExp l l -> SynCFExp λ l
- foldBinaryBoolean :: forall λ l f. (f ~ Placed, Value l ~ Value l, Wirthy λ, Pretty (Value l l Identity Identity)) => (Int, ParsedLexemes, Int) -> (f (Expression l l f f) -> f (Expression l l f f) -> Expression λ l f f) -> (Bool -> Bool -> Bool) -> SynCFExp l l -> SynCFExp l l -> SynCFExp λ l
- anyWhitespace :: ParsedLexemes -> ParsedLexemes -> ParsedLexemes
- lastWhitespace :: ParsedLexemes -> ParsedLexemes
- predefined :: (Wirthy l, Ord (QualIdent l)) => Environment l
- predefined2 :: (Wirthy l, Ord (QualIdent l)) => Environment l
Documentation
foldConstants :: (Oberon l, Nameable l, Ord (QualIdent l), Show (QualIdent l), Atts (Inherited (Auto ConstantFold)) (Block l l Sem Sem) ~ InhCF l, Atts (Synthesized (Auto ConstantFold)) (Block l l Sem Sem) ~ SynCFMod' l (Block l l), Functor (Auto ConstantFold) (Block l l), Functor (Auto ConstantFold) (Block l l)) => Environment l -> Map Ident (Placed (Module l l Placed Placed)) -> Map Ident (Placed (Module l l Placed Placed)) Source #
Fold the constants in the given collection of Oberon 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. The value of the latter argument is typically predefined or predefined2.
newtype Modules l f' f Source #
Constructors
| Modules | |
Fields
| |
Instances
data ConstantFold Source #
Constructors
| ConstantFold |
Instances
Constructors
| InhCFRoot | |
Fields
| |
Instances
| Generic (InhCFRoot l) Source # | |
| type Rep (InhCFRoot l) Source # | |
Defined in Language.Oberon.ConstantFolder type Rep (InhCFRoot l) = D1 ('MetaData "InhCFRoot" "Language.Oberon.ConstantFolder" "language-oberon-0.3.3-IKUoxbay5QRGXP2jOnakW5" 'False) (C1 ('MetaCons "InhCFRoot" 'PrefixI 'True) (S1 ('MetaSel ('Just "rootEnv") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Environment l)))) | |
Constructors
| InhCF | |
Fields
| |
Instances
| Generic (InhCF l) Source # | |
| type Rep (InhCF l) Source # | |
Defined in Language.Oberon.ConstantFolder type Rep (InhCF l) = D1 ('MetaData "InhCF" "Language.Oberon.ConstantFolder" "language-oberon-0.3.3-IKUoxbay5QRGXP2jOnakW5" '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))) | |
Instances
| Generic (SynCFMod l a) Source # | |
| type Rep (SynCFMod l a) Source # | |
Defined in Language.Oberon.ConstantFolder type Rep (SynCFMod l a) = D1 ('MetaData "SynCFMod" "Language.Oberon.ConstantFolder" "language-oberon-0.3.3-IKUoxbay5QRGXP2jOnakW5" 'False) (C1 ('MetaCons "SynCFMod" 'PrefixI 'True) (S1 ('MetaSel ('Just "moduleEnv") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Environment l)) :*: S1 ('MetaSel ('Just "folded") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Mapped Placed a)))) | |
data SynCFDesignator l Source #
Constructors
| SynCFDesignator | |
Instances
| Generic (SynCFDesignator l) Source # | |
Defined in Language.Oberon.ConstantFolder Associated Types type Rep (SynCFDesignator l) :: Type -> Type # Methods from :: SynCFDesignator l -> Rep (SynCFDesignator l) x # to :: Rep (SynCFDesignator l) x -> SynCFDesignator l # | |
| type Rep (SynCFDesignator l) Source # | |
Defined in Language.Oberon.ConstantFolder type Rep (SynCFDesignator l) = D1 ('MetaData "SynCFDesignator" "Language.Oberon.ConstantFolder" "language-oberon-0.3.3-IKUoxbay5QRGXP2jOnakW5" '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)))))) | |
Constructors
| SynCFRoot | |
Fields
| |
Modules instances, TH candidates
Boring attribute types
Disambiguation
foldedExp' :: SynCFExp λ l -> Placed (Expression λ l Placed Placed) Source #
Rules
literalSynthesis :: (Wirthy λ, Functor (Map Placed Identity) (Value l l), Pretty (Value l l Identity Identity)) => Placed (Value l l Placed Placed) -> SynCFExp λ l Source #
maxInteger :: Integer Source #
minInteger :: Integer Source #
doubleSize :: Integer Source #
foldBinaryArithmetic :: forall λ l f. (f ~ Placed, Value l ~ Value l, Wirthy λ, Pretty (Value l l Identity Identity)) => (Int, ParsedLexemes, Int) -> (f (Expression l l f f) -> f (Expression l l f f) -> Expression λ l f f) -> (forall n. Num n => n -> n -> n) -> SynCFExp l l -> SynCFExp l l -> SynCFExp λ l Source #
foldBinaryFractional :: forall λ l f. (f ~ Placed, Value l ~ Value l, Wirthy λ, Pretty (Value l l Identity Identity)) => (Int, ParsedLexemes, Int) -> (f (Expression l l f f) -> f (Expression l l f f) -> Expression λ l f f) -> (forall n. Fractional n => n -> n -> n) -> SynCFExp l l -> SynCFExp l l -> SynCFExp λ l Source #
foldBinaryInteger :: forall λ l f. (f ~ Placed, Value l ~ Value l, Wirthy λ, Pretty (Value l l Identity Identity)) => (Int, ParsedLexemes, Int) -> (f (Expression l l f f) -> f (Expression l l f f) -> Expression λ l f f) -> (forall n. Integral n => n -> n -> n) -> SynCFExp l l -> SynCFExp l l -> SynCFExp λ l Source #
foldBinaryBoolean :: forall λ l f. (f ~ Placed, Value l ~ Value l, Wirthy λ, Pretty (Value l l Identity Identity)) => (Int, ParsedLexemes, Int) -> (f (Expression l l f f) -> f (Expression l l f f) -> Expression λ l f f) -> (Bool -> Bool -> Bool) -> SynCFExp l l -> SynCFExp l l -> SynCFExp λ l Source #
Unsafe Rank2 AST instances
predefined :: (Wirthy l, Ord (QualIdent l)) => Environment l Source #
The set of predefined types and procedures defined in the Oberon Language Report.
predefined2 :: (Wirthy l, Ord (QualIdent l)) => Environment l Source #
Orphan instances
| Apply (Module l l f' :: (Type -> Type) -> Type) Source # | |
Methods (<*>) :: forall (p :: k -> Type) (q :: k -> Type). Module l l f' (p ~> q) -> Module l l f' p -> Module l l f' q # liftA2 :: (forall (a :: k). p a -> q a -> r a) -> Module l l f' p -> Module l l f' q -> Module l l f' r # liftA3 :: (forall (a :: k). p a -> q a -> r a -> s a) -> Module l l f' p -> Module l l f' q -> Module l l f' r -> Module l l f' s # | |