Copyright | Copyright 2017 Awake Security |
---|---|
License | Apache-2.0 |
Maintainer | opensource@awakesecurity.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
The Ninja build language after parsing.
This module re-exports all of the modules under the Language.Ninja.AST namespace for convenience.
It is recommended that you import it with the following style:
import qualified Language.Ninja.AST as AST
Since: 0.1.0
- data Ninja ann
- makeNinja :: Monoid ann => Ninja ann
- ninjaRules :: Lens' (Ninja ann) (HashMap Text (Rule ann))
- ninjaSingles :: Lens' (Ninja ann) (HashMap Text (Build ann))
- ninjaMultiples :: Lens' (Ninja ann) (HashMap Outputs (Build ann))
- ninjaPhonys :: Lens' (Ninja ann) (HashMap Text (HashSet Text))
- ninjaDefaults :: Lens' (Ninja ann) (HashSet Text)
- ninjaPools :: Lens' (Ninja ann) (HashMap Text Int)
- ninjaSpecials :: Lens' (Ninja ann) (HashMap Text Text)
- data Build ann
- makeBuild :: Monoid ann => Text -> Env Text Text -> Build ann
- buildRule :: Lens' (Build ann) Text
- buildEnv :: Lens' (Build ann) (Env Text Text)
- buildDeps :: Lens' (Build ann) (Deps ann)
- buildBind :: Lens' (Build ann) (HashMap Text Text)
- data Deps ann
- makeDeps :: Monoid ann => Deps ann
- depsNormal :: Lens' (Deps ann) (HashSet Text)
- depsImplicit :: Lens' (Deps ann) (HashSet Text)
- depsOrderOnly :: Lens' (Deps ann) (HashSet Text)
- data Rule ann
- makeRule :: Monoid ann => Rule ann
- ruleBind :: Lens' (Rule ann) (HashMap Text (Expr ann))
- data Expr ann
- _Exprs :: Prism' (Expr ann) (ann, [Expr ann])
- _Lit :: Prism' (Expr ann) (ann, Text)
- _Var :: Prism' (Expr ann) (ann, Text)
- askVar :: Env Text Text -> Text -> Text
- askExpr :: Env Text Text -> Expr ann -> Text
- addBind :: Text -> Expr ann -> Env Text Text -> Env Text Text
- addBinds :: [(Text, Expr ann)] -> Env Text Text -> Env Text Text
- normalizeExpr :: forall ann. Monoid ann => Expr ann -> Expr ann
- data Env k v
- makeEnv :: Env k v
- fromEnv :: Iso' (Env k v) (Maps k v)
- addEnv :: Key k => k -> v -> Env k v -> Env k v
- askEnv :: Key k => Env k v -> k -> Maybe v
- scopeEnv :: Env k v -> Env k v
Language.Ninja.AST.Ninja
A parsed Ninja file.
Since: 0.1.0
Functor Ninja Source # | |
Foldable Ninja Source # | |
Traversable Ninja Source # | |
Annotated Ninja Source # | The usual definition for Since: 0.1.0 |
(Monad m, NinjaConstraint (Serial m) ann) => Serial m (Ninja ann) Source # | Default Since: 0.1.0 |
(Monad m, NinjaConstraint (CoSerial m) ann) => CoSerial m (Ninja ann) Source # | Default Since: 0.1.0 |
Eq ann => Eq (Ninja ann) Source # | |
Show ann => Show (Ninja ann) Source # | |
Generic (Ninja ann) Source # | |
Arbitrary ann => Arbitrary (Ninja ann) Source # | Reasonable Since: 0.1.0 |
Hashable ann => Hashable (Ninja ann) Source # | Default Since: 0.1.0 |
ToJSON ann => ToJSON (Ninja ann) Source # | Converts to
Since: 0.1.0 |
FromJSON ann => FromJSON (Ninja ann) Source # | Inverse of the Since: 0.1.0 |
NFData ann => NFData (Ninja ann) Source # | Default Since: 0.1.0 |
type Rep (Ninja ann) Source # | |
ninjaRules :: Lens' (Ninja ann) (HashMap Text (Rule ann)) Source #
The rules defined in a parsed Ninja file.
Since: 0.1.0
ninjaSingles :: Lens' (Ninja ann) (HashMap Text (Build ann)) Source #
The set of build
declarations with precisely one output.
Since: 0.1.0
ninjaMultiples :: Lens' (Ninja ann) (HashMap Outputs (Build ann)) Source #
The set of build
declarations with two or more outputs.
Since: 0.1.0
ninjaPhonys :: Lens' (Ninja ann) (HashMap Text (HashSet Text)) Source #
The set of phony build
declarations.
Since: 0.1.0
ninjaPools :: Lens' (Ninja ann) (HashMap Text Int) Source #
A mapping from pool names to pool depth integers.
Since: 0.1.0
ninjaSpecials :: Lens' (Ninja ann) (HashMap Text Text) Source #
A map from "special" top-level variables to their values.
Since: 0.1.0
Language.Ninja.AST.Build
A parsed Ninja build
declaration.
Since: 0.1.0
Functor Build Source # | |
Foldable Build Source # | |
Traversable Build Source # | |
Annotated Build Source # | The usual definition for Since: 0.1.0 |
(Monad m, BuildConstraint (Serial m) ann) => Serial m (Build ann) Source # | Default Since: 0.1.0 |
(Monad m, BuildConstraint (CoSerial m) ann) => CoSerial m (Build ann) Source # | Default Since: 0.1.0 |
Eq ann => Eq (Build ann) Source # | |
Show ann => Show (Build ann) Source # | |
Generic (Build ann) Source # | |
Arbitrary ann => Arbitrary (Build ann) Source # | Reasonable Since: 0.1.0 |
Hashable ann => Hashable (Build ann) Source # | Default Since: 0.1.0 |
ToJSON ann => ToJSON (Build ann) Source # | Converts to Since: 0.1.0 |
FromJSON ann => FromJSON (Build ann) Source # | Inverse of the Since: 0.1.0 |
NFData ann => NFData (Build ann) Source # | Default Since: 0.1.0 |
type Rep (Build ann) Source # | |
Construct a Build
with all default values.
Since: 0.1.0
buildRule :: Lens' (Build ann) Text Source #
A lens into the rule name associated with a Build
.
Since: 0.1.0
buildEnv :: Lens' (Build ann) (Env Text Text) Source #
A lens into the environment associated with a Build
.
Since: 0.1.0
buildDeps :: Lens' (Build ann) (Deps ann) Source #
A lens into the dependencies associated with a Build
.
Since: 0.1.0
buildBind :: Lens' (Build ann) (HashMap Text Text) Source #
A lens into the bindings associated with a Build
.
Since: 0.1.0
Language.Ninja.AST.Deps
A set of Ninja build dependencies.
Since: 0.1.0
Functor Deps Source # | |
Foldable Deps Source # | |
Traversable Deps Source # | |
Annotated Deps Source # | The usual definition for Since: 0.1.0 |
(Monad m, DepsConstraint (Serial m) ann) => Serial m (Deps ann) Source # | Default Since: 0.1.0 |
(Monad m, DepsConstraint (CoSerial m) ann) => CoSerial m (Deps ann) Source # | Default Since: 0.1.0 |
Eq ann => Eq (Deps ann) Source # | |
Show ann => Show (Deps ann) Source # | |
Generic (Deps ann) Source # | |
Arbitrary ann => Arbitrary (Deps ann) Source # | Reasonable Since: 0.1.0 |
Hashable ann => Hashable (Deps ann) Source # | Default Since: 0.1.0 |
ToJSON ann => ToJSON (Deps ann) Source # | Converts to Since: 0.1.0 |
FromJSON ann => FromJSON (Deps ann) Source # | Inverse of the Since: 0.1.0 |
NFData ann => NFData (Deps ann) Source # | Default Since: 0.1.0 |
type Rep (Deps ann) Source # | |
depsNormal :: Lens' (Deps ann) (HashSet Text) Source #
A lens into the set of normal dependencies in a Deps
.
Since: 0.1.0
depsImplicit :: Lens' (Deps ann) (HashSet Text) Source #
A lens into the set of implicit dependencies in a Deps
.
Since: 0.1.0
depsOrderOnly :: Lens' (Deps ann) (HashSet Text) Source #
A lens into the set of order-only dependencies in a Deps
.
Since: 0.1.0
Language.Ninja.AST.Rule
A parsed Ninja rule
declaration.
Since: 0.1.0
Functor Rule Source # | |
Foldable Rule Source # | |
Traversable Rule Source # | |
Annotated Rule Source # | The usual definition for Since: 0.1.0 |
(Monad m, RuleConstraint (Serial m) ann) => Serial m (Rule ann) Source # | Default Since: 0.1.0 |
(Monad m, RuleConstraint (CoSerial m) ann) => CoSerial m (Rule ann) Source # | Default Since: 0.1.0 |
Eq ann => Eq (Rule ann) Source # | |
Show ann => Show (Rule ann) Source # | |
Generic (Rule ann) Source # | |
Arbitrary ann => Arbitrary (Rule ann) Source # | Reasonable Since: 0.1.0 |
Hashable ann => Hashable (Rule ann) Source # | Default Since: 0.1.0 |
ToJSON ann => ToJSON (Rule ann) Source # | Converts to Since: 0.1.0 |
FromJSON ann => FromJSON (Rule ann) Source # | Inverse of the Since: 0.1.0 |
NFData ann => NFData (Rule ann) Source # | Default Since: 0.1.0 |
type Rep (Rule ann) Source # | |
ruleBind :: Lens' (Rule ann) (HashMap Text (Expr ann)) Source #
The set of bindings in scope during the execution of this rule.
Since: 0.1.0
Language.Ninja.AST.Expr
An expression containing variable references in the Ninja language.
Since: 0.1.0
Exprs !ann ![Expr ann] | Sequencing of expressions. Since: 0.1.0 |
Lit !ann !Text | A literal string. Since: 0.1.0 |
Var !ann !Text | A variable reference. Since: 0.1.0 |
Functor Expr Source # | |
Foldable Expr Source # | |
Traversable Expr Source # | |
Annotated Expr Source # | The usual definition for Since: 0.1.0 |
(Monad m, ExprConstraint (Serial m) ann) => Serial m (Expr ann) Source # | Default Since: 0.1.0 |
(Monad m, ExprConstraint (CoSerial m) ann) => CoSerial m (Expr ann) Source # | Default Since: 0.1.0 |
Eq ann => Eq (Expr ann) Source # | |
Data ann => Data (Expr ann) Source # | |
Show ann => Show (Expr ann) Source # | |
Generic (Expr ann) Source # | |
Arbitrary ann => Arbitrary (Expr ann) Source # | Reasonable Since: 0.1.0 |
Hashable ann => Hashable (Expr ann) Source # | Default Since: 0.1.0 |
ToJSON ann => ToJSON (Expr ann) Source # | Converts Since: 0.1.0 |
FromJSON ann => FromJSON (Expr ann) Source # | Inverse of the Since: 0.1.0 |
NFData ann => NFData (Expr ann) Source # | Default Since: 0.1.0 |
Data ann => Plated (Expr ann) Source # | The usual definition for Since: 0.1.0 |
type Rep (Expr ann) Source # | |
_Exprs :: Prism' (Expr ann) (ann, [Expr ann]) Source #
A prism for the Exprs
constructor.
Since: 0.1.0
askVar :: Env Text Text -> Text -> Text Source #
Look up the given variable in the given context, returning the empty string if the variable was not found.
Since: 0.1.0
addBinds :: [(Text, Expr ann)] -> Env Text Text -> Env Text Text Source #
Add bindings from a list. Note that this function evaluates all the right-hand-sides first, and then adds them all to the environment.
For example:
>>>
:set -XOverloadedStrings
>>>
let binds = [("x", Lit () "5"), ("y", Var () "x")]
>>>
AST.headEnv (addBinds binds AST.makeEnv)
fromList [("x","5"),("y","")]
Since: 0.1.0
normalizeExpr :: forall ann. Monoid ann => Expr ann -> Expr ann Source #
Normalize an Expr
by recursively flattening any Exprs
nodes, removing
empty Lit
nodes, combining adjacent Lit
nodes, and pulling out the
interior of the top-level Exprs
node if it has only one subnode.
The number of Exprs
nodes in the output is guaranteed to be 0 or 1.
If it is 0, then there is exactly one node of any type in the output.
The output is thus isomorphic to (Maybe ann, [(ann, Either Text Text)])
,
where the Maybe ann
represents the annotation of the top-level Exprs
node if it exists.
Since: 0.1.0
Language.Ninja.AST.Env
A Ninja-style environment, basically a nonempty list of hash tables.
Since: 0.1.0
(Monad m, EnvConstraint (Serial m) k v) => Serial m (Env k v) Source # | Uses the underlying Since: 0.1.0 |
(Monad m, EnvConstraint (CoSerial m) k v) => CoSerial m (Env k v) Source # | Uses the underlying Since: 0.1.0 |
(Eq v, Eq k) => Eq (Env k v) Source # | |
(Show v, Show k) => Show (Env k v) Source # | |
Generic (Env k v) Source # | |
(Key k, Arbitrary k, Arbitrary v) => Arbitrary (Env k v) Source # | Reasonable Since: 0.1.0 |
(Hashable k, Hashable v) => Hashable (Env k v) Source # | Default Since: 0.1.0 |
(ToJSONKey k, ToJSON v) => ToJSON (Env k v) Source # | Converts to a (nonempty) array of JSON objects. Since: 0.1.0 |
(Key k, FromJSONKey k, FromJSON v) => FromJSON (Env k v) Source # | Inverse of the Since: 0.1.0 |
(NFData k, NFData v) => NFData (Env k v) Source # | Default Since: 0.1.0 |
type Rep (Env k v) Source # | |
addEnv :: Key k => k -> v -> Env k v -> Env k v Source #
Add the given key and value to the given Env
.
Since: 0.1.0