Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
BinaryOperationNode.cs
Go to the documentation of this file.
1 #region License
2 /* **********************************************************************************
3  * Copyright (c) Roman Ivantsov
4  * This source code is subject to terms and conditions of the MIT License
5  * for Irony. A copy of the license can be found in the License.txt file
6  * at the root of this distribution.
7  * By using this source code in any fashion, you are agreeing to be bound by the terms of the
8  * MIT License.
9  * You must not remove this notice from this software.
10  * **********************************************************************************/
11 #endregion
12 
13 using System;
14 using System.Collections.Generic;
15 using System.Linq;
16 using System.Text;
17 using Irony.Interpreter;
18 using Irony.Parsing;
19 
20 namespace Irony.Interpreter.Ast {
21  public class BinaryOperationNode : AstNode {
22  public AstNode Left;
23  public string Op;
24  public AstNode Right;
25 
26  public BinaryOperationNode() { }
27  public override void Init(ParsingContext context, ParseTreeNode treeNode) {
28  base.Init(context, treeNode);
29  Left = AddChild("Arg", treeNode.ChildNodes[0]);
30  Right = AddChild("Arg", treeNode.ChildNodes[2]);
31  var opToken = treeNode.ChildNodes[1].FindToken();
32  Op = opToken.Text;
33  //Set error anchor to operator, so on error (Division by zero) the explorer will point to
34  // operator node as location, not to the very beginning of the first operand.
35  ErrorAnchor = opToken.Location;
36  AsString = Op + "(operator)";
37  }
38 
39  public override void EvaluateNode(EvaluationContext context, AstMode mode) {
40  Left.Evaluate(context, AstMode.Read);
41  Right.Evaluate(context, AstMode.Read);
42  context.CallDispatcher.ExecuteBinaryOperator(this.Op);
43  }//method
44 
45  }//class
46 }//namespace
ParseTreeNodeList ChildNodes
Definition: ParseTree.cs:41
override void EvaluateNode(EvaluationContext context, AstMode mode)
override void Init(ParsingContext context, ParseTreeNode treeNode)