1 using Mercury.Exceptions;
2 using Mercury.Interpreting;
3 using Mercury.Nucleus.Trees;
6 using System.Collections.Generic;
19 private static string epsilon =
"e";
20 private static string root =
"S";
21 private static char[] alpha =
new[] {
'@',
'_' };
22 internal static string alphastr =
new string(alpha);
25 private static IReadOnlyDictionary<ParameterType, ArgumentType> typeMap
26 =
new Dictionary<ParameterType, ArgumentType>
28 { ParameterType.IntegralConstant, ArgumentType.Integer | ArgumentType.Real },
29 { ParameterType.RealConstant, ArgumentType.Real },
30 { ParameterType.StringConstant, ArgumentType.String },
31 { ParameterType.BooleanConstant, ArgumentType.Boolean },
32 { ParameterType.Variable, ArgumentType.Symbol | ArgumentType.Tree },
36 private static Dictionary<Type, ArgumentType> rtmap =
new Dictionary<Type, ArgumentType>
38 { typeof(
int), ArgumentType.Integer },
39 { typeof(
double), ArgumentType.Real },
40 { typeof(
string), ArgumentType.String },
41 { typeof(
bool), ArgumentType.Boolean },
42 { typeof(
Symbol), ArgumentType.Symbol },
43 { typeof(Tree<Symbol>), ArgumentType.Tree },
44 { typeof(
object), ArgumentType.Any },
50 public static string Epsilon {
get {
return epsilon; } }
53 public static string Root {
get {
return root; } }
67 {
return ptype == ParameterType.ActionCall ? ArgumentType.None : typeMap[ptype]; }
89 if (!rtmap.TryGetValue(tpu, out rargt) || tpu.Equals(tpt))
90 rargt |= ArgumentType.TValue;
Global class containing cool static / convenience stuff.
ArgumentType
Defines argument types using in the Mercury library
static string Epsilon
Default epsilon symbol name
ParameterType
Formal Parameter Type
static ArgumentType ParamToArgType(ParameterType ptype)
Translates formal Mercury.Interpreting.ParameterType into Mercury.Interpreting.ArgumentType. If the input is Mercury.Interpreting.ParameterType.ActionCall, this function will yield Mercury.Interpreting.ArgumentType.None as it cannot resolve return types of the Mercury.Interpreting.ActionCall. In that case use ReturnType field of the Mercury.Interpreting.InterpreterAction{T} class wrapped in the Mercury.Interpreting.ActionCall.
static string Root
Default root symbol name
static ArgumentType TypeToArgType< T, U >()
Translates a .NET type into Mercury.Interpreting.ArgumentType. If T equals U , T:System.Object or dynamic this function will return Mercury.Interpreting.ArgumentType.Any. If T is one of int, double, bool, string, Symbol or Tree
Represents a single symbol of the grammar. This is an immutable class. For a symbol name to be val...