syntactic-0.6: Generic abstract syntax, and utilities for embedded languages

Language.Syntactic.Features.Annotate

Description

Annotations for syntax trees

Synopsis

Documentation

data Ann info expr a whereSource

Annotating an expression with arbitrary information.

This can be used to annotate every node of a syntax tree, which is done by changing

 AST dom a

to

 AST (Ann info dom) a

Injection/projection of an annotated tree is done using injectAnn / projectAnn.

Constructors

Ann :: info (EvalResult a) -> expr a -> Ann info expr a 

Fields

annInfo :: info (EvalResult a)
 
annExpr :: expr a
 

Instances

ExprEq expr => ExprEq (Ann info expr) 
ToTree expr => ToTree (Ann info expr) 
Render expr => Render (Ann info expr) 
Eval expr => Eval (Ann info expr) 

type AnnSTF info dom a = ASTF (Ann info dom) aSource

injectAnn :: (sub :<: sup, ConsType a) => info (EvalResult a) -> sub a -> AST (Ann info sup) aSource

projectAnn :: sub :<: sup => AST (Ann info sup) a -> Maybe (info (EvalResult a), sub a)Source

getInfo :: AST (Ann info dom) a -> info (EvalResult a)Source

Get the annotation of the top-level node

collectInfo :: (forall a. info a -> b) -> AST (Ann info dom) a -> [b]Source

Collect the annotations of all nodes

toTreeAnn :: forall info dom a. (Render info, ToTree dom) => ASTF (Ann info dom) a -> Tree StringSource

Rendering of annotated syntax trees

showANN :: (Render info, ToTree dom) => ASTF (Ann info dom) a -> StringSource

Show an annotated syntax tree using ASCII art

drawANN :: (Render info, ToTree dom) => ASTF (Ann info dom) a -> IO ()Source

Print an annotated syntax tree using ASCII art