Exemple #1
0
 public override void Init(ParsingContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
       FindOpAndDetectPostfix(treeNode);
       int argIndex = IsPostfix? 0 : 1;
       Argument = AddChild(NodeUseType.ValueReadWrite, "Arg", treeNode.MappedChildNodes[argIndex]);
       BinaryOpSymbol = OpSymbol[0].ToString(); //take a single char out of ++ or --
       BinaryOp = context.GetOperatorExpressionType(BinaryOpSymbol);
       base.AsString = OpSymbol + (IsPostfix ? "(postfix)" : "(prefix)");
 }
 public override void Init(ParsingContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
       Left = AddChild("Arg", treeNode.MappedChildNodes[0]);
       Right = AddChild("Arg", treeNode.MappedChildNodes[2]);
       var opToken = treeNode.MappedChildNodes[1].FindToken();
       OpSymbol = opToken.Text;
       Op = context.GetOperatorExpressionType(OpSymbol);
       // Set error anchor to operator, so on error (Division by zero) the explorer will point to
       // operator node as location, not to the very beginning of the first operand.
       ErrorAnchor = opToken.Location;
       AsString = Op + "(operator)";
 }
 public override void Init(ParsingContext context, ParseTreeNode treeNode)
 {
     base.Init(context, treeNode);
       Target = AddChild(NodeUseType.ValueWrite, "To", treeNode.MappedChildNodes[0]);
       //Get Op and baseOp if it is combined assignment
       AssignmentOp = treeNode.MappedChildNodes[1].FindTokenAndGetText();
       if (string.IsNullOrEmpty(AssignmentOp))
     AssignmentOp = "=";
       BinaryExpressionType = CustomExpressionTypes.NotAnExpression;
       //There maybe an "=" sign in the middle, or not - if it is marked as punctuation; so we just take the last node in child list
       Expression = AddChild(NodeUseType.ValueRead, "Expr", treeNode.LastChild);
       AsString = AssignmentOp + " (assignment)";
       // TODO: this is not always correct: in Pascal the assignment operator is :=.
       IsAugmented = AssignmentOp.Length > 1;
       if (IsAugmented) {
     //it is combined op
     base.ExpressionType = context.GetOperatorExpressionType(AssignmentOp);
     BinaryExpressionType = OperatorUtility.GetBinaryOperatorForAugmented(this.ExpressionType);
     Target.UseType = NodeUseType.ValueReadWrite;
       }
 }