Mercury library  1.0
Translation of CFG grammars into an object model (Bachelor's thesis).
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
Static Public Member Functions | Static Public Attributes | List of all members
Mercury.Interpreting.BasicActions< T > Class Template Reference

Contains basic actions for interpretation.

Type specifiers of actions are defined as follows:
More...

Static Public Member Functions

static IReadOnlyList
< InterpreterAction< T > > 
GetAllActions ()
 Provides basic Mercury actions More...
 
static IReadOnlyDictionary
< string, string > 
GetAliases ()
 Returns aliases for basic actions.

It contains the following aliases: More...
 
static InterpreterAction< T > CreateTracer (string name, TextWriter writer)
 Creates custom trace action with stream, useful for logging. More...
 

Static Public Attributes

static readonly
InterpreterAction< T > 
ParseInteger
 Converts a string representation of an integer.
ParseInteger :: String -> Integer More...
 
static readonly
InterpreterAction< T > 
ParseReal
 Converts a string representation of a decimal number.
ParseReal :: String -> Real More...
 
static readonly
InterpreterAction< T > 
ParseBoolean
 Converts a string representation of a boolean.
ParseBoolean :: String -> Boolean More...
 
static readonly
InterpreterAction< T > 
Round = new ConvertAction<T, double, int>("Round", x => Convert.ToInt32(Math.Round(x)))
 Rounds a real number.
Round :: Real -> Integer More...
 
static readonly
InterpreterAction< T > 
Ceiling = new ConvertAction<T, double, int>("Ceiling", x => Convert.ToInt32(Math.Ceiling(x)))
 Returns a ceiling of a real number.
Ceiling :: Real -> Integer More...
 
static readonly
InterpreterAction< T > 
Floor = new ConvertAction<T, double, int>("Floor", x => Convert.ToInt32(Math.Floor(x)))
 Returns a floor of a real number.
Floor :: Real -> Integer More...
 
static readonly
InterpreterAction< T > 
ToReal = new ConvertAction<T, int, double>("ToReal", x => Convert.ToDouble(x))
 Converts an integer value to decimal.
ToReal :: Integer -> Real More...
 
static readonly
InterpreterAction< T > 
String = new ConvertAction<T, object, string>("String", x => x.ToString())
 Call ToString() method on its argument.
String :: Any -> String More...
 
static readonly
InterpreterAction< T > 
Add = new ArithmeticAction<T>("Add", (x, y) => x + y)
 Sum of the arguments.
Add[a = Integer|Real] :: a -> a -> ... -> a More...
 
static readonly
InterpreterAction< T > 
Sub = new ArithmeticAction<T>("Sub", (x, y) => x - y)
 Subtracts the arguments.
Sub[a = Integer|Real] :: a -> a -> ... -> a More...
 
static readonly
InterpreterAction< T > 
Mul = new ArithmeticAction<T>("Mul", (x, y) => x * y)
 Multiplies the arguments.
Mul[a = Integer|Real] :: a -> a -> ... -> a More...
 
static readonly
InterpreterAction< T > 
Div = new ArithmeticAction<T>("Div", (x, y) => x / y)
 Divides the values.
Div[a = Integer|Real] :: a -> a -> ... -> a More...
 
static readonly
InterpreterAction< T > 
Pow = new ArithmeticAction<T>("Pow", (x, y) => Math.Pow(x, y))
 Exponentiates the values.
Pow[a = Integer|Real] :: a -> a -> ... -> a More...
 
static readonly
InterpreterAction< T > 
FDiv = new OperationAction<T, double, double>("FDiv", (x, y) => x / y)
 Floating point division.
FDiv :: Real -&gt Real -> Real More...
 
static readonly
InterpreterAction< T > 
Mod = new OperationAction<T, int, int>("Mod", (x, y) => x % y)
 Modulo.
Mod :: Integer -> Integer -> Integer More...
 
static readonly
InterpreterAction< T > 
IsNull = new ConvertAction<T, object, bool>("IsNull", x => x == null, ArgumentType.Null)
 Indicates whether the object is null.
IsNull :: Any -> Boolean More...
 
static readonly
InterpreterAction< T > 
And = new FoldingAction<T, bool, bool>("And", 2, (x, y) => x && y, true)
 Logical multiplication.
And :: Boolean -> Boolean -> ... -> Boolean More...
 
static readonly
InterpreterAction< T > 
Or = new FoldingAction<T, bool, bool>("Or", 2, (x, y) => x && y, false)
 Logical addition.
Or :: Boolean -> Boolean -> ... -> Boolean More...
 
static readonly
InterpreterAction< T > 
Not = new ConvertAction<T, bool, bool>("Not", x => !x)
 Logical negation.
Not :: Boolean -> Boolean More...
 
static readonly
InterpreterAction< T > 
Xor = new OperationAction<T, bool, bool>("Xor", (x, y) => x ^ y)
 Exclusive disjunction.
Xor :: Boolean -> Boolean -> Boolean More...
 
static readonly
InterpreterAction< T > 
Eq = new OperationAction<T, object, bool>("Eq", (x, y) => (x != null) && x.Equals(y), ArgumentType.Null)
 Indicates whether provided objects are equal. If any of arguments is null, the result is always false.
Eq :: Any -> Any -> Boolean More...
 
static readonly
InterpreterAction< T > 
Neq = new OperationAction<T, object, bool>("Neq", (x, y) => (x == null) || !x.Equals(y), ArgumentType.Null)
 Complement of Eq.
Neq :: Any -> Any -> Boolean More...
 
static readonly
InterpreterAction< T > 
Gr = new OperationAction<T, double, bool>("Gr", (x, y) => x > y)
 Comparison "Greater than".
Gr :: Real -> Real -> Boolean More...
 
static readonly
InterpreterAction< T > 
Ls = new OperationAction<T, double, bool>("Ls", (x, y) => x < y)
 Comparison "Less than".
Ls :: Real -> Real -> Boolean More...
 
static readonly
InterpreterAction< T > 
Geq = new OperationAction<T, double, bool>("Geq", (x, y) => x >= y)
 Comparison "Greater than or equal to".
Geq :: Real -> Real -> Boolean More...
 
static readonly
InterpreterAction< T > 
Leq = new OperationAction<T, double, bool>("Leq", (x, y) => x <= y)
 Comparison "Less than or equal to".
Leq :: Real -> Real -> Boolean More...
 
static readonly
InterpreterAction< T > 
Empty = new ConstantAction<T, string>("Empty", "")
 Returns an empty string.
Empty :: String More...
 
static readonly
InterpreterAction< T > 
Join = new JoinAction<T>()
 Converts all arguments to strings and joins them with a given separator.
Join :: String -> [Any...] -> String More...
 
static readonly
InterpreterAction< T > 
Concat = new ConcatAction<T>()
 Converts all arguments to strings and concatenates them.
Concat :: [Any...] -> String More...
 
static readonly
InterpreterAction< T > 
Flatten = new FlattenAction<T>()
 Converts a tree into its string representation. An optional argument specifies the depth.
Flatten :: Tree -> [Integer] -> String More...
 
static readonly
InterpreterAction< T > 
Name = new ConvertAction<T, Symbol, string>("Name", x => x.Name)
 Returns the name of the given symbol.
Name :: Symbol -> String More...
 
static readonly
InterpreterAction< T > 
Symbol = new ConvertAction<T, Tree<Symbol>, Symbol>("Symbol", x => x.Value)
 Returns the root symbol of the given tree.
Symbol :: Tree -> Symbol More...
 
static readonly
InterpreterAction< T > 
Depth = new ConvertAction<T, Tree<Symbol>, int>("Depth", x => x.Depth)
 Returns the depth of the given tree.
Depth :: Tree -> Integer More...
 
static readonly
InterpreterAction< T > 
Leaves = new ConvertAction<T, Tree<Symbol>, int>("Leaves", x => x.LeavesCount)
 Returns the count of leaves of the given tree.
Leaves :: Tree -> Integer More...
 
static readonly
InterpreterAction< T > 
SubTree = new SubTreeAction<T>()
 Returns a child of a given tree at index specified as the second parameter. If no such child exists, the action returns null.
SubTree :: Tree -> Integer -> Tree More...
 
static readonly
InterpreterAction< T > 
Preterminal
 Returns a string value of a preterminal rule (of the form A -&gt b where b is the terminal. If the tree was not generated by a preterminal rule, returns null.
Preterminal :: Tree -> String More...
 
static readonly
InterpreterAction< T > 
If = new IfAction<T>()
 Condition. The semantics of (if c0 a0 c1 a1 ... e) is if (c0) then a1; else if (c1) then a1; ... else e;. All values and conditions are evaluated lazily.
Moreover, types of a_ must be equal otherwise the type inference would fail.
If[a = Any] :: [Boolean,a...] -> a -> a More...
 
static readonly
InterpreterAction< T > 
Select = new SelectAction<T>()
 Selection. The semantics of (select i c0 c1 ... cn def) is if (0 <= i <= n) then ci; else def;. All values are evaluated lazily.
Moreover, types of c_ must be equal otherwise the type inference would fail.
Select[a = Any] :: Integer -> [a...] -> a -> a More...
 
static readonly
InterpreterAction< T > 
Case = new CaseAction<T>()
 Case. The semantics of (case x c0 v0 c1 v1 ... def) is
switch (x) { case c0: v0; break; case c1: v1; break; ... default: def; }.
Moreover, types of c_ and x must be equal, as well as types of v_.
Case[v = Any, e = Any] :: v -> [v,e...] -> e -> e More...
 
static readonly
InterpreterAction< T > 
Eval = new EvaluateAction<T>()
 Recursively evaluates the given tree.
Eval :: Tree -> TValue More...
 
static readonly
InterpreterAction< T > 
Simple = new SimpleAction<T>()
 Evaluates the subtree of a given tree provided that it is the only subtree; otherwise returns null.
Simple :: Tree -> TValue More...
 
static readonly
InterpreterAction< T > 
Fail = new FailAction<T>()
 Returns null.
Fail :: Any More...
 
static readonly
InterpreterAction< T > 
Try = new TryAction<T>()
 Try action. The semantics of (try e1 e2) is try { e1; } catch (Mercury.Exceptions.ErrorActionException) { e2; }.
If the second argument is not specified, it will behave like (try e1 (fail)). Moreover, the types of e1 and e2 must be equal.
Try[a = Any] :: a -> a -> a More...
 
static readonly
InterpreterAction< T > 
Error = new ConvertAction<T, string, object>("Error", x => { throw new ErrorActionException(x); })
 Throws an instance of Mercury.Exceptions.ErrorActionException with the specified text.
Error :: String -> Any More...
 
static readonly
InterpreterAction< T > 
Identity = new IdentityAction<T>()
 Returns the same value.
Identity[a = Any] :: a -> a More...
 
static readonly
InterpreterAction< T > 
Let = new LetAction<T>()
 Saves the value in the current context.
The semantics of (Let x v0 y v1 ... act) is let (x = v0; y = v1; ...) in (act);.
The return type is same as the type of act.
Let[a = Any] :: [String,Any...] -> a -> a More...
 
static readonly
InterpreterAction< T > 
Var = new VarAction<T>()
 Retrieves the value stored by Let, but only in the same context. The function also performs runtime type check; if the value stored does not exist or match the type required, it will throw an exception.
Var :: String -> Any More...
 
static readonly
InterpreterAction< T > 
ArgsCount = new ArgsCountAction<T>()
 Returns the number of arguments. Useful to determine number of values captured by a Mercury.Interpreting.Wildcard.
ArgsCount :: [Any...] -> Integer More...
 
static readonly
InterpreterAction< T > 
Trace = new TraceAction<T>()
 Logs an event to the entry tree.
Trace[a = Any] -> a -> String -> [Any...] -> a More...
 

Detailed Description

Contains basic actions for interpretation.

Type specifiers of actions are defined as follows:

Syntax of action types is as follows:

Note that if f :: a -> [b] -> [c] -> d, the third argument of type c cannot be specified without the second argument of type b.

Template Parameters
TInterpreter return type.
Type Constraints
T :class 

Definition at line 39 of file BasicActions.cs.

Member Function Documentation

static InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.CreateTracer ( string  name,
TextWriter  writer 
)
static

Creates custom trace action with stream, useful for logging.

Parameters
nameThe name of the action
writerThe output writer
Returns
The interpreter action

Definition at line 352 of file BasicActions.cs.

static IReadOnlyDictionary<string,string> Mercury.Interpreting.BasicActions< T >.GetAliases ( )
static

Returns aliases for basic actions.

It contains the following aliases:

    + Add      - Sub      * Mul     / Div
   // FDiv     % Mod     ** Pow 
    @ String  ++ Concat   # Var
    & And      | Or       ^ Xor     ! Not
   == Eq      /= Neq
    > Gt       < Lt      >= Geq     <= Leq
    $ Eval    id Identity

Definition at line 332 of file BasicActions.cs.

static IReadOnlyList<InterpreterAction<T> > Mercury.Interpreting.BasicActions< T >.GetAllActions ( )
static

Provides basic Mercury actions

Template Parameters
TOutput type parameter
Returns
List of actions

Definition at line 304 of file BasicActions.cs.

Member Data Documentation

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Add = new ArithmeticAction<T>("Add", (x, y) => x + y)
static

Sum of the arguments.
Add[a = Integer|Real] :: a -> a -> ... -> a

Definition at line 96 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.And = new FoldingAction<T, bool, bool>("And", 2, (x, y) => x && y, true)
static

Logical multiplication.
And :: Boolean -> Boolean -> ... -> Boolean

Definition at line 123 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.ArgsCount = new ArgsCountAction<T>()
static

Returns the number of arguments. Useful to determine number of values captured by a Mercury.Interpreting.Wildcard.
ArgsCount :: [Any...] -> Integer

Definition at line 296 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Case = new CaseAction<T>()
static

Case. The semantics of (case x c0 v0 c1 v1 ... def) is
switch (x) { case c0: v0; break; case c1: v1; break; ... default: def; }.
Moreover, types of c_ and x must be equal, as well as types of v_.
Case[v = Any, e = Any] :: v -> [v,e...] -> e -> e

Definition at line 238 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Ceiling = new ConvertAction<T, double, int>("Ceiling", x => Convert.ToInt32(Math.Ceiling(x)))
static

Returns a ceiling of a real number.
Ceiling :: Real -> Integer

Definition at line 81 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Concat = new ConcatAction<T>()
static

Converts all arguments to strings and concatenates them.
Concat :: [Any...] -> String

Definition at line 168 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Depth = new ConvertAction<T, Tree<Symbol>, int>("Depth", x => x.Depth)
static

Returns the depth of the given tree.
Depth :: Tree -> Integer

Definition at line 186 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Div = new ArithmeticAction<T>("Div", (x, y) => x / y)
static

Divides the values.
Div[a = Integer|Real] :: a -> a -> ... -> a

Definition at line 105 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Empty = new ConstantAction<T, string>("Empty", "")
static

Returns an empty string.
Empty :: String

Definition at line 159 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Eq = new OperationAction<T, object, bool>("Eq", (x, y) => (x != null) && x.Equals(y), ArgumentType.Null)
static

Indicates whether provided objects are equal. If any of arguments is null, the result is always false.
Eq :: Any -> Any -> Boolean

Definition at line 138 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Error = new ConvertAction<T, string, object>("Error", x => { throw new ErrorActionException(x); })
static

Throws an instance of Mercury.Exceptions.ErrorActionException with the specified text.
Error :: String -> Any

Definition at line 267 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Eval = new EvaluateAction<T>()
static

Recursively evaluates the given tree.
Eval :: Tree -> TValue

Definition at line 241 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Fail = new FailAction<T>()
static

Returns null.
Fail :: Any

Definition at line 251 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.FDiv = new OperationAction<T, double, double>("FDiv", (x, y) => x / y)
static

Floating point division.
FDiv :: Real -&gt Real -> Real

Definition at line 111 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Flatten = new FlattenAction<T>()
static

Converts a tree into its string representation. An optional argument specifies the depth.
Flatten :: Tree -> [Integer] -> String

Definition at line 174 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Floor = new ConvertAction<T, double, int>("Floor", x => Convert.ToInt32(Math.Floor(x)))
static

Returns a floor of a real number.
Floor :: Real -> Integer

Definition at line 84 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Geq = new OperationAction<T, double, bool>("Geq", (x, y) => x >= y)
static

Comparison "Greater than or equal to".
Geq :: Real -> Real -> Boolean

Definition at line 150 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Gr = new OperationAction<T, double, bool>("Gr", (x, y) => x > y)
static

Comparison "Greater than".
Gr :: Real -> Real -> Boolean

Definition at line 144 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Identity = new IdentityAction<T>()
static

Returns the same value.
Identity[a = Any] :: a -> a

Definition at line 273 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.If = new IfAction<T>()
static

Condition. The semantics of (if c0 a0 c1 a1 ... e) is if (c0) then a1; else if (c1) then a1; ... else e;. All values and conditions are evaluated lazily.
Moreover, types of a_ must be equal otherwise the type inference would fail.
If[a = Any] :: [Boolean,a...] -> a -> a

Definition at line 221 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.IsNull = new ConvertAction<T, object, bool>("IsNull", x => x == null, ArgumentType.Null)
static

Indicates whether the object is null.
IsNull :: Any -> Boolean

Definition at line 120 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Join = new JoinAction<T>()
static

Converts all arguments to strings and joins them with a given separator.
Join :: String -> [Any...] -> String

Definition at line 165 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Leaves = new ConvertAction<T, Tree<Symbol>, int>("Leaves", x => x.LeavesCount)
static

Returns the count of leaves of the given tree.
Leaves :: Tree -> Integer

Definition at line 189 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Leq = new OperationAction<T, double, bool>("Leq", (x, y) => x <= y)
static

Comparison "Less than or equal to".
Leq :: Real -> Real -> Boolean

Definition at line 153 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Let = new LetAction<T>()
static

Saves the value in the current context.
The semantics of (Let x v0 y v1 ... act) is let (x = v0; y = v1; ...) in (act);.
The return type is same as the type of act.
Let[a = Any] :: [String,Any...] -> a -> a

Definition at line 282 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Ls = new OperationAction<T, double, bool>("Ls", (x, y) => x < y)
static

Comparison "Less than".
Ls :: Real -> Real -> Boolean

Definition at line 147 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Mod = new OperationAction<T, int, int>("Mod", (x, y) => x % y)
static

Modulo.
Mod :: Integer -> Integer -> Integer

Definition at line 114 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Mul = new ArithmeticAction<T>("Mul", (x, y) => x * y)
static

Multiplies the arguments.
Mul[a = Integer|Real] :: a -> a -> ... -> a

Definition at line 102 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Name = new ConvertAction<T, Symbol, string>("Name", x => x.Name)
static

Returns the name of the given symbol.
Name :: Symbol -> String

Definition at line 180 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Neq = new OperationAction<T, object, bool>("Neq", (x, y) => (x == null) || !x.Equals(y), ArgumentType.Null)
static

Complement of Eq.
Neq :: Any -> Any -> Boolean

Definition at line 141 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Not = new ConvertAction<T, bool, bool>("Not", x => !x)
static

Logical negation.
Not :: Boolean -> Boolean

Definition at line 129 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Or = new FoldingAction<T, bool, bool>("Or", 2, (x, y) => x && y, false)
static

Logical addition.
Or :: Boolean -> Boolean -> ... -> Boolean

Definition at line 126 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.ParseBoolean
static
Initial value:
= new ConvertAction<T, string, bool>("ParseBoolean",
x => { bool b; return bool.TryParse(x, out b) ? b : default(bool); })

Converts a string representation of a boolean.
ParseBoolean :: String -> Boolean

Definition at line 71 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.ParseInteger
static
Initial value:
= new ConvertAction<T, string, int>("ParseInteger",
x => { int i; return int.TryParse(x, NumberStyles.Integer, cinf, out i) ? i : default(int); })

Converts a string representation of an integer.
ParseInteger :: String -> Integer

Definition at line 55 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.ParseReal
static
Initial value:
= new ConvertAction<T, string, double>("ParseReal",
x => { double d; return double.TryParse(x, NumberStyles.Float, cinf, out d) ? d : default(double); })

Converts a string representation of a decimal number.
ParseReal :: String -> Real

Definition at line 63 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Pow = new ArithmeticAction<T>("Pow", (x, y) => Math.Pow(x, y))
static

Exponentiates the values.
Pow[a = Integer|Real] :: a -> a -> ... -> a

Definition at line 108 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Preterminal
static
Initial value:
= new ConvertAction<T, Tree<Symbol>, string>("Preterminal", x =>
{
return ((x.Children.Count != 1)
|| ((x[0].Value.Type & (SymbolType.Terminal | SymbolType.Epsilon)) == SymbolType.None))
? null : x[0].Value.Name;
})

Returns a string value of a preterminal rule (of the form A -&gt b where b is the terminal. If the tree was not generated by a preterminal rule, returns null.
Preterminal :: Tree -> String

Definition at line 204 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Round = new ConvertAction<T, double, int>("Round", x => Convert.ToInt32(Math.Round(x)))
static

Rounds a real number.
Round :: Real -> Integer

Definition at line 78 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Select = new SelectAction<T>()
static

Selection. The semantics of (select i c0 c1 ... cn def) is if (0 <= i <= n) then ci; else def;. All values are evaluated lazily.
Moreover, types of c_ must be equal otherwise the type inference would fail.
Select[a = Any] :: Integer -> [a...] -> a -> a

Definition at line 230 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Simple = new SimpleAction<T>()
static

Evaluates the subtree of a given tree provided that it is the only subtree; otherwise returns null.
Simple :: Tree -> TValue

Definition at line 248 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.String = new ConvertAction<T, object, string>("String", x => x.ToString())
static

Call ToString() method on its argument.
String :: Any -> String

Definition at line 90 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Sub = new ArithmeticAction<T>("Sub", (x, y) => x - y)
static

Subtracts the arguments.
Sub[a = Integer|Real] :: a -> a -> ... -> a

Definition at line 99 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.SubTree = new SubTreeAction<T>()
static

Returns a child of a given tree at index specified as the second parameter. If no such child exists, the action returns null.
SubTree :: Tree -> Integer -> Tree

Definition at line 196 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Symbol = new ConvertAction<T, Tree<Symbol>, Symbol>("Symbol", x => x.Value)
static

Returns the root symbol of the given tree.
Symbol :: Tree -> Symbol

Definition at line 183 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.ToReal = new ConvertAction<T, int, double>("ToReal", x => Convert.ToDouble(x))
static

Converts an integer value to decimal.
ToReal :: Integer -> Real

Definition at line 87 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Trace = new TraceAction<T>()
static

Logs an event to the entry tree.
Trace[a = Any] -> a -> String -> [Any...] -> a

Definition at line 299 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Try = new TryAction<T>()
static

Try action. The semantics of (try e1 e2) is try { e1; } catch (Mercury.Exceptions.ErrorActionException) { e2; }.
If the second argument is not specified, it will behave like (try e1 (fail)). Moreover, the types of e1 and e2 must be equal.
Try[a = Any] :: a -> a -> a

Definition at line 260 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Var = new VarAction<T>()
static

Retrieves the value stored by Let, but only in the same context. The function also performs runtime type check; if the value stored does not exist or match the type required, it will throw an exception.
Var :: String -> Any

Definition at line 290 of file BasicActions.cs.

readonly InterpreterAction<T> Mercury.Interpreting.BasicActions< T >.Xor = new OperationAction<T, bool, bool>("Xor", (x, y) => x ^ y)
static

Exclusive disjunction.
Xor :: Boolean -> Boolean -> Boolean

Definition at line 132 of file BasicActions.cs.


The documentation for this class was generated from the following file: