12
private struct Entry {
11
18
// We only store the type, as that is what is important.
12
19
private static Gee.HashMap<string, Type?> _allowed_functions;
14
protected const long UNDEFINED = long.MIN + 1; //+1 so that I can still use Long.MIN_VALUE.
21
protected const int64 UNDEFINED = int64.MIN + 1; //+1 so that I can still use int64.MIN_VALUE.
16
23
protected const string CH_RARR = "\u2192";
70
77
protected const string SYM_TRUNK_END = SYM_END; //"]"
73
_allowed_functions = new Gee.HashMap<string, Type?> ();
74
this.priority = PRIO_FUNCTION;
80
this.priority = Prio.FUNCTION;
78
85
* Ititialise the right functon token by it's name.
81
88
* @param position Token position.
82
89
* @return An instance representing the function, or @c null if not found.
84
public static FunctionToken? init_token (string token, int position) {
85
FunctionToken? retval = null;
91
public static FunctionToken? init_token (string token, int32 position) {
93
if (_allowed_functions == null) {
94
// Intialise the HashMap if it is not created.
95
_allowed_functions = new Gee.HashMap<string, Type?> ();
98
{"round_up", typeof (RoundUpFunctionToken)},
99
{"round_down", typeof (RoundDownFunctionToken)},
100
{"roll_and_keep", typeof (RollAndKeepFunctionToken)},
104
foreach (Entry e in entries) {
105
_allowed_functions.@set (e.key, e.val);
87
110
// We get the token type.
88
111
Type? t = _allowed_functions.@get (token.down ());
91
114
// Construct a new instance of the token.
92
retval = (FunctionToken) GLib.Object.@new (t, null, null);
115
return (FunctionToken) GLib.Object.@new (t, null, null);