{-# LANGUAGE FlexibleContexts, FlexibleInstances, KindSignatures, MultiParamTypeClasses, OverloadedStrings,
             ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TypeFamilies, TypeOperators,
             UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-simplifiable-class-constraints #-}

-- | This module exports functions for resolving the syntactic ambiguities in a parsed module. For example, an Oberon
-- expression @foo(bar)@ may be a call to function @foo@ with a parameter @bar@, or it may be type guard on variable
-- @foo@ casting it to type @bar@.

module Language.Oberon.Resolver (resolveModules, resolveModule, resolvePositions, resolvePosition,
                                 Error(..), Predefined, Placed, NodeWrap, predefined, predefined2) where

import Control.Applicative (ZipList(ZipList, getZipList))
import Control.Arrow (first)
import Control.Monad.Trans.State (StateT(..), evalStateT, execStateT, get, put)
import Data.Either (partitionEithers)
import Data.Either.Validation (Validation(..), validationToEither)
import Data.Foldable (toList)
import Data.Functor.Compose (Compose(..))
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NonEmpty
import qualified Data.List as List
import Data.Map.Lazy (Map, traverseWithKey)
import qualified Data.Map.Lazy as Map
import Data.Semigroup (Semigroup(..), sconcat)
import Data.Text (Text)
import Language.Haskell.TH (appT, conT, varT, newName)

import qualified Text.Parser.Input.Position as Position
import qualified Rank2.TH
import qualified Transformation
import qualified Transformation.Deep as Deep
import qualified Transformation.Deep.TH
import qualified Transformation.Full as Full
import qualified Transformation.Full.TH
import qualified Transformation.Rank2 as Rank2
import Text.Grampa (Ambiguous(..))

import qualified Language.Oberon.Abstract as Abstract
import Language.Oberon.AST
import Language.Oberon.Grammar (ParsedLexemes(Trailing))
import qualified Language.Oberon.Grammar as Grammar

-- | Replace the stored positions in the entire ambiguous parsed tree, as obtained from "Language.Oberon.Grammar",
-- | with offsets from the start of the given source text
resolvePositions :: (p ~ Grammar.NodeWrap, q ~ NodeWrap, Deep.Functor (Rank2.Map p q) g)
                 => Text -> p (g p p) -> q (g q q)
resolvePositions :: Text -> p (g p p) -> q (g q q)
resolvePositions Text
src p (g p p)
t = (forall x. NodeWrap x -> NodeWrap x) -> Map NodeWrap NodeWrap
forall (p :: * -> *) (q :: * -> *).
(forall x. p x -> q x) -> Map p q
Rank2.Map (Text -> NodeWrap x -> NodeWrap x
forall a. Text -> NodeWrap a -> NodeWrap a
resolvePosition Text
src) Map NodeWrap NodeWrap
-> Domain
     (Map NodeWrap NodeWrap)
     (g (Domain (Map NodeWrap NodeWrap))
        (Domain (Map NodeWrap NodeWrap)))
-> Codomain
     (Map NodeWrap NodeWrap)
     (g (Codomain (Map NodeWrap NodeWrap))
        (Codomain (Map NodeWrap NodeWrap)))
forall t (g :: (* -> *) -> (* -> *) -> *).
Functor t g =>
t
-> Domain t (g (Domain t) (Domain t))
-> Codomain t (g (Codomain t) (Codomain t))
Full.<$> p (g p p)
Domain
  (Map NodeWrap NodeWrap)
  (g (Domain (Map NodeWrap NodeWrap))
     (Domain (Map NodeWrap NodeWrap)))
t

-- | Replace the stored positions of the given node, as obtained from "Language.Oberon.Grammar", with offset from the
-- | start of the given source text
resolvePosition :: Text -> Grammar.NodeWrap a -> NodeWrap a
resolvePosition :: Text -> NodeWrap a -> NodeWrap a
resolvePosition Text
src = \(Compose ((Position
start, Position
end), Compose Ambiguous ((,) ParsedLexemes) a
a))-> ((Int, Int), Compose Ambiguous ((,) ParsedLexemes) a) -> NodeWrap a
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose ((Text -> Position -> Int
forall s. FactorialMonoid s => s -> Position -> Int
Position.offset Text
src Position
start, Text -> Position -> Int
forall s. FactorialMonoid s => s -> Position -> Int
Position.offset Text
src Position
end), Compose Ambiguous ((,) ParsedLexemes) a
a)

data DeclarationRHS l f' f = DeclaredConstant (f (Abstract.ConstExpression l l f' f'))
                           | DeclaredType (f (Abstract.Type l l f' f'))
                           | DeclaredVariable (f (Abstract.Type l l f' f'))
                           | DeclaredProcedure Bool (Maybe (f (Abstract.FormalParameters l l f' f')))
deriving instance (Show (Abstract.FormalParameters l l Placed Placed), Show (Abstract.Type l l Placed Placed),
                   Show (Abstract.ConstExpression l l Placed Placed)) =>
                  Show (DeclarationRHS l Placed Placed)
deriving instance (Show (Abstract.FormalParameters l l NodeWrap NodeWrap), Show (Abstract.Type l l NodeWrap NodeWrap),
                   Show (Abstract.ConstExpression l l NodeWrap NodeWrap)) =>
                  Show (DeclarationRHS l NodeWrap NodeWrap)

-- | All possible resolution errors
data Error l = UnknownModule (Abstract.QualIdent l)
             | UnknownLocal Ident
             | UnknownImport (Abstract.QualIdent l)
             | AmbiguousParses
             | AmbiguousDeclaration [Declaration l l NodeWrap NodeWrap]
             | AmbiguousDesignator [Designator l l NodeWrap NodeWrap]
             | AmbiguousExpression [Expression l l NodeWrap NodeWrap]
             | AmbiguousRecord [Designator l l NodeWrap NodeWrap]
             | AmbiguousStatement [Statement l l NodeWrap NodeWrap]
             | InvalidExpression (NonEmpty (Error l))
             | InvalidFunctionParameters [NodeWrap (Abstract.Expression l l NodeWrap NodeWrap)]
             | InvalidRecord (NonEmpty (Error l))
             | InvalidStatement (NonEmpty (Error l))
             | NotARecord (Abstract.QualIdent l)
             | NotAType (Abstract.QualIdent l)
             | NotAValue (Abstract.QualIdent l)
             | ClashingImports
             | UnparseableModule Text
deriving instance (Show (Abstract.QualIdent l),
                   Show (Declaration l l NodeWrap NodeWrap), Show (Statement l l NodeWrap NodeWrap),
                   Show (Expression l l NodeWrap NodeWrap), Show (Abstract.Expression l l NodeWrap NodeWrap),
                   Show (Designator l l NodeWrap NodeWrap)) => Show (Error l)

-- | The node wrapper in a fully resolved AST
type Placed = (,) (Int, ParsedLexemes, Int)

-- | The node wrapper in an ambiguous, freshly parsed AST, only with 'Position.Position' replaced with an offset from
-- the beginning of the source.
type NodeWrap = Compose ((,) (Int, Int)) (Compose Ambiguous ((,) ParsedLexemes))

type Scope l = Map Ident (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))

-- | A set of predefined declarations.
type Predefined l = Scope l

data Resolution l = Resolution{Resolution l -> Map Text (Scope l)
_modules :: Map Ident (Scope l)}

type Resolved l = StateT (Scope l, ResolutionState) (Validation (NonEmpty (Error l)))

data ResolutionState = ModuleState
                     | DeclarationState
                     | StatementState
                     | ExpressionState
                     | ExpressionOrTypeState
                     deriving (ResolutionState -> ResolutionState -> Bool
(ResolutionState -> ResolutionState -> Bool)
-> (ResolutionState -> ResolutionState -> Bool)
-> Eq ResolutionState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResolutionState -> ResolutionState -> Bool
$c/= :: ResolutionState -> ResolutionState -> Bool
== :: ResolutionState -> ResolutionState -> Bool
$c== :: ResolutionState -> ResolutionState -> Bool
Eq, Int -> ResolutionState -> ShowS
[ResolutionState] -> ShowS
ResolutionState -> String
(Int -> ResolutionState -> ShowS)
-> (ResolutionState -> String)
-> ([ResolutionState] -> ShowS)
-> Show ResolutionState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResolutionState] -> ShowS
$cshowList :: [ResolutionState] -> ShowS
show :: ResolutionState -> String
$cshow :: ResolutionState -> String
showsPrec :: Int -> ResolutionState -> ShowS
$cshowsPrec :: Int -> ResolutionState -> ShowS
Show)

instance Monad (Validation (NonEmpty (Error l))) where
   Success a
s >>= :: Validation (NonEmpty (Error l)) a
-> (a -> Validation (NonEmpty (Error l)) b)
-> Validation (NonEmpty (Error l)) b
>>= a -> Validation (NonEmpty (Error l)) b
f = a -> Validation (NonEmpty (Error l)) b
f a
s
   Failure NonEmpty (Error l)
errors >>= a -> Validation (NonEmpty (Error l)) b
_ = NonEmpty (Error l) -> Validation (NonEmpty (Error l)) b
forall e a. e -> Validation e a
Failure NonEmpty (Error l)
errors

instance Transformation.Transformation (Resolution l) where
    type Domain (Resolution l) = NodeWrap
    type Codomain (Resolution l) = Compose (Resolved l) Placed

instance {-# overlappable #-} Resolution l `Transformation.At` g Placed Placed where
   $ :: Resolution l
-> Domain (Resolution l) (g Placed Placed)
-> Codomain (Resolution l) (g Placed Placed)
($) = Resolution l
-> Domain (Resolution l) (g Placed Placed)
-> Codomain (Resolution l) (g Placed Placed)
forall l (g :: (* -> *) -> (* -> *) -> *) (f :: * -> *).
Resolution l
-> NodeWrap (g f f) -> Compose (Resolved l) Placed (g f f)
traverseResolveDefault

instance {-# overlappable #-} Resolution l `Transformation.At` g NodeWrap NodeWrap where
   $ :: Resolution l
-> Domain (Resolution l) (g NodeWrap NodeWrap)
-> Codomain (Resolution l) (g NodeWrap NodeWrap)
($) = Resolution l
-> Domain (Resolution l) (g NodeWrap NodeWrap)
-> Codomain (Resolution l) (g NodeWrap NodeWrap)
forall l (g :: (* -> *) -> (* -> *) -> *) (f :: * -> *).
Resolution l
-> NodeWrap (g f f) -> Compose (Resolved l) Placed (g f f)
traverseResolveDefault

instance {-# overlaps #-} Resolvable l => Resolution l `Transformation.At` Designator l l NodeWrap NodeWrap where
   Resolution l
res $ :: Resolution l
-> Domain (Resolution l) (Designator l l NodeWrap NodeWrap)
-> Codomain (Resolution l) (Designator l l NodeWrap NodeWrap)
$ Compose ((start, end), Compose (Ambiguous designators)) = StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), Designator l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
     Placed
     (Designator l l NodeWrap NodeWrap)
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (StateT
   (Scope l, ResolutionState)
   (Validation (NonEmpty (Error l)))
   ((Int, ParsedLexemes, Int), Designator l l NodeWrap NodeWrap)
 -> Compose
      (StateT
         (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
      Placed
      (Designator l l NodeWrap NodeWrap))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Designator l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
     Placed
     (Designator l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ ((Scope l, ResolutionState)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), Designator l l NodeWrap NodeWrap),
       (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Designator l l NodeWrap NodeWrap)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT (((Scope l, ResolutionState)
  -> Validation
       (NonEmpty (Error l))
       (((Int, ParsedLexemes, Int), Designator l l NodeWrap NodeWrap),
        (Scope l, ResolutionState)))
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      ((Int, ParsedLexemes, Int), Designator l l NodeWrap NodeWrap))
-> ((Scope l, ResolutionState)
    -> Validation
         (NonEmpty (Error l))
         (((Int, ParsedLexemes, Int), Designator l l NodeWrap NodeWrap),
          (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Designator l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ \s :: (Scope l, ResolutionState)
s@(Scope l
scope, ResolutionState
state)->
      case [Either
   (NonEmpty (Error l))
   (ParsedLexemes, Designator l l NodeWrap NodeWrap)]
-> ([NonEmpty (Error l)],
    [(ParsedLexemes, Designator l l NodeWrap NodeWrap)])
forall a b. [Either a b] -> ([a], [b])
partitionEithers (NonEmpty
  (Either
     (NonEmpty (Error l))
     (ParsedLexemes, Designator l l NodeWrap NodeWrap))
-> [Either
      (NonEmpty (Error l))
      (ParsedLexemes, Designator l l NodeWrap NodeWrap)]
forall a. NonEmpty a -> [a]
NonEmpty.toList ((Designator l l NodeWrap NodeWrap
 -> Either (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap))
-> (ParsedLexemes, Designator l l NodeWrap NodeWrap)
-> Either
     (NonEmpty (Error l))
     (ParsedLexemes, Designator l l NodeWrap NodeWrap)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (Validation (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap)
-> Either (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap)
forall e a. Validation e a -> Either e a
validationToEither (Validation (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap)
 -> Either (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap))
-> (Designator l l NodeWrap NodeWrap
    -> Validation
         (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap))
-> Designator l l NodeWrap NodeWrap
-> Either (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Resolution l
-> Scope l
-> ResolutionState
-> Designator l l NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap)
forall l.
Resolvable l =>
Resolution l
-> Scope l
-> ResolutionState
-> Designator l l NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap)
resolveDesignator Resolution l
res Scope l
scope ResolutionState
state)
                                              ((ParsedLexemes, Designator l l NodeWrap NodeWrap)
 -> Either
      (NonEmpty (Error l))
      (ParsedLexemes, Designator l l NodeWrap NodeWrap))
-> NonEmpty (ParsedLexemes, Designator l l NodeWrap NodeWrap)
-> NonEmpty
     (Either
        (NonEmpty (Error l))
        (ParsedLexemes, Designator l l NodeWrap NodeWrap))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmpty (ParsedLexemes, Designator l l NodeWrap NodeWrap)
designators))
      of ([NonEmpty (Error l)]
_, [(ParsedLexemes
ws, Designator l l NodeWrap NodeWrap
x)]) -> (((Int, ParsedLexemes, Int), Designator l l NodeWrap NodeWrap),
 (Scope l, ResolutionState))
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Designator l l NodeWrap NodeWrap),
      (Scope l, ResolutionState))
forall e a. a -> Validation e a
Success (((Int
start, ParsedLexemes
ws, Int
end), Designator l l NodeWrap NodeWrap
x), (Scope l, ResolutionState)
s)
         ([NonEmpty (Error l)]
errors, []) -> NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Designator l l NodeWrap NodeWrap),
      (Scope l, ResolutionState))
forall e a. e -> Validation e a
Failure (NonEmpty (NonEmpty (Error l)) -> NonEmpty (Error l)
forall a. Semigroup a => NonEmpty a -> a
sconcat (NonEmpty (NonEmpty (Error l)) -> NonEmpty (Error l))
-> NonEmpty (NonEmpty (Error l)) -> NonEmpty (Error l)
forall a b. (a -> b) -> a -> b
$ [NonEmpty (Error l)] -> NonEmpty (NonEmpty (Error l))
forall a. [a] -> NonEmpty a
NonEmpty.fromList [NonEmpty (Error l)]
errors)
         ([NonEmpty (Error l)]
_, [(ParsedLexemes, Designator l l NodeWrap NodeWrap)]
multi) -> NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Designator l l NodeWrap NodeWrap),
      (Scope l, ResolutionState))
forall e a. e -> Validation e a
Failure ([Designator l l NodeWrap NodeWrap] -> Error l
forall l. [Designator l l NodeWrap NodeWrap] -> Error l
AmbiguousDesignator ((ParsedLexemes, Designator l l NodeWrap NodeWrap)
-> Designator l l NodeWrap NodeWrap
forall a b. (a, b) -> b
snd ((ParsedLexemes, Designator l l NodeWrap NodeWrap)
 -> Designator l l NodeWrap NodeWrap)
-> [(ParsedLexemes, Designator l l NodeWrap NodeWrap)]
-> [Designator l l NodeWrap NodeWrap]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(ParsedLexemes, Designator l l NodeWrap NodeWrap)]
multi) Error l -> [Error l] -> NonEmpty (Error l)
forall a. a -> [a] -> NonEmpty a
:| [])

class Readable l where
   getVariableName :: Abstract.Designator l l f' f -> Maybe (Abstract.QualIdent l)

instance Readable Language where
   getVariableName :: Designator Language Language f' f -> Maybe (QualIdent Language)
getVariableName (Variable q) = QualIdent Language -> Maybe (QualIdent Language)
forall a. a -> Maybe a
Just QualIdent Language
QualIdent Language
q
   getVariableName Designator Language Language f' f
_ = Maybe (QualIdent Language)
forall a. Maybe a
Nothing

