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

Interprets derivation trees using rewrite rules. The type parameter T represents the target language.

More...

Inheritance diagram for Mercury.Interpreting.Interpreter< T >:
Mercury.Interpreting.IInterpreter< T >

Public Member Functions

 Interpreter (RewriteRuleCollection< T > rules, IInterpreterContextFactory factory, bool logging=true, int boostlim=4)
 Creates a new Interpreter instance. More...
 
InterpreterResult< T > Interpret (Tree< Symbol > tree)
 Interprets the tree using rewrite rules. More...
 
IReadOnlyList
< InterpreterResult< T > > 
Interpret (IReadOnlyList< Tree< Symbol >> trees)
 Interprets the specified trees. If the number of trees is at least boostlim specified in the constructor, the method will use memoization and parallelism. More...
 

Properties

RewriteRuleCollection< T > RewriteRules [get, set]
 The collection of rewrite rules. More...
 
- Properties inherited from Mercury.Interpreting.IInterpreter< T >
RewriteRuleCollection< T > RewriteRules [get]
 The collection of rewrite rules used by the interpreter More...
 

Detailed Description

Interprets derivation trees using rewrite rules. The type parameter T represents the target language.

Achtung: if T equals dynamic, the type check will assume all possible values on arguments and actions that take (or return for that matter) TValue.

The method Interpret parametrized with lists uses parallelism and memory caching. If number of interpreted trees is at least boostlim, the method will use System.Runtime.Caching.MemoryCache and System.Threading.Tasks.Parallel components to speed up the analysis. The value boostlim is 4 by default.

Type Constraints
T :class 

Definition at line 57 of file Interpreter.cs.

Constructor & Destructor Documentation

Mercury.Interpreting.Interpreter< T >.Interpreter ( RewriteRuleCollection< T >  rules,
IInterpreterContextFactory  factory,
bool  logging = true,
int  boostlim = 4 
)

Creates a new Interpreter instance.

Parameters
rulesA collection of rewrite rules.
factoryThe context factory or null to use the default factory.
loggingIf false, the interpreter will throw away logging structure to save memory
boostlimSpecifies the amount of trees required for the method Interpret on list of trees to use memoisation and parallelism. The default value is 4.
Exceptions
System.ArgumentNullExceptionWhen rules reference is null.

Definition at line 367 of file Interpreter.cs.

Member Function Documentation

InterpreterResult<T> Mercury.Interpreting.Interpreter< T >.Interpret ( Tree< Symbol tree)

Interprets the tree using rewrite rules.

Parameters
treeThe tree to interpret.
Returns
Result of the interpretation.

Implements Mercury.Interpreting.IInterpreter< T >.

Definition at line 391 of file Interpreter.cs.

IReadOnlyList<InterpreterResult<T> > Mercury.Interpreting.Interpreter< T >.Interpret ( IReadOnlyList< Tree< Symbol >>  trees)

Interprets the specified trees. If the number of trees is at least boostlim specified in the constructor, the method will use memoization and parallelism.

Parameters
treesThe list of trees.
Returns
List of results.

Implements Mercury.Interpreting.IInterpreter< T >.

Definition at line 401 of file Interpreter.cs.

Property Documentation

RewriteRuleCollection<T> Mercury.Interpreting.Interpreter< T >.RewriteRules
getset

The collection of rewrite rules.

Definition at line 382 of file Interpreter.cs.


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