public override void Build(Stack <Node> rpnStack, Element element, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions) { _variableName = element.Token.Text; _variables = variables; }
public override void Build(Stack <Node> rpnStack, Element element, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions) { ValueType = ValueType.Tuple; TupleValue = new List <Node>(); if (!rpnStack.TryPop(out var rightNode) || !rpnStack.TryPop(out var leftNode)) { throw new ParserException(element.Token, "Cannot find values to create parameter list"); } if (leftNode.ValueType == ValueType.Tuple) { // unfold tuple list foreach (var parameter in leftNode.TupleValue) { TupleValue.Add(parameter); } } else { TupleValue.Add(leftNode); } TupleValue.Add(rightNode); }
public override void Build(Stack <Node> rpnStack, Element element, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions) { if (!rpnStack.TryPop(out _rightNode) || !rpnStack.TryPop(out _leftNode)) { throw new ParserException(element.Token, "Cannot find tokens to sequence"); } }
public override void Build(Stack <Node> rpnStack, Element element, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions) { ValueType = ValueType.Boolean; if (!rpnStack.TryPop(out _childNode)) { throw new ParserException(element.Token, "Cannot find value to perform negate operation on"); } }
public override void Build(Stack <Node> rpnStack, Element element, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions) { if (!rpnStack.TryPop(out _rightNode) || !rpnStack.TryPop(out _leftNode)) { throw new ParserException(element.Token, "Cannot find values to perform arithmetic operation on"); } _operator = element.Type; }
public override void Build(Stack <Node> rpnStack, Element element, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions) { ValueType = ValueType.Boolean; _operationType = element.Type; if (!rpnStack.TryPop(out _rightNode) || !rpnStack.TryPop(out _leftNode)) { throw new ParserException(element.Token, NodesNotAvailableErrorMessage); } }
public override void Build(Stack <Node> rpnStack, Element element, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions) { if ((options & Compiler.Options.Immutable) == Compiler.Options.Immutable) { throw new ParserException(element.Token, "An assignment operator cannot be used for an immutable script"); } _assignmentType = element.Type; if (!rpnStack.TryPop(out _rightNode) || !rpnStack.TryPop(out _leftNode)) { throw new ParserException(element.Token, "Cannot find elements to perform assignment operation on"); } }
public static Node Build(List <Element> elements, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions) { var rpnStack = new Stack <Node>(); foreach (var element in elements) { var node = CreateNode(element.Type); node.Build(rpnStack, element, options, variables, functions); rpnStack.Push(node); } if (rpnStack.Count > 1) { throw new RuntimeException("Missing operator(s) to process all values"); } return(rpnStack.Pop()); }
public override void Build(Stack <Node> rpnStack, Element element, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions) { if (!functions.TryGetValue(element.Token.Text, out _functionOverload)) { throw new ParserException(element.Token, $"Undefined function: {element.Token.Text}"); } if (!rpnStack.TryPop(out var childNode)) { throw new ParserException(element.Token, $"Cannot find parameters for calling function: {element.Token.Text}"); } switch (childNode.ValueType) { case ValueType.Boolean: case ValueType.Float: case ValueType.Integer: case ValueType.Undefined: _parameters = new List <Node>(); _parameters.Add(childNode); _parameterTypes = new Type[1]; break; case ValueType.Tuple: _parameters = childNode.TupleValue; _parameterTypes = new Type[_parameters.Count]; break; case ValueType.Null: _parameterTypes = Array.Empty <Type>(); break; default: throw new ArgumentOutOfRangeException(nameof(childNode.ValueType), childNode.ValueType, "Unsupported child not value type"); } }
public override void Build(Stack <Node> rpnStack, Element element, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions) { ValueType = ValueType.Null; }
public override void Build(Stack <Node> rpnStack, Element element, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions) { Initialize(element.Type == ElementType.BooleanLiteralTrue); }
public override void Build(Stack <Node> rpnStack, Element element, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions) { Initialize(int.Parse(element.Token.Text)); }
public abstract void Build(Stack <Node> rpnStack, Element element, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions);
public override void Build(Stack <Node> rpnStack, Element element, Compiler.Options options, IDictionary <string, VariableValue> variables, IDictionary <string, CustomFunctionOverload> functions) { throw new System.NotImplementedException("Fake nodes cannot be built from RPN srack"); }