instance {-# overlaps #-}
   (Readable l, Abstract.Nameable l, Abstract.Oberon l,
    Deep.Traversable (Resolution l) (Abstract.Expression l l),
    Deep.Traversable (Resolution l) (Abstract.Designator l l),
    Resolution l `Transformation.At` Abstract.Expression l l NodeWrap NodeWrap,
    Resolution l `Transformation.At` Abstract.Designator l l NodeWrap NodeWrap) =>
   Resolution l `Transformation.At` Expression l l NodeWrap NodeWrap where
   Resolution l
res $ :: Resolution l
-> Domain (Resolution l) (Expression l l NodeWrap NodeWrap)
-> Codomain (Resolution l) (Expression l l NodeWrap NodeWrap)
$ Domain (Resolution l) (Expression l l NodeWrap NodeWrap)
expressions = StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), Expression l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
     Placed
     (Expression l l NodeWrap NodeWrap)
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (StateT
   (Scope l, ResolutionState)
   (Validation (NonEmpty (Error l)))
   ((Int, ParsedLexemes, Int), Expression l l NodeWrap NodeWrap)
 -> Compose
      (StateT
         (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
      Placed
      (Expression l l NodeWrap NodeWrap))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Expression l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
     Placed
     (Expression l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ ((Scope l, ResolutionState)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), Expression l l NodeWrap NodeWrap),
       (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Expression l l NodeWrap NodeWrap)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT (((Scope l, ResolutionState)
  -> Validation
       (NonEmpty (Error l))
       (((Int, ParsedLexemes, Int), Expression l l NodeWrap NodeWrap),
        (Scope l, ResolutionState)))
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      ((Int, ParsedLexemes, Int), Expression l l NodeWrap NodeWrap))
-> ((Scope l, ResolutionState)
    -> Validation
         (NonEmpty (Error l))
         (((Int, ParsedLexemes, Int), Expression l l NodeWrap NodeWrap),
          (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Expression l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ \s :: (Scope l, ResolutionState)
s@(Scope l
scope, ResolutionState
state)->
      let resolveExpression :: Expression l l NodeWrap NodeWrap
                            -> Validation (NonEmpty (Error l)) (Expression l l NodeWrap NodeWrap, ResolutionState)
          resolveExpression :: Expression l l NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error l))
     (Expression l l NodeWrap NodeWrap, ResolutionState)
resolveExpression e :: Expression l l NodeWrap NodeWrap
e@(Read NodeWrap (Designator l l NodeWrap NodeWrap)
designators) =
             case StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  (Placed (Designator l l NodeWrap NodeWrap))
-> (Scope l, ResolutionState)
-> Validation
     (NonEmpty (Error l)) (Placed (Designator l l NodeWrap NodeWrap))
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (Compose
  (StateT
     (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
  Placed
  (Designator l l NodeWrap NodeWrap)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     (Placed (Designator l l NodeWrap NodeWrap))
forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose (Compose
   (StateT
      (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
   Placed
   (Designator l l NodeWrap NodeWrap)
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      (Placed (Designator l l NodeWrap NodeWrap)))
-> Compose
     (StateT
        (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
     Placed
     (Designator l l NodeWrap NodeWrap)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     (Placed (Designator l l NodeWrap NodeWrap))
forall a b. (a -> b) -> a -> b
$ Resolution l
res Resolution l
-> Domain (Resolution l) (Designator l l NodeWrap NodeWrap)
-> Codomain (Resolution l) (Designator l l NodeWrap NodeWrap)
forall t x. At t x => t -> Domain t x -> Codomain t x
Transformation.$ NodeWrap (Designator l l NodeWrap NodeWrap)
Domain (Resolution l) (Designator l l NodeWrap NodeWrap)
designators) (Scope l, ResolutionState)
s
             of Failure NonEmpty (Error l)
errors -> NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (Expression l l NodeWrap NodeWrap, ResolutionState)
forall e a. e -> Validation e a
Failure NonEmpty (Error l)
errors
                Success{} -> (Expression l l NodeWrap NodeWrap, ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (Expression l l NodeWrap NodeWrap, ResolutionState)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Expression l l NodeWrap NodeWrap
e, ResolutionState
state)
          resolveExpression e :: Expression l l NodeWrap NodeWrap
e@(FunctionCall NodeWrap (Designator l l NodeWrap NodeWrap)
functions ZipList (NodeWrap (Expression l l NodeWrap NodeWrap))
parameters) =
             case StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  (Placed (Designator l l NodeWrap NodeWrap))
-> (Scope l, ResolutionState)
-> Validation
     (NonEmpty (Error l)) (Placed (Designator l l NodeWrap NodeWrap))
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (Compose
  (StateT
     (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
  Placed
  (Designator l l NodeWrap NodeWrap)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     (Placed (Designator l l NodeWrap NodeWrap))
forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose (Compose
   (StateT
      (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
   Placed
   (Designator l l NodeWrap NodeWrap)
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      (Placed (Designator l l NodeWrap NodeWrap)))
-> Compose
     (StateT
        (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
     Placed
     (Designator l l NodeWrap NodeWrap)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     (Placed (Designator l l NodeWrap NodeWrap))
forall a b. (a -> b) -> a -> b
$ Resolution l
res Resolution l
-> Domain (Resolution l) (Designator l l NodeWrap NodeWrap)
-> Codomain (Resolution l) (Designator l l NodeWrap NodeWrap)
forall t x. At t x => t -> Domain t x -> Codomain t x
Transformation.$ NodeWrap (Designator l l NodeWrap NodeWrap)
Domain (Resolution l) (Designator l l NodeWrap NodeWrap)
functions) (Scope l, ResolutionState)
s
             of Failure NonEmpty (Error l)
errors -> NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (Expression l l NodeWrap NodeWrap, ResolutionState)
forall e a. e -> Validation e a
Failure NonEmpty (Error l)
errors
                Success ((Int, ParsedLexemes, Int)
_pos, Designator l l NodeWrap NodeWrap
d)
                   | Just QualIdent l
q <- Designator l l NodeWrap NodeWrap -> Maybe (QualIdent l)
forall l (f' :: * -> *) (f :: * -> *).
Readable l =>
Designator l l f' f -> Maybe (QualIdent l)
getVariableName Designator l l NodeWrap NodeWrap
d, Success (DeclaredProcedure Bool
True Maybe (Placed (FormalParameters l l Placed Placed))
_) <- Resolution l
-> Scope l
-> QualIdent l
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall l.
(Nameable l, Oberon l) =>
Resolution l
-> Scope l
-> QualIdent l
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
resolveName Resolution l
res Scope l
scope QualIdent l
q
                     -> (Expression l l NodeWrap NodeWrap, ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (Expression l l NodeWrap NodeWrap, ResolutionState)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Expression l l NodeWrap NodeWrap
e, ResolutionState
ExpressionOrTypeState)
                   | Success{} <- StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  (ZipList (Placed (Expression l l NodeWrap NodeWrap)))
-> (Scope l, ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (ZipList (Placed (Expression l l NodeWrap NodeWrap)))
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT ((NodeWrap (Expression l l NodeWrap NodeWrap)
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      (Placed (Expression l l NodeWrap NodeWrap)))
-> ZipList (NodeWrap (Expression l l NodeWrap NodeWrap))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     (ZipList (Placed (Expression l l NodeWrap NodeWrap)))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (Compose
  (StateT
     (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
  Placed
  (Expression l l NodeWrap NodeWrap)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     (Placed (Expression l l NodeWrap NodeWrap))
forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose (Compose
   (StateT
      (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
   Placed
   (Expression l l NodeWrap NodeWrap)
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      (Placed (Expression l l NodeWrap NodeWrap)))
-> (NodeWrap (Expression l l NodeWrap NodeWrap)
    -> Compose
         (StateT
            (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
         Placed
         (Expression l l NodeWrap NodeWrap))
-> NodeWrap (Expression l l NodeWrap NodeWrap)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     (Placed (Expression l l NodeWrap NodeWrap))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Resolution l
res Resolution l
-> Domain (Resolution l) (Expression l l NodeWrap NodeWrap)
-> Codomain (Resolution l) (Expression l l NodeWrap NodeWrap)
forall t x. At t x => t -> Domain t x -> Codomain t x
Transformation.$)) ZipList (NodeWrap (Expression l l NodeWrap NodeWrap))
parameters)
                                             (Scope l
scope, ResolutionState
ExpressionState)
                     -> (Expression l l NodeWrap NodeWrap, ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (Expression l l NodeWrap NodeWrap, ResolutionState)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Expression l l NodeWrap NodeWrap
e, ResolutionState
ExpressionState)
                   | Bool
otherwise -> NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (Expression l l NodeWrap NodeWrap, ResolutionState)
forall e a. e -> Validation e a
Failure (Error l -> NonEmpty (Error l)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Error l -> NonEmpty (Error l)) -> Error l -> NonEmpty (Error l)
forall a b. (a -> b) -> a -> b
$ [NodeWrap (Expression l l NodeWrap NodeWrap)] -> Error l
forall l. [NodeWrap (Expression l l NodeWrap NodeWrap)] -> Error l
InvalidFunctionParameters ([NodeWrap (Expression l l NodeWrap NodeWrap)] -> Error l)
-> [NodeWrap (Expression l l NodeWrap NodeWrap)] -> Error l
forall a b. (a -> b) -> a -> b
$ ZipList (NodeWrap (Expression l l NodeWrap NodeWrap))
-> [NodeWrap (Expression l l NodeWrap NodeWrap)]
forall a. ZipList a -> [a]
getZipList ZipList (NodeWrap (Expression l l NodeWrap NodeWrap))
parameters)
          resolveExpression e :: Expression l l NodeWrap NodeWrap
e@(IsA NodeWrap (Expression l l NodeWrap NodeWrap)
_lefts QualIdent l
q) =
            case Resolution l
-> Scope l
-> QualIdent l
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall l.
(Nameable l, Oberon l) =>
Resolution l
-> Scope l
-> QualIdent l
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
resolveName Resolution l
res Scope l
scope QualIdent l
q
            of Failure NonEmpty (Error l)
err ->  NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (Expression l l NodeWrap NodeWrap, ResolutionState)
forall e a. e -> Validation e a
Failure NonEmpty (Error l)
err
               Success DeclaredType{} -> (Expression l l NodeWrap NodeWrap, ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (Expression l l NodeWrap NodeWrap, ResolutionState)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Expression l l NodeWrap NodeWrap
e, ResolutionState
ExpressionState)
               Success DeclarationRHS l Placed Placed
_ -> NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (Expression l l NodeWrap NodeWrap, ResolutionState)
forall e a. e -> Validation e a
Failure (QualIdent l -> Error l
forall l. QualIdent l -> Error l
NotAType QualIdent l
q Error l -> [Error l] -> NonEmpty (Error l)
forall a. a -> [a] -> NonEmpty a
:| [])
          resolveExpression Expression l l NodeWrap NodeWrap
e = (Expression l l NodeWrap NodeWrap, ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (Expression l l NodeWrap NodeWrap, ResolutionState)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Expression l l NodeWrap NodeWrap
e, ResolutionState
state)
      in (\((Int, ParsedLexemes, Int)
pos, (Expression l l NodeWrap NodeWrap
r, ResolutionState
s'))-> (((Int, ParsedLexemes, Int)
pos, Expression l l NodeWrap NodeWrap
r), (Scope l
scope, ResolutionState
s')))
         (((Int, ParsedLexemes, Int),
  (Expression l l NodeWrap NodeWrap, ResolutionState))
 -> (((Int, ParsedLexemes, Int), Expression l l NodeWrap NodeWrap),
     (Scope l, ResolutionState)))
-> Validation
     (NonEmpty (Error l))
     ((Int, ParsedLexemes, Int),
      (Expression l l NodeWrap NodeWrap, ResolutionState))
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Expression l l NodeWrap NodeWrap),
      (Scope l, ResolutionState))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (NonEmpty (Error l) -> Error l)
-> ([(Expression l l NodeWrap NodeWrap, ResolutionState)]
    -> Error l)
-> NodeWrap
     (Validation
        (NonEmpty (Error l))
        (Expression l l NodeWrap NodeWrap, ResolutionState))
-> Validation
     (NonEmpty (Error l))
     ((Int, ParsedLexemes, Int),
      (Expression l l NodeWrap NodeWrap, ResolutionState))
forall l a.
(NonEmpty (Error l) -> Error l)
-> ([a] -> Error l)
-> NodeWrap (Validation (NonEmpty (Error l)) a)
-> Validation (NonEmpty (Error l)) (Placed a)
unique NonEmpty (Error l) -> Error l
forall l. NonEmpty (Error l) -> Error l
InvalidExpression ([Expression l l NodeWrap NodeWrap] -> Error l
forall l. [Expression l l NodeWrap NodeWrap] -> Error l
AmbiguousExpression ([Expression l l NodeWrap NodeWrap] -> Error l)
-> ([(Expression l l NodeWrap NodeWrap, ResolutionState)]
    -> [Expression l l NodeWrap NodeWrap])
-> [(Expression l l NodeWrap NodeWrap, ResolutionState)]
-> Error l
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Expression l l NodeWrap NodeWrap, ResolutionState)
-> Expression l l NodeWrap NodeWrap
forall a b. (a, b) -> a
fst ((Expression l l NodeWrap NodeWrap, ResolutionState)
 -> Expression l l NodeWrap NodeWrap)
-> [(Expression l l NodeWrap NodeWrap, ResolutionState)]
-> [Expression l l NodeWrap NodeWrap]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>)) (Expression l l NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error l))
     (Expression l l NodeWrap NodeWrap, ResolutionState)
resolveExpression (Expression l l NodeWrap NodeWrap
 -> Validation
      (NonEmpty (Error l))
      (Expression l l NodeWrap NodeWrap, ResolutionState))
-> Compose
     ((,) (Int, Int))
     (Compose Ambiguous ((,) ParsedLexemes))
     (Expression l l NodeWrap NodeWrap)
-> NodeWrap
     (Validation
        (NonEmpty (Error l))
        (Expression l l NodeWrap NodeWrap, ResolutionState))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Compose
  ((,) (Int, Int))
  (Compose Ambiguous ((,) ParsedLexemes))
  (Expression l l NodeWrap NodeWrap)
Domain (Resolution l) (Expression l l NodeWrap NodeWrap)
expressions)

instance {-# overlaps #-}
   (BindableDeclaration l, CoFormalParameters l, Abstract.Wirthy l,
    Full.Traversable (Resolution l) (Abstract.Type l l),
    Full.Traversable (Resolution l) (Abstract.FormalParameters l l),
    Full.Traversable (Resolution l) (Abstract.ConstExpression l l),
    Deep.Traversable (Resolution l) (Abstract.Type l l),
    Deep.Traversable (Resolution l) (Abstract.ProcedureHeading l l),
    Deep.Traversable (Resolution l) (Abstract.FormalParameters l l),
    Deep.Traversable (Resolution l) (Abstract.ConstExpression l l),
    Resolution l `Transformation.At` Abstract.ProcedureHeading l l NodeWrap NodeWrap,
    Resolution l `Transformation.At` Abstract.Block l l NodeWrap NodeWrap) =>
   Resolution l `Transformation.At` Declaration l l NodeWrap NodeWrap where
   Resolution l
res $ :: Resolution l
-> Domain (Resolution l) (Declaration l l NodeWrap NodeWrap)
-> Codomain (Resolution l) (Declaration l l NodeWrap NodeWrap)
$ Compose ((start, end), Compose (Ambiguous ((ws, proc@(ProcedureDeclaration heading body)) :| []))) =
      StateT
  (Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Map
           Text
           (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
         ResolutionState)
        (Validation (NonEmpty (Error l))))
     Placed
     (Declaration l l NodeWrap NodeWrap)
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (StateT
   (Map
      Text
      (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
    ResolutionState)
   (Validation (NonEmpty (Error l)))
   ((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap)
 -> Compose
      (StateT
         (Map
            Text
            (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
          ResolutionState)
         (Validation (NonEmpty (Error l))))
      Placed
      (Declaration l l NodeWrap NodeWrap))
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Map
           Text
           (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
         ResolutionState)
        (Validation (NonEmpty (Error l))))
     Placed
     (Declaration l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$
      do s :: (Map
   Text
   (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
 ResolutionState)
s@(Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
scope, ResolutionState
state) <- StateT
  (Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
  (Validation (NonEmpty (Error l)))
  (Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
forall (m :: * -> *) s. Monad m => StateT s m s
get
         let Success (Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
headingScope, ResolutionState
_) = StateT
  (Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
  (Validation (NonEmpty (Error l)))
  (Placed (ProcedureHeading l l NodeWrap NodeWrap))
-> (Map
      Text
      (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
    ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m s
execStateT (Compose
  (StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l))))
  Placed
  (ProcedureHeading l l NodeWrap NodeWrap)
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     (Placed (ProcedureHeading l l NodeWrap NodeWrap))
forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose (Compose
   (StateT
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState)
      (Validation (NonEmpty (Error l))))
   Placed
   (ProcedureHeading l l NodeWrap NodeWrap)
 -> StateT
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState)
      (Validation (NonEmpty (Error l)))
      (Placed (ProcedureHeading l l NodeWrap NodeWrap)))
-> Compose
     (StateT
        (Map
           Text
           (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
         ResolutionState)
        (Validation (NonEmpty (Error l))))
     Placed
     (ProcedureHeading l l NodeWrap NodeWrap)
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     (Placed (ProcedureHeading l l NodeWrap NodeWrap))
forall a b. (a -> b) -> a -> b
$ Resolution l
res Resolution l
-> Domain (Resolution l) (ProcedureHeading l l NodeWrap NodeWrap)
-> Codomain (Resolution l) (ProcedureHeading l l NodeWrap NodeWrap)
forall t x. At t x => t -> Domain t x -> Codomain t x
Transformation.$ NodeWrap (ProcedureHeading l l NodeWrap NodeWrap)
Domain (Resolution l) (ProcedureHeading l l NodeWrap NodeWrap)
heading) (Map
   Text
   (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
 ResolutionState)
s
             Success ((Int, ParsedLexemes, Int)
_, Block l l NodeWrap NodeWrap
body') = StateT
  (Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
-> (Map
      Text
      (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
    ResolutionState)
-> Validation
     (NonEmpty (Error l))
     ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (Compose
  (StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l))))
  Placed
  (Block l l NodeWrap NodeWrap)
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose (Compose
   (StateT
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState)
      (Validation (NonEmpty (Error l))))
   Placed
   (Block l l NodeWrap NodeWrap)
 -> StateT
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState)
      (Validation (NonEmpty (Error l)))
      ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap))
-> Compose
     (StateT
        (Map
           Text
           (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
         ResolutionState)
        (Validation (NonEmpty (Error l))))
     Placed
     (Block l l NodeWrap NodeWrap)
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ Resolution l
res Resolution l
-> Domain (Resolution l) (Block l l NodeWrap NodeWrap)
-> Codomain (Resolution l) (Block l l NodeWrap NodeWrap)
forall t x. At t x => t -> Domain t x -> Codomain t x
Transformation.$ NodeWrap (Block l l NodeWrap NodeWrap)
Domain (Resolution l) (Block l l NodeWrap NodeWrap)
body) (Map
   Text
   (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
 ResolutionState)
s
             innerScope :: Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
innerScope = Resolution l
-> Text
-> [NodeWrap (Declaration l l NodeWrap NodeWrap)]
-> Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall l.
(BindableDeclaration l, Traversable (Resolution l) (Type l l),
 Traversable (Resolution l) (FormalParameters l l),
 Traversable (Resolution l) (ConstExpression l l)) =>
Resolution l
-> Text
-> [NodeWrap (Declaration l l NodeWrap NodeWrap)]
-> Scope l
-> Scope l
localScope Resolution l
res Text
"" (Block l l NodeWrap NodeWrap
-> [NodeWrap (Declaration l l NodeWrap NodeWrap)]
forall l (f' :: * -> *) (f :: * -> *).
CoFormalParameters l =>
Block l l f' f -> [f (Declaration l l f' f')]
getLocalDeclarations Block l l NodeWrap NodeWrap
body') (Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
headingScope Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall k a. Ord k => Map k a -> Map k a -> Map k a
`Map.union` Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
scope)
         (Map
   Text
   (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
 ResolutionState)
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ()
forall (m :: * -> *) s. Monad m => s -> StateT s m ()
put (Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
innerScope, ResolutionState
state)
         ((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap)
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap)
forall (m :: * -> *) a. Monad m => a -> m a
return ((Int
start, ParsedLexemes
ws, Int
end), Declaration l l NodeWrap NodeWrap
proc)
   Resolution l
_ $ Compose ((start, end), Compose (Ambiguous ((ws, dec) :| []))) = StateT
  (Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Map
           Text
           (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
         ResolutionState)
        (Validation (NonEmpty (Error l))))
     Placed
     (Declaration l l NodeWrap NodeWrap)
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap)
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Int
start, ParsedLexemes
ws, Int
end), Declaration l l NodeWrap NodeWrap
dec))
   Resolution l
_ $ Domain (Resolution l) (Declaration l l NodeWrap NodeWrap)
declarations = StateT
  (Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Map
           Text
           (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
         ResolutionState)
        (Validation (NonEmpty (Error l))))
     Placed
     (Declaration l l NodeWrap NodeWrap)
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (((Map
    Text
    (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
  ResolutionState)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap),
       (Map
          Text
          (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
        ResolutionState)))
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT (((Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
  -> Validation
       (NonEmpty (Error l))
       (((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap),
        (Map
           Text
           (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
         ResolutionState)))
 -> StateT
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState)
      (Validation (NonEmpty (Error l)))
      ((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap))
-> ((Map
       Text
       (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
     ResolutionState)
    -> Validation
         (NonEmpty (Error l))
         (((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap),
          (Map
             Text
             (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
           ResolutionState)))
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ Validation
  (NonEmpty (Error l))
  (((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap),
   (Map
      Text
      (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
    ResolutionState))
-> (Map
      Text
      (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
    ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap),
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState))
forall a b. a -> b -> a
const (Validation
   (NonEmpty (Error l))
   (((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap),
    (Map
       Text
       (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
     ResolutionState))
 -> (Map
       Text
       (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
     ResolutionState)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap),
       (Map
          Text
          (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
        ResolutionState)))
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap),
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState))
-> (Map
      Text
      (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
    ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap),
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState))
forall a b. (a -> b) -> a -> b
$ NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap),
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState))
forall e a. e -> Validation e a
Failure (NonEmpty (Error l)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap),
       (Map
          Text
          (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
        ResolutionState)))
-> NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Declaration l l NodeWrap NodeWrap),
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState))
forall a b. (a -> b) -> a -> b
$ Error l -> NonEmpty (Error l)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Error l -> NonEmpty (Error l)) -> Error l -> NonEmpty (Error l)
forall a b. (a -> b) -> a -> b
$ [Declaration l l NodeWrap NodeWrap] -> Error l
forall l. [Declaration l l NodeWrap NodeWrap] -> Error l
AmbiguousDeclaration ([Declaration l l NodeWrap NodeWrap] -> Error l)
-> [Declaration l l NodeWrap NodeWrap] -> Error l
forall a b. (a -> b) -> a -> b
$ Compose
  ((,) (Int, Int))
  (Compose Ambiguous ((,) ParsedLexemes))
  (Declaration l l NodeWrap NodeWrap)
-> [Declaration l l NodeWrap NodeWrap]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Compose
  ((,) (Int, Int))
  (Compose Ambiguous ((,) ParsedLexemes))
  (Declaration l l NodeWrap NodeWrap)
Domain (Resolution l) (Declaration l l NodeWrap NodeWrap)
declarations)

class CoFormalParameters l where
   getFPSections :: Abstract.FormalParameters l l f' f -> [f (Abstract.FPSection l l f' f')]
   evalFPSection :: Abstract.FPSection l l f' f -> (Bool -> [Ident] -> f (Abstract.Type l l f' f') -> r) -> r
   getLocalDeclarations :: Abstract.Block l l f' f -> [f (Abstract.Declaration l l f' f')]

instance CoFormalParameters Language where
   getFPSections :: FormalParameters Language Language f' f
-> [f (FPSection Language Language f' f')]
getFPSections (FormalParameters sections _) = ZipList (f (FPSection Language Language f' f'))
-> [f (FPSection Language Language f' f')]
forall a. ZipList a -> [a]
getZipList ZipList (f (FPSection Language Language f' f'))
ZipList (f (FPSection Language Language f' f'))
sections
   evalFPSection :: FPSection Language Language f' f
-> (Bool -> [Text] -> f (Type Language Language f' f') -> r) -> r
evalFPSection (FPSection var names types) Bool -> [Text] -> f (Type Language Language f' f') -> r
f = Bool -> [Text] -> f (Type Language Language f' f') -> r
f Bool
var [Text]
names f (Type Language Language f' f')
types
   getLocalDeclarations :: Block Language Language f' f
-> [f (Declaration Language Language f' f')]
getLocalDeclarations (Block declarations _statements) = ZipList (f (Declaration Language Language f' f'))
-> [f (Declaration Language Language f' f')]
forall a. ZipList a -> [a]
getZipList ZipList (f (Declaration Language Language f' f'))
ZipList (f (Declaration Language Language f' f'))
declarations

instance {-# overlaps #-}
   (Abstract.Wirthy l, CoFormalParameters l,
    Full.Traversable (Resolution l) (Abstract.Type l l),
    Full.Traversable (Resolution l) (Abstract.FormalParameters l l),
    Full.Traversable (Resolution l) (Abstract.ConstExpression l l),
    Deep.Traversable (Resolution l) (Abstract.Type l l),
    Deep.Traversable (Resolution l) (Abstract.FormalParameters l l),
    Deep.Traversable (Resolution l) (Abstract.ConstExpression l l)) =>
   Resolution l `Transformation.At` ProcedureHeading l l NodeWrap NodeWrap where
   Resolution l
res $ :: Resolution l
-> Domain (Resolution l) (ProcedureHeading l l NodeWrap NodeWrap)
-> Codomain (Resolution l) (ProcedureHeading l l NodeWrap NodeWrap)
$ Compose ((start, end), Compose (Ambiguous ((ws, proc@(ProcedureHeading _ _ parameters)) :| []))) =
      StateT
  (Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), ProcedureHeading l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Map
           Text
           (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
         ResolutionState)
        (Validation (NonEmpty (Error l))))
     Placed
     (ProcedureHeading l l NodeWrap NodeWrap)
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (StateT
   (Map
      Text
      (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
    ResolutionState)
   (Validation (NonEmpty (Error l)))
   ((Int, ParsedLexemes, Int), ProcedureHeading l l NodeWrap NodeWrap)
 -> Compose
      (StateT
         (Map
            Text
            (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
          ResolutionState)
         (Validation (NonEmpty (Error l))))
      Placed
      (ProcedureHeading l l NodeWrap NodeWrap))
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), ProcedureHeading l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Map
           Text
           (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
         ResolutionState)
        (Validation (NonEmpty (Error l))))
     Placed
     (ProcedureHeading l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ ((Map
    Text
    (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
  ResolutionState)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int),
        ProcedureHeading l l NodeWrap NodeWrap),
       (Map
          Text
          (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
        ResolutionState)))
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), ProcedureHeading l l NodeWrap NodeWrap)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT (((Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
  -> Validation
       (NonEmpty (Error l))
       (((Int, ParsedLexemes, Int),
         ProcedureHeading l l NodeWrap NodeWrap),
        (Map
           Text
           (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
         ResolutionState)))
 -> StateT
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState)
      (Validation (NonEmpty (Error l)))
      ((Int, ParsedLexemes, Int),
       ProcedureHeading l l NodeWrap NodeWrap))
-> ((Map
       Text
       (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
     ResolutionState)
    -> Validation
         (NonEmpty (Error l))
         (((Int, ParsedLexemes, Int),
           ProcedureHeading l l NodeWrap NodeWrap),
          (Map
             Text
             (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
           ResolutionState)))
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), ProcedureHeading l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ \s :: (Map
   Text
   (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
 ResolutionState)
s@(Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
scope, ResolutionState
state)->
         let innerScope :: Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
innerScope = Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
parameterScope Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall k a. Ord k => Map k a -> Map k a -> Map k a
`Map.union` Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
scope
             parameterScope :: Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
parameterScope = case Maybe
  (Compose
     ((,) (Int, Int))
     (Compose Ambiguous ((,) ParsedLexemes))
     (FormalParameters l l NodeWrap NodeWrap))
parameters
                              of Maybe
  (Compose
     ((,) (Int, Int))
     (Compose Ambiguous ((,) ParsedLexemes))
     (FormalParameters l l NodeWrap NodeWrap))
Nothing -> Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall a. Monoid a => a
mempty
                                 Just (Compose (_, Compose (Ambiguous ((ws, fp) :| [])))) | [Compose
   ((,) (Int, Int))
   (Compose Ambiguous ((,) ParsedLexemes))
   (FPSection l l NodeWrap NodeWrap)]
sections <- FormalParameters l l NodeWrap NodeWrap
-> [Compose
      ((,) (Int, Int))
      (Compose Ambiguous ((,) ParsedLexemes))
      (FPSection l l NodeWrap NodeWrap)]
forall l (f' :: * -> *) (f :: * -> *).
CoFormalParameters l =>
FormalParameters l l f' f -> [f (FPSection l l f' f')]
getFPSections FormalParameters l l NodeWrap NodeWrap
fp
                                    -> [(Text,
  Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))]
-> Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ((Compose
   ((,) (Int, Int))
   (Compose Ambiguous ((,) ParsedLexemes))
   (FPSection l l NodeWrap NodeWrap)
 -> [(Text,
      Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))])
-> [Compose
      ((,) (Int, Int))
      (Compose Ambiguous ((,) ParsedLexemes))
      (FPSection l l NodeWrap NodeWrap)]
-> [(Text,
     Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Compose
  ((,) (Int, Int))
  (Compose Ambiguous ((,) ParsedLexemes))
  (FPSection l l NodeWrap NodeWrap)
-> [(Text,
     Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))]
binding [Compose
   ((,) (Int, Int))
   (Compose Ambiguous ((,) ParsedLexemes))
   (FPSection l l NodeWrap NodeWrap)]
sections)
             binding :: Compose
  ((,) (Int, Int))
  (Compose Ambiguous ((,) ParsedLexemes))
  (FPSection l l NodeWrap NodeWrap)
-> [(Text,
     Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))]
binding (Compose ((Int, Int)
_, Compose (Ambiguous ((ParsedLexemes
_, FPSection l l NodeWrap NodeWrap
section) :| [])))) = FPSection l l NodeWrap NodeWrap
-> (Bool
    -> [Text]
    -> NodeWrap (Type l l NodeWrap NodeWrap)
    -> [(Text,
         Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))])
-> [(Text,
     Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))]
forall l (f' :: * -> *) (f :: * -> *) r.
CoFormalParameters l =>
FPSection l l f' f
-> (Bool -> [Text] -> f (Type l l f' f') -> r) -> r
evalFPSection FPSection l l NodeWrap NodeWrap
section ((Bool
  -> [Text]
  -> NodeWrap (Type l l NodeWrap NodeWrap)
  -> [(Text,
       Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))])
 -> [(Text,
      Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))])
-> (Bool
    -> [Text]
    -> NodeWrap (Type l l NodeWrap NodeWrap)
    -> [(Text,
         Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))])
-> [(Text,
     Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))]
forall a b. (a -> b) -> a -> b
$ \ Bool
_ [Text]
names NodeWrap (Type l l NodeWrap NodeWrap)
types->
                [(Text
v, StateT
  (Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
  (Validation (NonEmpty (Error l)))
  (DeclarationRHS l Placed Placed)
-> (Map
      Text
      (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
    ResolutionState)
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (Resolution l
-> DeclarationRHS l (Domain (Resolution l)) (Domain (Resolution l))
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     (DeclarationRHS l Placed Placed)
forall t (g :: (* -> *) -> (* -> *) -> *) (m :: * -> *)
       (f :: * -> *).
(Traversable t g, Codomain t ~ Compose m f) =>
t -> g (Domain t) (Domain t) -> m (g f f)
Deep.traverse Resolution l
res (DeclarationRHS l (Domain (Resolution l)) (Domain (Resolution l))
 -> StateT
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState)
      (Validation (NonEmpty (Error l)))
      (DeclarationRHS l Placed Placed))
-> DeclarationRHS l (Domain (Resolution l)) (Domain (Resolution l))
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     (DeclarationRHS l Placed Placed)
forall a b. (a -> b) -> a -> b
$ NodeWrap (Type l l NodeWrap NodeWrap)
-> DeclarationRHS l NodeWrap NodeWrap
forall l (f' :: * -> *) (f :: * -> *).
f (Type l l f' f') -> DeclarationRHS l f' f
DeclaredVariable NodeWrap (Type l l NodeWrap NodeWrap)
types) (Map
   Text
   (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
 ResolutionState)
s) | Text
v <- [Text]
names]
         in (((Int, ParsedLexemes, Int),
  ProcedureHeading l l NodeWrap NodeWrap),
 (Map
    Text
    (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
  ResolutionState))
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int),
       ProcedureHeading l l NodeWrap NodeWrap),
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState))
forall e a. a -> Validation e a
Success (((Int
start, ParsedLexemes
ws, Int
end), ProcedureHeading l l NodeWrap NodeWrap
proc), (Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
innerScope, ResolutionState
state))
   Resolution l
res $ Compose ((start, end),
                  Compose (Ambiguous ((ws, proc@(TypeBoundHeading _var receiverName receiverType _ _ parameters))
                                      :| []))) =
      StateT
  (Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), ProcedureHeading l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Map
           Text
           (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
         ResolutionState)
        (Validation (NonEmpty (Error l))))
     Placed
     (ProcedureHeading l l NodeWrap NodeWrap)
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (StateT
   (Map
      Text
      (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
    ResolutionState)
   (Validation (NonEmpty (Error l)))
   ((Int, ParsedLexemes, Int), ProcedureHeading l l NodeWrap NodeWrap)
 -> Compose
      (StateT
         (Map
            Text
            (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
          ResolutionState)
         (Validation (NonEmpty (Error l))))
      Placed
      (ProcedureHeading l l NodeWrap NodeWrap))
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), ProcedureHeading l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Map
           Text
           (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
         ResolutionState)
        (Validation (NonEmpty (Error l))))
     Placed
     (ProcedureHeading l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ ((Map
    Text
    (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
  ResolutionState)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int),
        ProcedureHeading l l NodeWrap NodeWrap),
       (Map
          Text
          (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
        ResolutionState)))
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), ProcedureHeading l l NodeWrap NodeWrap)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT (((Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
  -> Validation
       (NonEmpty (Error l))
       (((Int, ParsedLexemes, Int),
         ProcedureHeading l l NodeWrap NodeWrap),
        (Map
           Text
           (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
         ResolutionState)))
 -> StateT
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState)
      (Validation (NonEmpty (Error l)))
      ((Int, ParsedLexemes, Int),
       ProcedureHeading l l NodeWrap NodeWrap))
-> ((Map
       Text
       (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
     ResolutionState)
    -> Validation
         (NonEmpty (Error l))
         (((Int, ParsedLexemes, Int),
           ProcedureHeading l l NodeWrap NodeWrap),
          (Map
             Text
             (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
           ResolutionState)))
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), ProcedureHeading l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ \s :: (Map
   Text
   (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
 ResolutionState)
s@(Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
scope, ResolutionState
state)->
         let innerScope :: Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
innerScope = Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
parameterScope Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall k a. Ord k => Map k a -> Map k a -> Map k a
`Map.union` Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall e (f' :: * -> *).
Map Text (Validation e (DeclarationRHS l f' Placed))
receiverBinding Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall k a. Ord k => Map k a -> Map k a -> Map k a
`Map.union` Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
scope
             receiverBinding :: Map Ident (Validation e (DeclarationRHS l f' Placed))
             receiverBinding :: Map Text (Validation e (DeclarationRHS l f' Placed))
receiverBinding = Text
-> Validation e (DeclarationRHS l f' Placed)
-> Map Text (Validation e (DeclarationRHS l f' Placed))
forall k a. k -> a -> Map k a
Map.singleton Text
receiverName (DeclarationRHS l f' Placed
-> Validation e (DeclarationRHS l f' Placed)
forall e a. a -> Validation e a
Success (DeclarationRHS l f' Placed
 -> Validation e (DeclarationRHS l f' Placed))
-> DeclarationRHS l f' Placed
-> Validation e (DeclarationRHS l f' Placed)
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), Type l l f' f')
-> DeclarationRHS l f' Placed
forall l (f' :: * -> *) (f :: * -> *).
f (Type l l f' f') -> DeclarationRHS l f' f
DeclaredVariable (((Int, ParsedLexemes, Int), Type l l f' f')
 -> DeclarationRHS l f' Placed)
-> ((Int, ParsedLexemes, Int), Type l l f' f')
-> DeclarationRHS l f' Placed
forall a b. (a -> b) -> a -> b
$ (,) (Int
start, ParsedLexemes
ws, Int
end)
                                                           (Type l l f' f' -> ((Int, ParsedLexemes, Int), Type l l f' f'))
-> Type l l f' f' -> ((Int, ParsedLexemes, Int), Type l l f' f')
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l f' f'
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference
                                                           (QualIdent l -> Type l l f' f') -> QualIdent l -> Type l l f' f'
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
receiverType)
             parameterScope :: Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
parameterScope = case Maybe
  (Compose
     ((,) (Int, Int))
     (Compose Ambiguous ((,) ParsedLexemes))
     (FormalParameters l l NodeWrap NodeWrap))
parameters
                              of Maybe
  (Compose
     ((,) (Int, Int))
     (Compose Ambiguous ((,) ParsedLexemes))
     (FormalParameters l l NodeWrap NodeWrap))
Nothing -> Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall a. Monoid a => a
mempty
                                 Just (Compose (_, Compose (Ambiguous ((ws, fp) :| [])))) | [Compose
   ((,) (Int, Int))
   (Compose Ambiguous ((,) ParsedLexemes))
   (FPSection l l NodeWrap NodeWrap)]
sections <- FormalParameters l l NodeWrap NodeWrap
-> [Compose
      ((,) (Int, Int))
      (Compose Ambiguous ((,) ParsedLexemes))
      (FPSection l l NodeWrap NodeWrap)]
forall l (f' :: * -> *) (f :: * -> *).
CoFormalParameters l =>
FormalParameters l l f' f -> [f (FPSection l l f' f')]
getFPSections FormalParameters l l NodeWrap NodeWrap
fp
                                    -> [(Text,
  Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))]
-> Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ((Compose
   ((,) (Int, Int))
   (Compose Ambiguous ((,) ParsedLexemes))
   (FPSection l l NodeWrap NodeWrap)
 -> [(Text,
      Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))])
-> [Compose
      ((,) (Int, Int))
      (Compose Ambiguous ((,) ParsedLexemes))
      (FPSection l l NodeWrap NodeWrap)]
-> [(Text,
     Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Compose
  ((,) (Int, Int))
  (Compose Ambiguous ((,) ParsedLexemes))
  (FPSection l l NodeWrap NodeWrap)
-> [(Text,
     Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))]
binding [Compose
   ((,) (Int, Int))
   (Compose Ambiguous ((,) ParsedLexemes))
   (FPSection l l NodeWrap NodeWrap)]
sections)
             binding :: Compose
  ((,) (Int, Int))
  (Compose Ambiguous ((,) ParsedLexemes))
  (FPSection l l NodeWrap NodeWrap)
-> [(Text,
     Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))]
binding (Compose ((Int, Int)
_, Compose (Ambiguous ((ParsedLexemes
_, FPSection l l NodeWrap NodeWrap
section) :| [])))) = FPSection l l NodeWrap NodeWrap
-> (Bool
    -> [Text]
    -> NodeWrap (Type l l NodeWrap NodeWrap)
    -> [(Text,
         Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))])
-> [(Text,
     Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))]
forall l (f' :: * -> *) (f :: * -> *) r.
CoFormalParameters l =>
FPSection l l f' f
-> (Bool -> [Text] -> f (Type l l f' f') -> r) -> r
evalFPSection FPSection l l NodeWrap NodeWrap
section ((Bool
  -> [Text]
  -> NodeWrap (Type l l NodeWrap NodeWrap)
  -> [(Text,
       Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))])
 -> [(Text,
      Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))])
-> (Bool
    -> [Text]
    -> NodeWrap (Type l l NodeWrap NodeWrap)
    -> [(Text,
         Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))])
-> [(Text,
     Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))]
forall a b. (a -> b) -> a -> b
$ \ Bool
_ [Text]
names NodeWrap (Type l l NodeWrap NodeWrap)
types->
                [(Text
v, StateT
  (Map
     Text
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
   ResolutionState)
  (Validation (NonEmpty (Error l)))
  (DeclarationRHS l Placed Placed)
-> (Map
      Text
      (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
    ResolutionState)
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (Resolution l
-> DeclarationRHS l (Domain (Resolution l)) (Domain (Resolution l))
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     (DeclarationRHS l Placed Placed)
forall t (g :: (* -> *) -> (* -> *) -> *) (m :: * -> *)
       (f :: * -> *).
(Traversable t g, Codomain t ~ Compose m f) =>
t -> g (Domain t) (Domain t) -> m (g f f)
Deep.traverse Resolution l
res (DeclarationRHS l (Domain (Resolution l)) (Domain (Resolution l))
 -> StateT
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState)
      (Validation (NonEmpty (Error l)))
      (DeclarationRHS l Placed Placed))
-> DeclarationRHS l (Domain (Resolution l)) (Domain (Resolution l))
-> StateT
     (Map
        Text
        (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
      ResolutionState)
     (Validation (NonEmpty (Error l)))
     (DeclarationRHS l Placed Placed)
forall a b. (a -> b) -> a -> b
$ NodeWrap (Type l l NodeWrap NodeWrap)
-> DeclarationRHS l NodeWrap NodeWrap
forall l (f' :: * -> *) (f :: * -> *).
f (Type l l f' f') -> DeclarationRHS l f' f
DeclaredVariable NodeWrap (Type l l NodeWrap NodeWrap)
types) (Map
   Text
   (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
 ResolutionState)
s) | Text
v <- [Text]
names]
         in (((Int, ParsedLexemes, Int),
  ProcedureHeading l l NodeWrap NodeWrap),
 (Map
    Text
    (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
  ResolutionState))
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int),
       ProcedureHeading l l NodeWrap NodeWrap),
      (Map
         Text
         (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)),
       ResolutionState))
forall e a. a -> Validation e a
Success (((Int
start, ParsedLexemes
ws, Int
end), ProcedureHeading l l NodeWrap NodeWrap
proc), (Map
  Text
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
innerScope, ResolutionState
state))

instance {-# overlaps #-}
   (BindableDeclaration l,
    Full.Traversable (Resolution l) (Abstract.Type l l),
    Full.Traversable (Resolution l) (Abstract.FormalParameters l l),
    Full.Traversable (Resolution l) (Abstract.ConstExpression l l),
    Deep.Traversable (Resolution l) (Abstract.Type l l),
    Deep.Traversable (Resolution l) (Abstract.FormalParameters l l),
    Deep.Traversable (Resolution l) (Abstract.ConstExpression l l)) =>
   Resolution l `Transformation.At` Block l l NodeWrap NodeWrap where
   Resolution l
res $ :: Resolution l
-> Domain (Resolution l) (Block l l NodeWrap NodeWrap)
-> Codomain (Resolution l) (Block l l NodeWrap NodeWrap)
$ Compose ((start, end), Compose (Ambiguous ((ws, body@(Block (ZipList declarations) _statements)) :| []))) =
     StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
     Placed
     (Block l l NodeWrap NodeWrap)
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (StateT
   (Scope l, ResolutionState)
   (Validation (NonEmpty (Error l)))
   ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
 -> Compose
      (StateT
         (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
      Placed
      (Block l l NodeWrap NodeWrap))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
     Placed
     (Block l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ ((Scope l, ResolutionState)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
       (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT (((Scope l, ResolutionState)
  -> Validation
       (NonEmpty (Error l))
       (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
        (Scope l, ResolutionState)))
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap))
-> ((Scope l, ResolutionState)
    -> Validation
         (NonEmpty (Error l))
         (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
          (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ \(Scope l
scope, ResolutionState
state)-> (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
 (Scope l, ResolutionState))
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
      (Scope l, ResolutionState))
forall e a. a -> Validation e a
Success (((Int
start, ParsedLexemes
ws, Int
end), Block l l NodeWrap NodeWrap
body),
                                                   (Resolution l
-> Text
-> [NodeWrap (Declaration l l NodeWrap NodeWrap)]
-> Scope l
-> Scope l
forall l.
(BindableDeclaration l, Traversable (Resolution l) (Type l l),
 Traversable (Resolution l) (FormalParameters l l),
 Traversable (Resolution l) (ConstExpression l l)) =>
Resolution l
-> Text
-> [NodeWrap (Declaration l l NodeWrap NodeWrap)]
-> Scope l
-> Scope l
localScope Resolution l
res Text
"" [NodeWrap (Declaration l l NodeWrap NodeWrap)]
declarations Scope l
scope, ResolutionState
state))
   Resolution l
_ $ Domain (Resolution l) (Block l l NodeWrap NodeWrap)
_ = StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
     Placed
     (Block l l NodeWrap NodeWrap)
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (((Scope l, ResolutionState)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
       (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT (((Scope l, ResolutionState)
  -> Validation
       (NonEmpty (Error l))
       (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
        (Scope l, ResolutionState)))
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap))
-> ((Scope l, ResolutionState)
    -> Validation
         (NonEmpty (Error l))
         (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
          (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ Validation
  (NonEmpty (Error l))
  (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
   (Scope l, ResolutionState))
-> (Scope l, ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
      (Scope l, ResolutionState))
forall a b. a -> b -> a
const (Validation
   (NonEmpty (Error l))
   (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
    (Scope l, ResolutionState))
 -> (Scope l, ResolutionState)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
       (Scope l, ResolutionState)))
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
      (Scope l, ResolutionState))
-> (Scope l, ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
      (Scope l, ResolutionState))
forall a b. (a -> b) -> a -> b
$ NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
      (Scope l, ResolutionState))
forall e a. e -> Validation e a
Failure (NonEmpty (Error l)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
       (Scope l, ResolutionState)))
-> NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap),
      (Scope l, ResolutionState))
forall a b. (a -> b) -> a -> b
$ Error l -> NonEmpty (Error l)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Error l
forall l. Error l
AmbiguousParses)

instance {-# overlaps #-}
    (Deep.Traversable (Resolution l) (Abstract.Designator l l),
     Resolution l `Transformation.At` Abstract.Designator l l NodeWrap NodeWrap) =>
    Resolution l `Transformation.At` Statement l l NodeWrap NodeWrap where
   Resolution l
res $ :: Resolution l
-> Domain (Resolution l) (Statement l l NodeWrap NodeWrap)
-> Codomain (Resolution l) (Statement l l NodeWrap NodeWrap)
$ Domain (Resolution l) (Statement l l NodeWrap NodeWrap)
statements = StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), Statement l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
     Placed
     (Statement l l NodeWrap NodeWrap)
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (StateT
   (Scope l, ResolutionState)
   (Validation (NonEmpty (Error l)))
   ((Int, ParsedLexemes, Int), Statement l l NodeWrap NodeWrap)
 -> Compose
      (StateT
         (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
      Placed
      (Statement l l NodeWrap NodeWrap))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Statement l l NodeWrap NodeWrap)
-> Compose
     (StateT
        (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
     Placed
     (Statement l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ ((Scope l, ResolutionState)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), Statement l l NodeWrap NodeWrap),
       (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Statement l l NodeWrap NodeWrap)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT (((Scope l, ResolutionState)
  -> Validation
       (NonEmpty (Error l))
       (((Int, ParsedLexemes, Int), Statement l l NodeWrap NodeWrap),
        (Scope l, ResolutionState)))
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      ((Int, ParsedLexemes, Int), Statement l l NodeWrap NodeWrap))
-> ((Scope l, ResolutionState)
    -> Validation
         (NonEmpty (Error l))
         (((Int, ParsedLexemes, Int), Statement l l NodeWrap NodeWrap),
          (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Statement l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ \s :: (Scope l, ResolutionState)
s@(Scope l
scope, ResolutionState
_state)->
      let resolveStatement :: Statement l l NodeWrap NodeWrap
                            -> Validation (NonEmpty (Error l)) (Statement l l NodeWrap NodeWrap, ResolutionState)
          resolveStatement :: Statement l l NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error l))
     (Statement l l NodeWrap NodeWrap, ResolutionState)
resolveStatement p :: Statement l l NodeWrap NodeWrap
p@(ProcedureCall NodeWrap (Designator l l NodeWrap NodeWrap)
procedures Maybe (ZipList (NodeWrap (Expression l l NodeWrap NodeWrap)))
_parameters) =
             case StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  (Placed (Designator l l NodeWrap NodeWrap))
-> (Scope l, ResolutionState)
-> Validation
     (NonEmpty (Error l)) (Placed (Designator l l NodeWrap NodeWrap))
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (Compose
  (StateT
     (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
  Placed
  (Designator l l NodeWrap NodeWrap)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     (Placed (Designator l l NodeWrap NodeWrap))
forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose (Compose
   (StateT
      (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
   Placed
   (Designator l l NodeWrap NodeWrap)
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      (Placed (Designator l l NodeWrap NodeWrap)))
-> Compose
     (StateT
        (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
     Placed
     (Designator l l NodeWrap NodeWrap)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     (Placed (Designator l l NodeWrap NodeWrap))
forall a b. (a -> b) -> a -> b
$ Resolution l
res Resolution l
-> Domain (Resolution l) (Designator l l NodeWrap NodeWrap)
-> Codomain (Resolution l) (Designator l l NodeWrap NodeWrap)
forall t x. At t x => t -> Domain t x -> Codomain t x
Transformation.$ NodeWrap (Designator l l NodeWrap NodeWrap)
Domain (Resolution l) (Designator l l NodeWrap NodeWrap)
procedures) (Scope l, ResolutionState)
s
             of Failure NonEmpty (Error l)
errors -> NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (Statement l l NodeWrap NodeWrap, ResolutionState)
forall e a. e -> Validation e a
Failure NonEmpty (Error l)
errors
                Success{} -> (Statement l l NodeWrap NodeWrap, ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (Statement l l NodeWrap NodeWrap, ResolutionState)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Statement l l NodeWrap NodeWrap
p, ResolutionState
StatementState)
          resolveStatement Statement l l NodeWrap NodeWrap
stat = (Statement l l NodeWrap NodeWrap, ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (Statement l l NodeWrap NodeWrap, ResolutionState)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Statement l l NodeWrap NodeWrap
stat, ResolutionState
StatementState)
      in (\((Int, ParsedLexemes, Int)
pos, (Statement l l NodeWrap NodeWrap
r, ResolutionState
s'))-> (((Int, ParsedLexemes, Int)
pos, Statement l l NodeWrap NodeWrap
r), (Scope l
scope, ResolutionState
s')))
         (((Int, ParsedLexemes, Int),
  (Statement l l NodeWrap NodeWrap, ResolutionState))
 -> (((Int, ParsedLexemes, Int), Statement l l NodeWrap NodeWrap),
     (Scope l, ResolutionState)))
-> Validation
     (NonEmpty (Error l))
     ((Int, ParsedLexemes, Int),
      (Statement l l NodeWrap NodeWrap, ResolutionState))
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), Statement l l NodeWrap NodeWrap),
      (Scope l, ResolutionState))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (NonEmpty (Error l) -> Error l)
-> ([(Statement l l NodeWrap NodeWrap, ResolutionState)]
    -> Error l)
-> NodeWrap
     (Validation
        (NonEmpty (Error l))
        (Statement l l NodeWrap NodeWrap, ResolutionState))
-> Validation
     (NonEmpty (Error l))
     ((Int, ParsedLexemes, Int),
      (Statement l l NodeWrap NodeWrap, ResolutionState))
forall l a.
(NonEmpty (Error l) -> Error l)
-> ([a] -> Error l)
-> NodeWrap (Validation (NonEmpty (Error l)) a)
-> Validation (NonEmpty (Error l)) (Placed a)
unique NonEmpty (Error l) -> Error l
forall l. NonEmpty (Error l) -> Error l
InvalidStatement ([Statement l l NodeWrap NodeWrap] -> Error l
forall l. [Statement l l NodeWrap NodeWrap] -> Error l
AmbiguousStatement ([Statement l l NodeWrap NodeWrap] -> Error l)
-> ([(Statement l l NodeWrap NodeWrap, ResolutionState)]
    -> [Statement l l NodeWrap NodeWrap])
-> [(Statement l l NodeWrap NodeWrap, ResolutionState)]
-> Error l
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Statement l l NodeWrap NodeWrap, ResolutionState)
-> Statement l l NodeWrap NodeWrap
forall a b. (a, b) -> a
fst ((Statement l l NodeWrap NodeWrap, ResolutionState)
 -> Statement l l NodeWrap NodeWrap)
-> [(Statement l l NodeWrap NodeWrap, ResolutionState)]
-> [Statement l l NodeWrap NodeWrap]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>)) (Statement l l NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error l))
     (Statement l l NodeWrap NodeWrap, ResolutionState)
resolveStatement (Statement l l NodeWrap NodeWrap
 -> Validation
      (NonEmpty (Error l))
      (Statement l l NodeWrap NodeWrap, ResolutionState))
-> Compose
     ((,) (Int, Int))
     (Compose Ambiguous ((,) ParsedLexemes))
     (Statement l l NodeWrap NodeWrap)
-> NodeWrap
     (Validation
        (NonEmpty (Error l))
        (Statement l l NodeWrap NodeWrap, ResolutionState))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Compose
  ((,) (Int, Int))
  (Compose Ambiguous ((,) ParsedLexemes))
  (Statement l l NodeWrap NodeWrap)
Domain (Resolution l) (Statement l l NodeWrap NodeWrap)
statements)

traverseResolveDefault :: Resolution l -> NodeWrap (g (f :: * -> *) f) -> Compose (Resolved l) Placed (g f f)
traverseResolveDefault :: Resolution l
-> NodeWrap (g f f) -> Compose (Resolved l) Placed (g f f)
traverseResolveDefault Resolution{} (Compose ((Int
start, Int
end), Compose (Ambiguous ((ParsedLexemes
ws, g f f
x) :| [])))) =
   StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), g f f)
-> Compose (Resolved l) Placed (g f f)
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (((Scope l, ResolutionState)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), g f f)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT (((Scope l, ResolutionState)
  -> Validation
       (NonEmpty (Error l))
       (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState)))
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      ((Int, ParsedLexemes, Int), g f f))
-> ((Scope l, ResolutionState)
    -> Validation
         (NonEmpty (Error l))
         (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), g f f)
forall a b. (a -> b) -> a -> b
$ \(Scope l, ResolutionState)
s-> (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState))
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState))
forall e a. a -> Validation e a
Success (((Int
start, ParsedLexemes
ws, Int
end), g f f
x), (Scope l, ResolutionState)
s))
traverseResolveDefault Resolution{} NodeWrap (g f f)
_ = StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), g f f)
-> Compose (Resolved l) Placed (g f f)
forall k k1 (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (((Scope l, ResolutionState)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), g f f)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StateT (((Scope l, ResolutionState)
  -> Validation
       (NonEmpty (Error l))
       (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState)))
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      ((Int, ParsedLexemes, Int), g f f))
-> ((Scope l, ResolutionState)
    -> Validation
         (NonEmpty (Error l))
         (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), g f f)
forall a b. (a -> b) -> a -> b
$ Validation
  (NonEmpty (Error l))
  (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState))
-> (Scope l, ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState))
forall a b. a -> b -> a
const (Validation
   (NonEmpty (Error l))
   (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState))
 -> (Scope l, ResolutionState)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState)))
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState))
-> (Scope l, ResolutionState)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState))
forall a b. (a -> b) -> a -> b
$ NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState))
forall e a. e -> Validation e a
Failure (NonEmpty (Error l)
 -> Validation
      (NonEmpty (Error l))
      (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState)))
-> NonEmpty (Error l)
-> Validation
     (NonEmpty (Error l))
     (((Int, ParsedLexemes, Int), g f f), (Scope l, ResolutionState))
forall a b. (a -> b) -> a -> b
$ Error l -> NonEmpty (Error l)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Error l
forall l. Error l
AmbiguousParses)

class Resolvable l where
   resolveDesignator :: Resolution l -> Scope l -> ResolutionState -> (Designator l l NodeWrap NodeWrap)
                     -> Validation (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap)
   resolveRecord :: Resolution l -> Scope l -> ResolutionState -> (Designator l l NodeWrap NodeWrap)
                 -> Validation (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap)

instance Resolvable Language where
   resolveDesignator :: Resolution Language
-> Scope Language
-> ResolutionState
-> Designator Language Language NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
resolveDesignator Resolution Language
res Scope Language
scope ResolutionState
state (Variable QualIdent Language
q) =
      case Resolution Language
-> Scope Language
-> QualIdent Language
-> Validation
     (NonEmpty (Error Language)) (DeclarationRHS Language Placed Placed)
forall l.
(Nameable l, Oberon l) =>
Resolution l
-> Scope l
-> QualIdent l
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
resolveName Resolution Language
res Scope Language
scope QualIdent Language
q
      of Failure NonEmpty (Error Language)
err ->  NonEmpty (Error Language)
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall e a. e -> Validation e a
Failure NonEmpty (Error Language)
err
         Success DeclaredType{} | ResolutionState
state ResolutionState -> ResolutionState -> Bool
forall a. Eq a => a -> a -> Bool
/= ResolutionState
ExpressionOrTypeState -> NonEmpty (Error Language)
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall e a. e -> Validation e a
Failure (QualIdent Language -> Error Language
forall l. QualIdent l -> Error l
NotAValue QualIdent Language
q Error Language -> [Error Language] -> NonEmpty (Error Language)
forall a. a -> [a] -> NonEmpty a
:| [])
         Success DeclarationRHS Language Placed Placed
_ -> Designator Language Language NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall e a. a -> Validation e a
Success (QualIdent Language
-> Designator Language Language NodeWrap NodeWrap
forall λ l (f' :: * -> *) (f :: * -> *).
QualIdent l -> Designator λ l f' f
Variable QualIdent Language
q)
   resolveDesignator Resolution Language
res Scope Language
scope ResolutionState
state d :: Designator Language Language NodeWrap NodeWrap
d@(Field NodeWrap (Designator Language Language NodeWrap NodeWrap)
records Text
field) =
      case StateT
  (Scope Language, ResolutionState)
  (Validation (NonEmpty (Error Language)))
  (Placed (Designator Language Language NodeWrap NodeWrap))
-> (Scope Language, ResolutionState)
-> Validation
     (NonEmpty (Error Language))
     (Placed (Designator Language Language NodeWrap NodeWrap))
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (Compose
  (StateT
     (Scope Language, ResolutionState)
     (Validation (NonEmpty (Error Language))))
  Placed
  (Designator Language Language NodeWrap NodeWrap)
-> StateT
     (Scope Language, ResolutionState)
     (Validation (NonEmpty (Error Language)))
     (Placed (Designator Language Language NodeWrap NodeWrap))
forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose (Compose
   (StateT
      (Scope Language, ResolutionState)
      (Validation (NonEmpty (Error Language))))
   Placed
   (Designator Language Language NodeWrap NodeWrap)
 -> StateT
      (Scope Language, ResolutionState)
      (Validation (NonEmpty (Error Language)))
      (Placed (Designator Language Language NodeWrap NodeWrap)))
-> Compose
     (StateT
        (Scope Language, ResolutionState)
        (Validation (NonEmpty (Error Language))))
     Placed
     (Designator Language Language NodeWrap NodeWrap)
-> StateT
     (Scope Language, ResolutionState)
     (Validation (NonEmpty (Error Language)))
     (Placed (Designator Language Language NodeWrap NodeWrap))
forall a b. (a -> b) -> a -> b
$ Resolution Language
res Resolution Language
-> Domain
     (Resolution Language)
     (Designator Language Language NodeWrap NodeWrap)
-> Codomain
     (Resolution Language)
     (Designator Language Language NodeWrap NodeWrap)
forall t x. At t x => t -> Domain t x -> Codomain t x
Transformation.$ NodeWrap (Designator Language Language NodeWrap NodeWrap)
Domain
  (Resolution Language)
  (Designator Language Language NodeWrap NodeWrap)
records) (Scope Language
scope, ResolutionState
state)
      of Failure NonEmpty (Error Language)
errors -> NonEmpty (Error Language)
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall e a. e -> Validation e a
Failure NonEmpty (Error Language)
errors
         Success{} -> Designator Language Language NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Designator Language Language NodeWrap NodeWrap
d
   resolveDesignator Resolution Language
res Scope Language
scope ResolutionState
state (TypeGuard NodeWrap (Designator Language Language NodeWrap NodeWrap)
records QualIdent Language
subtypes) =
      case (NonEmpty (Error Language) -> Error Language)
-> ([Designator Language Language NodeWrap NodeWrap]
    -> Error Language)
-> NodeWrap
     (Validation
        (NonEmpty (Error Language))
        (Designator Language Language NodeWrap NodeWrap))
-> Validation
     (NonEmpty (Error Language))
     (Placed (Designator Language Language NodeWrap NodeWrap))
forall l a.
(NonEmpty (Error l) -> Error l)
-> ([a] -> Error l)
-> NodeWrap (Validation (NonEmpty (Error l)) a)
-> Validation (NonEmpty (Error l)) (Placed a)
unique NonEmpty (Error Language) -> Error Language
forall l. NonEmpty (Error l) -> Error l
InvalidRecord [Designator Language Language NodeWrap NodeWrap] -> Error Language
forall l. [Designator l l NodeWrap NodeWrap] -> Error l
AmbiguousRecord (Resolution Language
-> Scope Language
-> ResolutionState
-> Designator Language Language NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall l.
Resolvable l =>
Resolution l
-> Scope l
-> ResolutionState
-> Designator l l NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap)
resolveRecord Resolution Language
res Scope Language
scope ResolutionState
state (Designator Language Language NodeWrap NodeWrap
 -> Validation
      (NonEmpty (Error Language))
      (Designator Language Language NodeWrap NodeWrap))
-> Compose
     ((,) (Int, Int))
     (Compose Ambiguous ((,) ParsedLexemes))
     (Designator Language Language NodeWrap NodeWrap)
-> NodeWrap
     (Validation
        (NonEmpty (Error Language))
        (Designator Language Language NodeWrap NodeWrap))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NodeWrap (Designator Language Language NodeWrap NodeWrap)
Compose
  ((,) (Int, Int))
  (Compose Ambiguous ((,) ParsedLexemes))
  (Designator Language Language NodeWrap NodeWrap)
records)
      of Failure NonEmpty (Error Language)
errors -> NonEmpty (Error Language)
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall e a. e -> Validation e a
Failure NonEmpty (Error Language)
errors
         Success{} -> NodeWrap (Designator Language Language NodeWrap NodeWrap)
-> QualIdent Language
-> Designator Language Language NodeWrap NodeWrap
forall λ l (f' :: * -> *) (f :: * -> *).
f (Designator l l f' f') -> QualIdent l -> Designator λ l f' f
TypeGuard NodeWrap (Designator Language Language NodeWrap NodeWrap)
records (QualIdent Language
 -> Designator Language Language NodeWrap NodeWrap)
-> Validation (NonEmpty (Error Language)) (QualIdent Language)
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Resolution Language
-> Scope Language
-> QualIdent Language
-> Validation (NonEmpty (Error Language)) (QualIdent Language)
forall l.
(Nameable l, Oberon l) =>
Resolution l
-> Scope l
-> QualIdent l
-> Validation (NonEmpty (Error l)) (QualIdent l)
resolveTypeName Resolution Language
res Scope Language
scope QualIdent Language
subtypes
   resolveDesignator Resolution Language
res Scope Language
scope ResolutionState
state d :: Designator Language Language NodeWrap NodeWrap
d@(Dereference NodeWrap (Designator Language Language NodeWrap NodeWrap)
pointers) =
      case StateT
  (Scope Language, ResolutionState)
  (Validation (NonEmpty (Error Language)))
  (Placed (Designator Language Language NodeWrap NodeWrap))
-> (Scope Language, ResolutionState)
-> Validation
     (NonEmpty (Error Language))
     (Placed (Designator Language Language NodeWrap NodeWrap))
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (Compose
  (StateT
     (Scope Language, ResolutionState)
     (Validation (NonEmpty (Error Language))))
  Placed
  (Designator Language Language NodeWrap NodeWrap)
-> StateT
     (Scope Language, ResolutionState)
     (Validation (NonEmpty (Error Language)))
     (Placed (Designator Language Language NodeWrap NodeWrap))
forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose (Compose
   (StateT
      (Scope Language, ResolutionState)
      (Validation (NonEmpty (Error Language))))
   Placed
   (Designator Language Language NodeWrap NodeWrap)
 -> StateT
      (Scope Language, ResolutionState)
      (Validation (NonEmpty (Error Language)))
      (Placed (Designator Language Language NodeWrap NodeWrap)))
-> Compose
     (StateT
        (Scope Language, ResolutionState)
        (Validation (NonEmpty (Error Language))))
     Placed
     (Designator Language Language NodeWrap NodeWrap)
-> StateT
     (Scope Language, ResolutionState)
     (Validation (NonEmpty (Error Language)))
     (Placed (Designator Language Language NodeWrap NodeWrap))
forall a b. (a -> b) -> a -> b
$ Resolution Language
res Resolution Language
-> Domain
     (Resolution Language)
     (Designator Language Language NodeWrap NodeWrap)
-> Codomain
     (Resolution Language)
     (Designator Language Language NodeWrap NodeWrap)
forall t x. At t x => t -> Domain t x -> Codomain t x
Transformation.$ NodeWrap (Designator Language Language NodeWrap NodeWrap)
Domain
  (Resolution Language)
  (Designator Language Language NodeWrap NodeWrap)
pointers) (Scope Language
scope, ResolutionState
state)
      of Failure NonEmpty (Error Language)
errors -> NonEmpty (Error Language)
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall e a. e -> Validation e a
Failure NonEmpty (Error Language)
errors
         Success{} -> Designator Language Language NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Designator Language Language NodeWrap NodeWrap
d
   resolveDesignator Resolution Language
_ Scope Language
_ ResolutionState
_ Designator Language Language NodeWrap NodeWrap
d = Designator Language Language NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Designator Language Language NodeWrap NodeWrap
d

   resolveRecord :: Resolution Language
-> Scope Language
-> ResolutionState
-> Designator Language Language NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
resolveRecord Resolution Language
res Scope Language
scope ResolutionState
state d :: Designator Language Language NodeWrap NodeWrap
d@(Variable QualIdent Language
q) =
      case Resolution Language
-> Scope Language
-> QualIdent Language
-> Validation
     (NonEmpty (Error Language)) (DeclarationRHS Language Placed Placed)
forall l.
(Nameable l, Oberon l) =>
Resolution l
-> Scope l
-> QualIdent l
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
resolveName Resolution Language
res Scope Language
scope QualIdent Language
q
      of Failure NonEmpty (Error Language)
err -> NonEmpty (Error Language)
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall e a. e -> Validation e a
Failure NonEmpty (Error Language)
err
         Success DeclaredType{} -> NonEmpty (Error Language)
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall e a. e -> Validation e a
Failure (QualIdent Language -> Error Language
forall l. QualIdent l -> Error l
NotAValue QualIdent Language
q Error Language -> [Error Language] -> NonEmpty (Error Language)
forall a. a -> [a] -> NonEmpty a
:| [])
         Success DeclaredProcedure{} -> NonEmpty (Error Language)
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall e a. e -> Validation e a
Failure (QualIdent Language -> Error Language
forall l. QualIdent l -> Error l
NotARecord QualIdent Language
q Error Language -> [Error Language] -> NonEmpty (Error Language)
forall a. a -> [a] -> NonEmpty a
:| [])
         Success DeclaredVariable{} -> Resolution Language
-> Scope Language
-> ResolutionState
-> Designator Language Language NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall l.
Resolvable l =>
Resolution l
-> Scope l
-> ResolutionState
-> Designator l l NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap)
resolveDesignator Resolution Language
res Scope Language
scope ResolutionState
state Designator Language Language NodeWrap NodeWrap
d
   resolveRecord Resolution Language
res Scope Language
scope ResolutionState
state Designator Language Language NodeWrap NodeWrap
d = Resolution Language
-> Scope Language
-> ResolutionState
-> Designator Language Language NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error Language))
     (Designator Language Language NodeWrap NodeWrap)
forall l.
Resolvable l =>
Resolution l
-> Scope l
-> ResolutionState
-> Designator l l NodeWrap NodeWrap
-> Validation
     (NonEmpty (Error l)) (Designator l l NodeWrap NodeWrap)
resolveDesignator Resolution Language
res Scope Language
scope ResolutionState
state Designator Language Language NodeWrap NodeWrap
d

resolveTypeName :: Resolution l
-> Scope l
-> QualIdent l
-> Validation (NonEmpty (Error l)) (QualIdent l)
resolveTypeName Resolution l
res Scope l
scope QualIdent l
q =
   case Resolution l
-> Scope l
-> QualIdent l
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall l.
(Nameable l, Oberon l) =>
Resolution l
-> Scope l
-> QualIdent l
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
resolveName Resolution l
res Scope l
scope QualIdent l
q
   of Failure NonEmpty (Error l)
err ->  NonEmpty (Error l) -> Validation (NonEmpty (Error l)) (QualIdent l)
forall e a. e -> Validation e a
Failure NonEmpty (Error l)
err
      Success DeclaredType{} -> QualIdent l -> Validation (NonEmpty (Error l)) (QualIdent l)
forall e a. a -> Validation e a
Success QualIdent l
q
      Success DeclarationRHS l Placed Placed
_ -> NonEmpty (Error l) -> Validation (NonEmpty (Error l)) (QualIdent l)
forall e a. e -> Validation e a
Failure (QualIdent l -> Error l
forall l. QualIdent l -> Error l
NotAType QualIdent l
q Error l -> [Error l] -> NonEmpty (Error l)
forall a. a -> [a] -> NonEmpty a
:| [])

resolveName :: (Abstract.Nameable l, Abstract.Oberon l)
            => Resolution l -> Scope l -> Abstract.QualIdent l
            -> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
resolveName :: Resolution l
-> Scope l
-> QualIdent l
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
resolveName Resolution l
res Scope l
scope QualIdent l
q
   | Just (Text
moduleName, Text
name) <- QualIdent l -> Maybe (Text, Text)
forall l. Oberon l => QualIdent l -> Maybe (Text, Text)
Abstract.getQualIdentNames QualIdent l
q =
     case Text -> Map Text (Scope l) -> Maybe (Scope l)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
moduleName (Resolution l -> Map Text (Scope l)
forall l. Resolution l -> Map Text (Scope l)
_modules Resolution l
res)
     of Maybe (Scope l)
Nothing -> NonEmpty (Error l)
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall e a. e -> Validation e a
Failure (QualIdent l -> Error l
forall l. QualIdent l -> Error l
UnknownModule QualIdent l
q Error l -> [Error l] -> NonEmpty (Error l)
forall a. a -> [a] -> NonEmpty a
:| [])
        Just Scope l
exports -> case Text
-> Scope l
-> Maybe
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
name Scope l
exports
                        of Just Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
rhs -> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
rhs
                           Maybe
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
Nothing -> NonEmpty (Error l)
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall e a. e -> Validation e a
Failure (QualIdent l -> Error l
forall l. QualIdent l -> Error l
UnknownImport QualIdent l
q Error l -> [Error l] -> NonEmpty (Error l)
forall a. a -> [a] -> NonEmpty a
:| [])
   | Just Text
name <- QualIdent l -> Maybe Text
forall l. Nameable l => QualIdent l -> Maybe Text
Abstract.getNonQualIdentName QualIdent l
q =
     case Text
-> Scope l
-> Maybe
     (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
name Scope l
scope
     of Just (Success DeclarationRHS l Placed Placed
rhs) -> DeclarationRHS l Placed Placed
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall e a. a -> Validation e a
Success DeclarationRHS l Placed Placed
rhs
        Maybe
  (Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
_ -> NonEmpty (Error l)
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall e a. e -> Validation e a
Failure (Text -> Error l
forall l. Text -> Error l
UnknownLocal Text
name Error l -> [Error l] -> NonEmpty (Error l)
forall a. a -> [a] -> NonEmpty a
:| [])

-- | Resolve ambiguities in the given collection of modules, a 'Map' keyed by module name. The value for the first
-- argument is typically 'predefined' or 'predefined2'. Note that all class constraints in the function's type
-- signature are satisfied by the Oberon 'Language'.
resolveModules :: forall l. (BindableDeclaration l, CoFormalParameters l, Abstract.Wirthy l,
                             Deep.Traversable (Resolution l) (Abstract.Declaration l l),
                             Deep.Traversable (Resolution l) (Abstract.Type l l),
                             Deep.Traversable (Resolution l) (Abstract.ProcedureHeading l l),
                             Deep.Traversable (Resolution l) (Abstract.FormalParameters l l),
                             Deep.Traversable (Resolution l) (Abstract.Expression l l),
                             Deep.Traversable (Resolution l) (Abstract.Block l l),
                             Deep.Traversable (Resolution l) (Abstract.StatementSequence l l),
                             Full.Traversable (Resolution l) (Abstract.Declaration l l),
                             Full.Traversable (Resolution l) (Abstract.Type l l),
                             Full.Traversable (Resolution l) (Abstract.ProcedureHeading l l),
                             Full.Traversable (Resolution l) (Abstract.FormalParameters l l),
                             Full.Traversable (Resolution l) (Abstract.Expression l l),
                             Full.Traversable (Resolution l) (Abstract.Block l l),
                             Full.Traversable (Resolution l) (Abstract.StatementSequence l l),
                             Resolution l `Transformation.At` Abstract.Block l l NodeWrap NodeWrap) =>
                  Predefined l -> Map Ident (NodeWrap (Module l l NodeWrap NodeWrap))
                -> Validation (NonEmpty (Ident, NonEmpty (Error l))) (Map Ident (Placed (Module l l Placed Placed)))
resolveModules :: Predefined l
-> Map Text (NodeWrap (Module l l NodeWrap NodeWrap))
-> Validation
     (NonEmpty (Text, NonEmpty (Error l)))
     (Map Text (Placed (Module l l Placed Placed)))
resolveModules Predefined l
predefinedScope Map Text (NodeWrap (Module l l NodeWrap NodeWrap))
modules = (Text
 -> Validation
      (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
 -> Validation
      (NonEmpty (Text, NonEmpty (Error l)))
      (Placed (Module l l Placed Placed)))
-> Map
     Text
     (Validation
        (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
-> Validation
     (NonEmpty (Text, NonEmpty (Error l)))
     (Map Text (Placed (Module l l Placed Placed)))
forall (t :: * -> *) k a b.
Applicative t =>
(k -> a -> t b) -> Map k a -> t (Map k b)
traverseWithKey Text
-> Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
-> Validation
     (NonEmpty (Text, NonEmpty (Error l)))
     (Placed (Module l l Placed Placed))
forall a b a. a -> Validation b a -> Validation (NonEmpty (a, b)) a
extractErrors Map
  Text
  (Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
modules'
   where modules' :: Map
  Text
  (Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
modules' = Predefined l
-> Map
     Text
     (Validation
        (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
-> NodeWrap (Module l l NodeWrap NodeWrap)
-> Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
forall l.
(BindableDeclaration l, CoFormalParameters l,
 Traversable (Resolution l) (Block l l),
 Traversable (Resolution l) (Declaration l l),
 Traversable (Resolution l) (Type l l),
 Traversable (Resolution l) (FormalParameters l l),
 Traversable (Resolution l) (ConstExpression l l),
 Traversable (Resolution l) (StatementSequence l l),
 Traversable (Resolution l) (Declaration l l),
 Traversable (Resolution l) (Declaration l l),
 Traversable (Resolution l) (StatementSequence l l),
 Traversable (Resolution l) (Type l l),
 Traversable (Resolution l) (FormalParameters l l),
 Traversable (Resolution l) (ConstExpression l l),
 At (Resolution l) (Block l l NodeWrap NodeWrap)) =>
Scope l
-> Map
     Text
     (Validation
        (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
-> NodeWrap (Module l l NodeWrap NodeWrap)
-> Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
resolveModule Predefined l
predefinedScope Map
  Text
  (Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
modules' (NodeWrap (Module l l NodeWrap NodeWrap)
 -> Validation
      (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
-> Map Text (NodeWrap (Module l l NodeWrap NodeWrap))
-> Map
     Text
     (Validation
        (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map Text (NodeWrap (Module l l NodeWrap NodeWrap))
modules
         extractErrors :: a -> Validation b a -> Validation (NonEmpty (a, b)) a
extractErrors a
moduleKey (Failure b
e)   = NonEmpty (a, b) -> Validation (NonEmpty (a, b)) a
forall e a. e -> Validation e a
Failure ((a
moduleKey, b
e) (a, b) -> [(a, b)] -> NonEmpty (a, b)
forall a. a -> [a] -> NonEmpty a
:| [])
         extractErrors a
_         (Success a
mod) = a -> Validation (NonEmpty (a, b)) a
forall e a. a -> Validation e a
Success a
mod

-- | Resolve ambiguities in a single module. The value for the first argument is typically 'predefined' or
-- 'predefined2'. The imports are resolved using the given map of already resolved modules. Note that all class
-- constraints in the function's type signature are satisfied by the Oberon 'Language'.
resolveModule :: forall l. (BindableDeclaration l, CoFormalParameters l,
                            Full.Traversable (Resolution l) (Abstract.Block l l),
                            Full.Traversable (Resolution l) (Abstract.Declaration l l),
                            Full.Traversable (Resolution l) (Abstract.Type l l),
                            Full.Traversable (Resolution l) (Abstract.FormalParameters l l),
                            Full.Traversable (Resolution l) (Abstract.ConstExpression l l),
                            Full.Traversable (Resolution l) (Abstract.StatementSequence l l),
                            Deep.Traversable (Resolution l) (Declaration l l),
                            Deep.Traversable (Resolution l) (Abstract.Declaration l l),
                            Deep.Traversable (Resolution l) (Abstract.StatementSequence l l),
                            Deep.Traversable (Resolution l) (Abstract.Type l l),
                            Deep.Traversable (Resolution l) (Abstract.FormalParameters l l),
                            Deep.Traversable (Resolution l) (Abstract.ConstExpression l l),
                            Resolution l `Transformation.At` Abstract.Block l l NodeWrap NodeWrap) =>
                 Scope l -> Map Ident (Validation (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
              -> NodeWrap (Module l l NodeWrap NodeWrap)
              -> Validation (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
resolveModule :: Scope l
-> Map
     Text
     (Validation
        (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
-> NodeWrap (Module l l NodeWrap NodeWrap)
-> Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
resolveModule Scope l
predefined Map
  Text
  (Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
modules m :: NodeWrap (Module l l NodeWrap NodeWrap)
m@(Compose ((Int, Int)
pos, Compose (Ambiguous ((ParsedLexemes
ls, Module Text
moduleName [Import l]
imports NodeWrap (Block l l NodeWrap NodeWrap)
body) :| [])))) =
   StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  (Placed (Module l l Placed Placed))
-> (Scope l, ResolutionState)
-> Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (Resolution l
-> Domain
     (Resolution l)
     (Module l l (Domain (Resolution l)) (Domain (Resolution l)))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     (Placed (Module l l Placed Placed))
forall t (g :: (* -> *) -> (* -> *) -> *) (m :: * -> *)
       (f :: * -> *).
(Traversable t g, Codomain t ~ Compose m f) =>
t -> Domain t (g (Domain t) (Domain t)) -> m (f (g f f))
Full.traverse Resolution l
res NodeWrap (Module l l NodeWrap NodeWrap)
Domain
  (Resolution l)
  (Module l l (Domain (Resolution l)) (Domain (Resolution l)))
m) (Scope l
moduleGlobalScope, ResolutionState
ModuleState)
   where res :: Resolution l
res = Map Text (Scope l) -> Resolution l
forall l. Map Text (Scope l) -> Resolution l
Resolution Map Text (Scope l)
moduleExports
         importedModules :: Map
  Text
  (Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
importedModules = Text
-> Map
     Text
     (Validation
        (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
-> Map
     Text
     (Validation
        (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
forall k a. Ord k => k -> Map k a -> Map k a
Map.delete Text
forall a. Monoid a => a
mempty ((Validation
   (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
 -> Validation
      (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
 -> Validation
      (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
-> (Text -> Text)
-> Map
     Text
     (Validation
        (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
-> Map
     Text
     (Validation
        (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
forall k2 a k1.
Ord k2 =>
(a -> a -> a) -> (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeysWith Validation (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
-> Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
-> Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
forall p p l a. p -> p -> Validation (NonEmpty (Error l)) a
clashingRenames Text -> Text
importedAs Map
  Text
  (Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
modules)
            where importedAs :: Text -> Text
importedAs Text
moduleName = case (Import l -> Bool) -> [Import l] -> Maybe (Import l)
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
List.find ((Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
moduleName) (Text -> Bool) -> (Import l -> Text) -> Import l -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Import l -> Text
forall a b. (a, b) -> b
snd) [Import l]
imports
                                          of Just (Maybe Text
Nothing, Text
moduleKey) -> Text
moduleKey
                                             Just (Just Text
innerKey, Text
_) -> Text
innerKey
                                             Maybe (Import l)
Nothing -> Text
forall a. Monoid a => a
mempty
                  clashingRenames :: p -> p -> Validation (NonEmpty (Error l)) a
clashingRenames p
_ p
_ = NonEmpty (Error l) -> Validation (NonEmpty (Error l)) a
forall e a. e -> Validation e a
Failure (Error l
forall l. Error l
ClashingImports Error l -> [Error l] -> NonEmpty (Error l)
forall a. a -> [a] -> NonEmpty a
:| [])
         resolveDeclaration :: NodeWrap (Declaration l l NodeWrap NodeWrap) -> Resolved l (Declaration l l Placed Placed)
         resolveDeclaration :: NodeWrap (Declaration l l NodeWrap NodeWrap)
-> Resolved l (Declaration l l Placed Placed)
resolveDeclaration NodeWrap (Declaration l l NodeWrap NodeWrap)
d = ((Int, ParsedLexemes, Int), Declaration l l Placed Placed)
-> Declaration l l Placed Placed
forall a b. (a, b) -> b
snd (((Int, ParsedLexemes, Int), Declaration l l Placed Placed)
 -> Declaration l l Placed Placed)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Declaration l l Placed Placed)
-> Resolved l (Declaration l l Placed Placed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Declaration l l NodeWrap NodeWrap
 -> Resolved l (Declaration l l Placed Placed))
-> NodeWrap (Declaration l l NodeWrap NodeWrap)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     (Compose
        ((,) (Int, Int))
        (Compose Ambiguous ((,) ParsedLexemes))
        (Declaration l l Placed Placed))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (Resolution l
-> Declaration l l (Domain (Resolution l)) (Domain (Resolution l))
-> Resolved l (Declaration l l Placed Placed)
forall t (g :: (* -> *) -> (* -> *) -> *) (m :: * -> *)
       (f :: * -> *).
(Traversable t g, Codomain t ~ Compose m f) =>
t -> g (Domain t) (Domain t) -> m (g f f)
Deep.traverse Resolution l
res) NodeWrap (Declaration l l NodeWrap NodeWrap)
d StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  (Compose
     ((,) (Int, Int))
     (Compose Ambiguous ((,) ParsedLexemes))
     (Declaration l l Placed Placed))
-> (Compose
      ((,) (Int, Int))
      (Compose Ambiguous ((,) ParsedLexemes))
      (Declaration l l Placed Placed)
    -> StateT
         (Scope l, ResolutionState)
         (Validation (NonEmpty (Error l)))
         ((Int, ParsedLexemes, Int), Declaration l l Placed Placed))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Declaration l l Placed Placed)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Compose
  (StateT
     (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
  Placed
  (Declaration l l Placed Placed)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Declaration l l Placed Placed)
forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose (Compose
   (StateT
      (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
   Placed
   (Declaration l l Placed Placed)
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      ((Int, ParsedLexemes, Int), Declaration l l Placed Placed))
-> (Compose
      ((,) (Int, Int))
      (Compose Ambiguous ((,) ParsedLexemes))
      (Declaration l l Placed Placed)
    -> Compose
         (StateT
            (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
         Placed
         (Declaration l l Placed Placed))
-> Compose
     ((,) (Int, Int))
     (Compose Ambiguous ((,) ParsedLexemes))
     (Declaration l l Placed Placed)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Declaration l l Placed Placed)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Resolution l
res Resolution l
-> Domain (Resolution l) (Declaration l l Placed Placed)
-> Codomain (Resolution l) (Declaration l l Placed Placed)
forall t x. At t x => t -> Domain t x -> Codomain t x
Transformation.$))
         moduleExports :: Map Text (Scope l)
moduleExports = (Placed (Module l l Placed Placed) -> Scope l)
-> Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
-> Scope l
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (Module l l Placed Placed -> Scope l
forall l.
(BindableDeclaration l, CoFormalParameters l) =>
Module l l Placed Placed -> Scope l
exportsOfModule (Module l l Placed Placed -> Scope l)
-> (Placed (Module l l Placed Placed) -> Module l l Placed Placed)
-> Placed (Module l l Placed Placed)
-> Scope l
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Placed (Module l l Placed Placed) -> Module l l Placed Placed
forall a b. (a, b) -> b
snd) (Validation
   (NonEmpty (Error l)) (Placed (Module l l Placed Placed))
 -> Scope l)
-> Map
     Text
     (Validation
        (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
-> Map Text (Scope l)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map
  Text
  (Validation
     (NonEmpty (Error l)) (Placed (Module l l Placed Placed)))
importedModules
         Success ((Int, ParsedLexemes, Int)
_, Block l l NodeWrap NodeWrap
body') = StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
-> (Scope l, ResolutionState)
-> Validation
     (NonEmpty (Error l))
     ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (Compose
  (StateT
     (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
  Placed
  (Block l l NodeWrap NodeWrap)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose (Compose
   (StateT
      (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
   Placed
   (Block l l NodeWrap NodeWrap)
 -> StateT
      (Scope l, ResolutionState)
      (Validation (NonEmpty (Error l)))
      ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap))
-> Compose
     (StateT
        (Scope l, ResolutionState) (Validation (NonEmpty (Error l))))
     Placed
     (Block l l NodeWrap NodeWrap)
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     ((Int, ParsedLexemes, Int), Block l l NodeWrap NodeWrap)
forall a b. (a -> b) -> a -> b
$ Resolution l
res Resolution l
-> Domain (Resolution l) (Block l l NodeWrap NodeWrap)
-> Codomain (Resolution l) (Block l l NodeWrap NodeWrap)
forall t x. At t x => t -> Domain t x -> Codomain t x
Transformation.$ NodeWrap (Block l l NodeWrap NodeWrap)
Domain (Resolution l) (Block l l NodeWrap NodeWrap)
body) (Scope l
predefined, ResolutionState
ModuleState)
         moduleGlobalScope :: Scope l
moduleGlobalScope = Resolution l
-> Text
-> [NodeWrap (Declaration l l NodeWrap NodeWrap)]
-> Scope l
-> Scope l
forall l.
(BindableDeclaration l, Traversable (Resolution l) (Type l l),
 Traversable (Resolution l) (FormalParameters l l),
 Traversable (Resolution l) (ConstExpression l l)) =>
Resolution l
-> Text
-> [NodeWrap (Declaration l l NodeWrap NodeWrap)]
-> Scope l
-> Scope l
localScope Resolution l
res Text
moduleName (Block l l NodeWrap NodeWrap
-> [NodeWrap (Declaration l l NodeWrap NodeWrap)]
forall l (f' :: * -> *) (f :: * -> *).
CoFormalParameters l =>
Block l l f' f -> [f (Declaration l l f' f')]
getLocalDeclarations Block l l NodeWrap NodeWrap
body') Scope l
predefined

localScope :: forall l. (BindableDeclaration l,
                         Full.Traversable (Resolution l) (Abstract.Type l l),
                         Full.Traversable (Resolution l) (Abstract.FormalParameters l l),
                         Full.Traversable (Resolution l) (Abstract.ConstExpression l l)) =>
              Resolution l -> Ident -> [NodeWrap (Abstract.Declaration l l NodeWrap NodeWrap)] -> Scope l -> Scope l
localScope :: Resolution l
-> Text
-> [NodeWrap (Declaration l l NodeWrap NodeWrap)]
-> Scope l
-> Scope l
localScope Resolution l
res Text
qual [NodeWrap (Declaration l l NodeWrap NodeWrap)]
declarations Scope l
outerScope = Scope l
innerScope
   where innerScope :: Scope l
innerScope = Scope l -> Scope l -> Scope l
forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union ((AccessMode,
 Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall a b. (a, b) -> b
snd ((AccessMode,
  Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
 -> Validation
      (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Map
     Text
     (AccessMode,
      Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Scope l
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map
  Text
  (AccessMode,
   Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
scopeAdditions) Scope l
outerScope
         scopeAdditions :: Map
  Text
  (AccessMode,
   Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
scopeAdditions = (Resolution l
-> Scope l
-> DeclarationRHS l NodeWrap NodeWrap
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
resolveBinding Resolution l
res Scope l
innerScope (DeclarationRHS l NodeWrap NodeWrap
 -> Validation
      (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> (AccessMode, DeclarationRHS l NodeWrap NodeWrap)
-> (AccessMode,
    Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>)
                          ((AccessMode, DeclarationRHS l NodeWrap NodeWrap)
 -> (AccessMode,
     Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)))
-> Map Text (AccessMode, DeclarationRHS l NodeWrap NodeWrap)
-> Map
     Text
     (AccessMode,
      Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Text, (AccessMode, DeclarationRHS l NodeWrap NodeWrap))]
-> Map Text (AccessMode, DeclarationRHS l NodeWrap NodeWrap)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ((NodeWrap (Declaration l l NodeWrap NodeWrap)
 -> [(Text, (AccessMode, DeclarationRHS l NodeWrap NodeWrap))])
-> [NodeWrap (Declaration l l NodeWrap NodeWrap)]
-> [(Text, (AccessMode, DeclarationRHS l NodeWrap NodeWrap))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Text
-> Declaration l l NodeWrap NodeWrap
-> [(Text, (AccessMode, DeclarationRHS l NodeWrap NodeWrap))]
forall l (f :: * -> *).
(BindableDeclaration l, Foldable f) =>
Text
-> Declaration l l f f
-> [(Text, (AccessMode, DeclarationRHS l f f))]
declarationBinding Text
qual (Declaration l l NodeWrap NodeWrap
 -> [(Text, (AccessMode, DeclarationRHS l NodeWrap NodeWrap))])
-> (NodeWrap (Declaration l l NodeWrap NodeWrap)
    -> Declaration l l NodeWrap NodeWrap)
-> NodeWrap (Declaration l l NodeWrap NodeWrap)
-> [(Text, (AccessMode, DeclarationRHS l NodeWrap NodeWrap))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NodeWrap (Declaration l l NodeWrap NodeWrap)
-> Declaration l l NodeWrap NodeWrap
forall a a a. Compose ((,) a) (Compose Ambiguous ((,) a)) a -> a
unamb) [NodeWrap (Declaration l l NodeWrap NodeWrap)]
declarations)
         unamb :: Compose ((,) a) (Compose Ambiguous ((,) a)) a -> a
unamb (Compose (a
offset, Compose (Ambiguous ((a
_, a
x) :| [])))) = a
x
         resolveBinding     :: Resolution l -> Scope l -> DeclarationRHS l NodeWrap NodeWrap
                            -> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
         resolveBinding :: Resolution l
-> Scope l
-> DeclarationRHS l NodeWrap NodeWrap
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
resolveBinding Resolution l
res Scope l
scope DeclarationRHS l NodeWrap NodeWrap
dr = StateT
  (Scope l, ResolutionState)
  (Validation (NonEmpty (Error l)))
  (DeclarationRHS l Placed Placed)
-> (Scope l, ResolutionState)
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (Resolution l
-> DeclarationRHS l (Domain (Resolution l)) (Domain (Resolution l))
-> StateT
     (Scope l, ResolutionState)
     (Validation (NonEmpty (Error l)))
     (DeclarationRHS l Placed Placed)
forall t (g :: (* -> *) -> (* -> *) -> *) (m :: * -> *)
       (f :: * -> *).
(Traversable t g, Codomain t ~ Compose m f) =>
t -> g (Domain t) (Domain t) -> m (g f f)
Deep.traverse Resolution l
res DeclarationRHS l NodeWrap NodeWrap
DeclarationRHS l (Domain (Resolution l)) (Domain (Resolution l))
dr) (Scope l
scope, ResolutionState
DeclarationState)

class BindableDeclaration l where
   declarationBinding :: Foldable f => Ident -> Abstract.Declaration l l f f -> [(Ident, (AccessMode, DeclarationRHS l f f))]
   
instance BindableDeclaration Language where
   declarationBinding :: Text
-> Declaration Language Language f f
-> [(Text, (AccessMode, DeclarationRHS Language f f))]
declarationBinding Text
_ (ConstantDeclaration (IdentDef name export) expr) =
      [(Text
name, (AccessMode
export, f (ConstExpression Language Language f f)
-> DeclarationRHS Language f f
forall l (f' :: * -> *) (f :: * -> *).
f (ConstExpression l l f' f') -> DeclarationRHS l f' f
DeclaredConstant f (ConstExpression Language Language f f)
expr))]
   declarationBinding Text
_ (TypeDeclaration (IdentDef name export) typeDef) =
      [(Text
name, (AccessMode
export, f (Type Language Language f f) -> DeclarationRHS Language f f
forall l (f' :: * -> *) (f :: * -> *).
f (Type l l f' f') -> DeclarationRHS l f' f
DeclaredType f (Type Language Language f f)
typeDef))]
   declarationBinding Text
_ (VariableDeclaration names typeDef) =
      [(Text
name, (AccessMode
export, f (Type Language Language f f) -> DeclarationRHS Language f f
forall l (f' :: * -> *) (f :: * -> *).
f (Type l l f' f') -> DeclarationRHS l f' f
DeclaredVariable f (Type Language Language f f)
typeDef)) | (IdentDef Text
name AccessMode
export) <- NonEmpty (IdentDef Language) -> [IdentDef Language]
forall a. NonEmpty a -> [a]
NonEmpty.toList IdentList Language
NonEmpty (IdentDef Language)
names]
   declarationBinding Text
moduleName (ProcedureDeclaration heading _) = ProcedureHeading Language Language f f
-> [(Text, (AccessMode, DeclarationRHS Language f f))]
procedureHeadBinding ((ProcedureHeading Language Language f f
 -> ProcedureHeading Language Language f f
 -> ProcedureHeading Language Language f f)
-> f (ProcedureHeading Language Language f f)
-> ProcedureHeading Language Language f f
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldr1 ProcedureHeading Language Language f f
-> ProcedureHeading Language Language f f
-> ProcedureHeading Language Language f f
forall a b. a -> b -> a
const f (ProcedureHeading Language Language f f)
f (ProcedureHeading Language Language f f)
heading)
      where procedureHeadBinding :: ProcedureHeading Language Language f f
-> [(Text, (AccessMode, DeclarationRHS Language f f))]
procedureHeadBinding (ProcedureHeading Bool
_ (IdentDef name export) Maybe (f (FormalParameters Language Language f f))
parameters) =
               [(Text
name, (AccessMode
export, Bool
-> Maybe (f (FormalParameters Language Language f f))
-> DeclarationRHS Language f f
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure (Text
moduleName Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"SYSTEM") Maybe (f (FormalParameters Language Language f f))
parameters))]
            procedureHeadBinding (TypeBoundHeading Bool
_ Text
_ Text
_ Bool
_ (IdentDef name export) Maybe (f (FormalParameters Language Language f f))
parameters) =
               [(Text
name, (AccessMode
export, Bool
-> Maybe (f (FormalParameters Language Language f f))
-> DeclarationRHS Language f f
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure (Text
moduleName Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"SYSTEM") Maybe (f (FormalParameters Language Language f f))
parameters))]
   declarationBinding Text
_ (ForwardDeclaration (IdentDef name export) parameters) =
      [(Text
name, (AccessMode
export, Bool
-> Maybe (f (FormalParameters Language Language f f))
-> DeclarationRHS Language f f
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False Maybe (f (FormalParameters Language Language f f))
parameters))]

predefined, predefined2 :: Abstract.Oberon l => Predefined l
-- | The set of 'Predefined' types and procedures defined in the Oberon Language Report.
predefined :: Predefined l
predefined = DeclarationRHS l Placed Placed
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall e a. a -> Validation e a
Success (DeclarationRHS l Placed Placed
 -> Validation
      (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Map Text (DeclarationRHS l Placed Placed) -> Predefined l
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Text, DeclarationRHS l Placed Placed)]
-> Map Text (DeclarationRHS l Placed Placed)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
   [(Text
"BOOLEAN", ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
f (Type l l f' f') -> DeclarationRHS l f' f
DeclaredType (Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"BOOLEAN")),
    (Text
"CHAR", ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
f (Type l l f' f') -> DeclarationRHS l f' f
DeclaredType (Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"CHAR")),
    (Text
"SHORTINT", ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
f (Type l l f' f') -> DeclarationRHS l f' f
DeclaredType (Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"SHORTINT")),
    (Text
"INTEGER", ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
f (Type l l f' f') -> DeclarationRHS l f' f
DeclaredType (Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER")),
    (Text
"LONGINT", ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
f (Type l l f' f') -> DeclarationRHS l f' f
DeclaredType (Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"LONGINT")),
    (Text
"REAL", ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
f (Type l l f' f') -> DeclarationRHS l f' f
DeclaredType (Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"REAL")),
    (Text
"LONGREAL", ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
f (Type l l f' f') -> DeclarationRHS l f' f
DeclaredType (Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"LONGREAL")),
    (Text
"SET", ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
f (Type l l f' f') -> DeclarationRHS l f' f
DeclaredType (Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"SET")),
    (Text
"TRUE", ((Int, ParsedLexemes, Int), ConstExpression l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
f (ConstExpression l l f' f') -> DeclarationRHS l f' f
DeclaredConstant (ConstExpression l l Placed Placed
-> ((Int, ParsedLexemes, Int), ConstExpression l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (ConstExpression l l Placed Placed
 -> ((Int, ParsedLexemes, Int), ConstExpression l l Placed Placed))
-> ConstExpression l l Placed Placed
-> ((Int, ParsedLexemes, Int), ConstExpression l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), Designator l l Placed Placed)
-> ConstExpression l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Designator l' l' f' f') -> Expression l l' f' f
Abstract.read (((Int, ParsedLexemes, Int), Designator l l Placed Placed)
 -> ConstExpression l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Designator l l Placed Placed)
-> ConstExpression l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Designator l l Placed Placed
-> ((Int, ParsedLexemes, Int), Designator l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (Designator l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Designator l l Placed Placed))
-> Designator l l Placed Placed
-> ((Int, ParsedLexemes, Int), Designator l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Designator l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Designator l l' f' f
Abstract.variable (QualIdent l -> Designator l l Placed Placed)
-> QualIdent l -> Designator l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"TRUE")),
    (Text
"FALSE", ((Int, ParsedLexemes, Int), ConstExpression l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
f (ConstExpression l l f' f') -> DeclarationRHS l f' f
DeclaredConstant (ConstExpression l l Placed Placed
-> ((Int, ParsedLexemes, Int), ConstExpression l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (ConstExpression l l Placed Placed
 -> ((Int, ParsedLexemes, Int), ConstExpression l l Placed Placed))
-> ConstExpression l l Placed Placed
-> ((Int, ParsedLexemes, Int), ConstExpression l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), Designator l l Placed Placed)
-> ConstExpression l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
f (Designator l' l' f' f') -> Expression l l' f' f
Abstract.read (((Int, ParsedLexemes, Int), Designator l l Placed Placed)
 -> ConstExpression l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Designator l l Placed Placed)
-> ConstExpression l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Designator l l Placed Placed
-> ((Int, ParsedLexemes, Int), Designator l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (Designator l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Designator l l Placed Placed))
-> Designator l l Placed Placed
-> ((Int, ParsedLexemes, Int), Designator l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Designator l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Designator l l' f' f
Abstract.variable (QualIdent l -> Designator l l Placed Placed)
-> QualIdent l -> Designator l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"FALSE")),
    (Text
"ABS", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
            [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                       (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"] (Maybe (QualIdent l) -> FormalParameters l l Placed Placed)
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall a b. (a -> b) -> a -> b
$
            QualIdent l -> Maybe (QualIdent l)
forall a. a -> Maybe a
Just (QualIdent l -> Maybe (QualIdent l))
-> QualIdent l -> Maybe (QualIdent l)
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"),
    (Text
"ASH", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
            [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                       (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"] (Maybe (QualIdent l) -> FormalParameters l l Placed Placed)
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall a b. (a -> b) -> a -> b
$
            QualIdent l -> Maybe (QualIdent l)
forall a. a -> Maybe a
Just (QualIdent l -> Maybe (QualIdent l))
-> QualIdent l -> Maybe (QualIdent l)
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"),
    (Text
"CAP", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
            [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"c") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                       (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"CHAR"] (Maybe (QualIdent l) -> FormalParameters l l Placed Placed)
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall a b. (a -> b) -> a -> b
$
            QualIdent l -> Maybe (QualIdent l)
forall a. a -> Maybe a
Just (QualIdent l -> Maybe (QualIdent l))
-> QualIdent l -> Maybe (QualIdent l)
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"CHAR"),
    (Text
"LEN", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
            [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"c") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                       (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"ARRAY"] (Maybe (QualIdent l) -> FormalParameters l l Placed Placed)
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall a b. (a -> b) -> a -> b
$
            QualIdent l -> Maybe (QualIdent l)
forall a. a -> Maybe a
Just (QualIdent l -> Maybe (QualIdent l))
-> QualIdent l -> Maybe (QualIdent l)
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"LONGINT"),
    (Text
"MAX", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
True (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
            [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"c") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                       (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"SET"] (Maybe (QualIdent l) -> FormalParameters l l Placed Placed)
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall a b. (a -> b) -> a -> b
$
            QualIdent l -> Maybe (QualIdent l)
forall a. a -> Maybe a
Just (QualIdent l -> Maybe (QualIdent l))
-> QualIdent l -> Maybe (QualIdent l)
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"),
    (Text
"MIN", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
True (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
            [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"c") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                       (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"SET"] (Maybe (QualIdent l) -> FormalParameters l l Placed Placed)
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall a b. (a -> b) -> a -> b
$
            QualIdent l -> Maybe (QualIdent l)
forall a. a -> Maybe a
Just (QualIdent l -> Maybe (QualIdent l))
-> QualIdent l -> Maybe (QualIdent l)
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"),
    (Text
"ODD", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
            [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                       (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"CHAR"] (Maybe (QualIdent l) -> FormalParameters l l Placed Placed)
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall a b. (a -> b) -> a -> b
$
            QualIdent l -> Maybe (QualIdent l)
forall a. a -> Maybe a
Just (QualIdent l -> Maybe (QualIdent l))
-> QualIdent l -> Maybe (QualIdent l)
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"BOOLEAN"),
    (Text
"SIZE", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
True (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
             [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                        (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"CHAR"] (Maybe (QualIdent l) -> FormalParameters l l Placed Placed)
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall a b. (a -> b) -> a -> b
$
             QualIdent l -> Maybe (QualIdent l)
forall a. a -> Maybe a
Just (QualIdent l -> Maybe (QualIdent l))
-> QualIdent l -> Maybe (QualIdent l)
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"),
    (Text
"ORD", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
            [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                       (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"CHAR"] (Maybe (QualIdent l) -> FormalParameters l l Placed Placed)
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall a b. (a -> b) -> a -> b
$
            QualIdent l -> Maybe (QualIdent l)
forall a. a -> Maybe a
Just (QualIdent l -> Maybe (QualIdent l))
-> QualIdent l -> Maybe (QualIdent l)
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"),
    (Text
"CHR", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
            [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                       (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"] (Maybe (QualIdent l) -> FormalParameters l l Placed Placed)
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall a b. (a -> b) -> a -> b
$
            QualIdent l -> Maybe (QualIdent l)
forall a. a -> Maybe a
Just (QualIdent l -> Maybe (QualIdent l))
-> QualIdent l -> Maybe (QualIdent l)
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"CHAR"),
    (Text
"SHORT", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
              [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                         (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"] (Maybe (QualIdent l) -> FormalParameters l l Placed Placed)
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall a b. (a -> b) -> a -> b
$
              QualIdent l -> Maybe (QualIdent l)
forall a. a -> Maybe a
Just (QualIdent l -> Maybe (QualIdent l))
-> QualIdent l -> Maybe (QualIdent l)
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"),
    (Text
"LONG", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
             [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                        (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"] (Maybe (QualIdent l) -> FormalParameters l l Placed Placed)
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall a b. (a -> b) -> a -> b
$
             QualIdent l -> Maybe (QualIdent l)
forall a. a -> Maybe a
Just (QualIdent l -> Maybe (QualIdent l))
-> QualIdent l -> Maybe (QualIdent l)
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"),
    (Text
"ENTIER", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
               [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                          (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"REAL"] (Maybe (QualIdent l) -> FormalParameters l l Placed Placed)
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall a b. (a -> b) -> a -> b
$
               QualIdent l -> Maybe (QualIdent l)
forall a. a -> Maybe a
Just (QualIdent l -> Maybe (QualIdent l))
-> QualIdent l -> Maybe (QualIdent l)
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"),
    (Text
"INC", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
            [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                       (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"] Maybe (QualIdent l)
forall a. Maybe a
Nothing),
    (Text
"DEC", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
            [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                       (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"] Maybe (QualIdent l)
forall a. Maybe a
Nothing),
    (Text
"INCL", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
             [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"s") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                        (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"SET",
                               FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                               (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"] Maybe (QualIdent l)
forall a. Maybe a
Nothing),
    (Text
"EXCL", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
             [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"s") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                        (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"SET",
                               FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                               (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"] Maybe (QualIdent l)
forall a. Maybe a
Nothing),
    (Text
"COPY", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
             [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"s") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                        (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"ARRAY",
                               FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                               (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"ARRAY"] Maybe (QualIdent l)
forall a. Maybe a
Nothing),
    (Text
"NEW", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
            [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                       (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"POINTER"] Maybe (QualIdent l)
forall a. Maybe a
Nothing),
    (Text
"HALT", Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$
             [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (QualIdent l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap
                                        (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ QualIdent l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (QualIdent l -> Type l l Placed Placed)
-> QualIdent l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> QualIdent l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"INTEGER"] Maybe (QualIdent l)
forall a. Maybe a
Nothing)]

-- | The set of 'Predefined' types and procedures defined in the Oberon-2 Language Report.
predefined2 :: Predefined l
predefined2 = Predefined l
forall l. Oberon l => Predefined l
predefined Predefined l -> Predefined l -> Predefined l
forall a. Semigroup a => a -> a -> a
<>
   (DeclarationRHS l Placed Placed
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall e a. a -> Validation e a
Success (DeclarationRHS l Placed Placed
 -> Validation
      (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Map Text (DeclarationRHS l Placed Placed) -> Predefined l
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Text, DeclarationRHS l Placed Placed)]
-> Map Text (DeclarationRHS l Placed Placed)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
    [(Text
"ASSERT",
      Bool
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall l (f' :: * -> *) (f :: * -> *).
Bool
-> Maybe (f (FormalParameters l l f' f')) -> DeclarationRHS l f' f
DeclaredProcedure Bool
False (Maybe
   ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> DeclarationRHS l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> DeclarationRHS l Placed Placed
forall a b. (a -> b) -> a -> b
$ ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a. a -> Maybe a
Just (((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
 -> Maybe
      ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
-> Maybe
     ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FormalParameters l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed))
-> FormalParameters l l Placed Placed
-> ((Int, ParsedLexemes, Int), FormalParameters l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ [((Int, ParsedLexemes, Int), FPSection l l Placed Placed)]
-> Maybe (ReturnType l) -> FormalParameters l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
[f (FPSection l' l' f' f')]
-> Maybe (ReturnType l') -> FormalParameters l l' f' f
Abstract.formalParameters
       [FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"s") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ ReturnType l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (ReturnType l -> Type l l Placed Placed)
-> ReturnType l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> ReturnType l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"ARRAY",
        FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (FPSection l l Placed Placed
 -> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed))
-> FPSection l l Placed Placed
-> ((Int, ParsedLexemes, Int), FPSection l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ Bool
-> [Text]
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall l (f :: * -> *) l' (f' :: * -> *).
Wirthy l =>
Bool -> [Text] -> f (Type l' l' f' f') -> FPSection l l' f' f
Abstract.fpSection Bool
False (Text -> [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
"n") (((Int, ParsedLexemes, Int), Type l l Placed Placed)
 -> FPSection l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
-> FPSection l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall b. b -> ((Int, ParsedLexemes, Int), b)
wrap (Type l l Placed Placed
 -> ((Int, ParsedLexemes, Int), Type l l Placed Placed))
-> Type l l Placed Placed
-> ((Int, ParsedLexemes, Int), Type l l Placed Placed)
forall a b. (a -> b) -> a -> b
$ ReturnType l -> Type l l Placed Placed
forall l l' (f' :: * -> *) (f :: * -> *).
Wirthy l =>
QualIdent l' -> Type l l' f' f
Abstract.typeReference (ReturnType l -> Type l l Placed Placed)
-> ReturnType l -> Type l l Placed Placed
forall a b. (a -> b) -> a -> b
$ Text -> ReturnType l
forall l. Wirthy l => Text -> QualIdent l
Abstract.nonQualIdent Text
"ARRAY"]
      Maybe (ReturnType l)
forall a. Maybe a
Nothing)])

wrap :: b -> ((Int, ParsedLexemes, Int), b)
wrap = (,) (Int
0, [Lexeme] -> ParsedLexemes
Trailing [], Int
0)

exportsOfModule :: (BindableDeclaration l, CoFormalParameters l) => Module l l Placed Placed -> Scope l
exportsOfModule :: Module l l Placed Placed -> Scope l
exportsOfModule = (DeclarationRHS l Placed Placed
 -> Validation
      (NonEmpty (Error l)) (DeclarationRHS l Placed Placed))
-> Map Text (DeclarationRHS l Placed Placed) -> Scope l
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap DeclarationRHS l Placed Placed
-> Validation (NonEmpty (Error l)) (DeclarationRHS l Placed Placed)
forall e a. a -> Validation e a
Success (Map Text (DeclarationRHS l Placed Placed) -> Scope l)
-> (Module l l Placed Placed
    -> Map Text (DeclarationRHS l Placed Placed))
-> Module l l Placed Placed
-> Scope l
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((AccessMode, DeclarationRHS l Placed Placed)
 -> Maybe (DeclarationRHS l Placed Placed))
-> Map Text (AccessMode, DeclarationRHS l Placed Placed)
-> Map Text (DeclarationRHS l Placed Placed)
forall a b k. (a -> Maybe b) -> Map k a -> Map k b
Map.mapMaybe (AccessMode, DeclarationRHS l Placed Placed)
-> Maybe (DeclarationRHS l Placed Placed)
forall a. (AccessMode, a) -> Maybe a
isExported (Map Text (AccessMode, DeclarationRHS l Placed Placed)
 -> Map Text (DeclarationRHS l Placed Placed))
-> (Module l l Placed Placed
    -> Map Text (AccessMode, DeclarationRHS l Placed Placed))
-> Module l l Placed Placed
-> Map Text (DeclarationRHS l Placed Placed)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Module l l Placed Placed
-> Map Text (AccessMode, DeclarationRHS l Placed Placed)
forall l.
(BindableDeclaration l, CoFormalParameters l) =>
Module l l Placed Placed
-> Map Text (AccessMode, DeclarationRHS l Placed Placed)
globalsOfModule
   where isExported :: (AccessMode, a) -> Maybe a
isExported (AccessMode
PrivateOnly, a
_) = Maybe a
forall a. Maybe a
Nothing
         isExported (AccessMode
_, a
binding) = a -> Maybe a
forall a. a -> Maybe a
Just a
binding

globalsOfModule :: forall l. (BindableDeclaration l, CoFormalParameters l) =>
                   Module l l Placed Placed -> Map Ident (AccessMode, DeclarationRHS l Placed Placed)
globalsOfModule :: Module l l Placed Placed
-> Map Text (AccessMode, DeclarationRHS l Placed Placed)
globalsOfModule (Module Text
name [Import l]
imports ((Int, ParsedLexemes, Int)
_, Block l l Placed Placed
body)) =
   [(Text, (AccessMode, DeclarationRHS l Placed Placed))]
-> Map Text (AccessMode, DeclarationRHS l Placed Placed)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ((((Int, ParsedLexemes, Int), Declaration l l Placed Placed)
 -> [(Text, (AccessMode, DeclarationRHS l Placed Placed))])
-> [((Int, ParsedLexemes, Int), Declaration l l Placed Placed)]
-> [(Text, (AccessMode, DeclarationRHS l Placed Placed))]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Text
-> Declaration l l Placed Placed
-> [(Text, (AccessMode, DeclarationRHS l Placed Placed))]
forall l (f :: * -> *).
(BindableDeclaration l, Foldable f) =>
Text
-> Declaration l l f f
-> [(Text, (AccessMode, DeclarationRHS l f f))]
declarationBinding Text
name (Declaration l l Placed Placed
 -> [(Text, (AccessMode, DeclarationRHS l Placed Placed))])
-> (((Int, ParsedLexemes, Int), Declaration l l Placed Placed)
    -> Declaration l l Placed Placed)
-> ((Int, ParsedLexemes, Int), Declaration l l Placed Placed)
-> [(Text, (AccessMode, DeclarationRHS l Placed Placed))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Int, ParsedLexemes, Int), Declaration l l Placed Placed)
-> Declaration l l Placed Placed
forall a b. (a, b) -> b
snd) (Block l l Placed Placed
-> [((Int, ParsedLexemes, Int), Declaration l l Placed Placed)]
forall l (f' :: * -> *) (f :: * -> *).
CoFormalParameters l =>
Block l l f' f -> [f (Declaration l l f' f')]
getLocalDeclarations Block l l Placed Placed
body))

unique :: (NonEmpty (Error l) -> Error l) -> ([a] -> Error l) -> NodeWrap (Validation (NonEmpty (Error l)) a)
       -> Validation (NonEmpty (Error l)) (Placed a)
unique :: (NonEmpty (Error l) -> Error l)
-> ([a] -> Error l)
-> NodeWrap (Validation (NonEmpty (Error l)) a)
-> Validation (NonEmpty (Error l)) (Placed a)
unique NonEmpty (Error l) -> Error l
_ [a] -> Error l
_ (Compose ((Int
start, Int
end), Compose (Ambiguous ((ParsedLexemes, Validation (NonEmpty (Error l)) a)
x :| [])))) = (ParsedLexemes -> (Int, ParsedLexemes, Int))
-> (ParsedLexemes, a) -> Placed a
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first ((ParsedLexemes -> Int -> (Int, ParsedLexemes, Int))
-> Int -> ParsedLexemes -> (Int, ParsedLexemes, Int)
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((,,) Int
start) Int
end) ((ParsedLexemes, a) -> Placed a)
-> Validation (NonEmpty (Error l)) (ParsedLexemes, a)
-> Validation (NonEmpty (Error l)) (Placed a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((ParsedLexemes, Validation (NonEmpty (Error l)) a)
-> Validation (NonEmpty (Error l)) (ParsedLexemes, a)
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA (ParsedLexemes, Validation (NonEmpty (Error l)) a)
x)
unique NonEmpty (Error l) -> Error l
inv [a] -> Error l
amb (Compose ((Int
start, Int
end), Compose (Ambiguous NonEmpty (ParsedLexemes, Validation (NonEmpty (Error l)) a)
xs))) =
   case [Either (NonEmpty (Error l)) (ParsedLexemes, a)]
-> ([NonEmpty (Error l)], [(ParsedLexemes, a)])
forall a b. [Either a b] -> ([a], [b])
partitionEithers ((Validation (NonEmpty (Error l)) a
 -> Either (NonEmpty (Error l)) a)
-> (ParsedLexemes, Validation (NonEmpty (Error l)) a)
-> Either (NonEmpty (Error l)) (ParsedLexemes, a)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Validation (NonEmpty (Error l)) a -> Either (NonEmpty (Error l)) a
forall e a. Validation e a -> Either e a
validationToEither ((ParsedLexemes, Validation (NonEmpty (Error l)) a)
 -> Either (NonEmpty (Error l)) (ParsedLexemes, a))
-> [(ParsedLexemes, Validation (NonEmpty (Error l)) a)]
-> [Either (NonEmpty (Error l)) (ParsedLexemes, a)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmpty (ParsedLexemes, Validation (NonEmpty (Error l)) a)
-> [(ParsedLexemes, Validation (NonEmpty (Error l)) a)]
forall a. NonEmpty a -> [a]
NonEmpty.toList NonEmpty (ParsedLexemes, Validation (NonEmpty (Error l)) a)
xs)
   of ([NonEmpty (Error l)]
_, [(ParsedLexemes
ws, a
x)]) -> Placed a -> Validation (NonEmpty (Error l)) (Placed a)
forall e a. a -> Validation e a
Success ((Int
start, ParsedLexemes
ws, Int
end), a
x)
      ([NonEmpty (Error l)]
errors, []) -> NonEmpty (Error l) -> Validation (NonEmpty (Error l)) (Placed a)
forall e a. e -> Validation e a
Failure (NonEmpty (Error l) -> Error l
inv (NonEmpty (NonEmpty (Error l)) -> NonEmpty (Error l)
forall a. Semigroup a => NonEmpty a -> a
sconcat (NonEmpty (NonEmpty (Error l)) -> NonEmpty (Error l))
-> NonEmpty (NonEmpty (Error l)) -> NonEmpty (Error l)
forall a b. (a -> b) -> a -> b
$ [NonEmpty (Error l)] -> NonEmpty (NonEmpty (Error l))
forall a. [a] -> NonEmpty a
NonEmpty.fromList [NonEmpty (Error l)]
errors) Error l -> [Error l] -> NonEmpty (Error l)
forall a. a -> [a] -> NonEmpty a
:| [])
      ([NonEmpty (Error l)]
_, [(ParsedLexemes, a)]
multi) -> NonEmpty (Error l) -> Validation (NonEmpty (Error l)) (Placed a)
forall e a. e -> Validation e a
Failure ([a] -> Error l
amb ((ParsedLexemes, a) -> a
forall a b. (a, b) -> b
snd ((ParsedLexemes, a) -> a) -> [(ParsedLexemes, a)] -> [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(ParsedLexemes, a)]
multi) Error l -> [Error l] -> NonEmpty (Error l)
forall a. a -> [a] -> NonEmpty a
:| [])

$(Rank2.TH.deriveFunctor ''DeclarationRHS)
$(Rank2.TH.deriveFoldable ''DeclarationRHS)
$(Rank2.TH.deriveTraversable ''DeclarationRHS)
$(Transformation.Deep.TH.deriveTraversable ''DeclarationRHS)

$(do l <- varT <$> newName "l"
     mconcat <$> mapM (\t-> Transformation.Full.TH.deriveDownTraversable (conT ''Resolution `appT` l)
                            $ conT t `appT` l `appT` l)
        [''Module, ''Declaration, ''Type, ''FieldList,
         ''ProcedureHeading, ''FormalParameters, ''FPSection,
         ''Expression, ''Element, ''Designator,
         ''Block, ''StatementSequence, ''Statement,
         ''Case, ''CaseLabels, ''ConditionalBranch, ''Value, ''WithAlternative])