technique-0.2.5: Procedures and Sequences
Safe HaskellNone
LanguageHaskell2010

Technique.Translate

Description

Given a Technique Procedure (concrete syntax tree), translate it into an internalized representation (abstract syntax tree) that can be subsequently executed (that is, interpreted; evaluated).

Synopsis

Documentation

data Environment Source #

Environment in the type-theory sense of the word: the map(s) between names and their bindings.

Instances

Instances details
Eq Environment Source # 
Instance details

Defined in Technique.Translate

Show Environment Source # 
Instance details

Defined in Technique.Translate

MonadState Environment Translate Source # 
Instance details

Defined in Technique.Translate

newtype Translate a Source #

Instances

Instances details
Monad Translate Source # 
Instance details

Defined in Technique.Translate

Methods

(>>=) :: Translate a -> (a -> Translate b) -> Translate b #

(>>) :: Translate a -> Translate b -> Translate b #

return :: a -> Translate a #

Functor Translate Source # 
Instance details

Defined in Technique.Translate

Methods

fmap :: (a -> b) -> Translate a -> Translate b #

(<$) :: a -> Translate b -> Translate a #

Applicative Translate Source # 
Instance details

Defined in Technique.Translate

Methods

pure :: a -> Translate a #

(<*>) :: Translate (a -> b) -> Translate a -> Translate b #

liftA2 :: (a -> b -> c) -> Translate a -> Translate b -> Translate c #

(*>) :: Translate a -> Translate b -> Translate b #

(<*) :: Translate a -> Translate b -> Translate a #

MonadState Environment Translate Source # 
Instance details

Defined in Technique.Translate

MonadError CompilationError Translate Source # 
Instance details

Defined in Technique.Translate

runTranslate :: Environment -> Translate a -> Either CompilationError (a, Environment) Source #

Take a translator action and an environment and spin it up into a Step or nest of Steps (Subroutine) suitable for interpretation. In other words, translate between the concrete syntax types and the abstract syntax we can feed to an evaluator.

translateBlock :: Block -> Translate Step Source #

Blocks are scoping mechanisms, so accumulated environment is discarded once we finish resolving names within it.

translateExpression :: Expression -> Translate Step Source #

Note that this does NOT add the steps to the Environment.

registerProcedure :: Offset -> Function -> Translate () Source #

A given procedure call can either be to a user declared in-scope procedure or to a primative builtin. We have Invocation as the Step constructors for these cases.

insertVariable :: Offset -> Identifier -> Translate Name Source #

Identifiers are valid names but Names are unique, so that we can put them into the environment map. This is where we check for reuse of an already declared name (TODO) and given the local use of the identifier a scope-local (or globally?) unique name.

appendStep :: Step -> Translate () Source #

Accumulate a Step.

applyRestriction :: Attribute -> Block -> Translate Step Source #

This begins a new (more refined) scope and does *not* add its declarations or variables to the current environment.

resolveFunctions :: Step -> Translate Step Source #

The second stage of translation phase: iterate through the Steps and where a function call is made, look up to see if we actually know what it is.

setLocationFrom :: Located a => a -> Translate () Source #

Update the environment's idea of where in the source we are, so that if we need to generate an error message we can offer one with position information.