operator.cs

来自「Excel的操作,其中可以读取及写入Excel 文件」· CS 代码 · 共 60 行

CS
60
字号
using System;
using System.Collections;

namespace Microsoft.Fawvw.Components.NExcel.Biff.Formula
{
	
	/// <summary> An operator is a node in a parse tree.  Its children can be other
	/// operators or operands
	/// Arithmetic operators and functions are all considered operators
	/// </summary>
	abstract class Operator:ParseItem
	{
		/// <summary> Gets the precedence for this operator.  Operator precedents run from 
		/// 1 to 5, one being the highest, 5 being the lowest
		/// 
		/// </summary>
		/// <returns> the operator precedence
		/// </returns>
		internal abstract int Precedence{get;}
		/// <summary> The items which this operator manipulates. There will be at most two</summary>
		private ParseItem[] operands;
		
		/// <summary> Constructor</summary>
		public Operator()
		{
			operands = new ParseItem[0];
		}
		
		/// <summary> Tells the operands to use the alternate code</summary>
		protected internal virtual void  setOperandAlternateCode()
		{
			for (int i = 0; i < operands.Length; i++)
			{
				operands[i].setAlternateCode();
			}
		}
		
		/// <summary> Adds operands to this item</summary>
		protected internal virtual void  add(ParseItem n)
		{
			n.Parent = this;
			
			// Grow the array
			ParseItem[] newOperands = new ParseItem[operands.Length + 1];
			Array.Copy(operands, 0, newOperands, 0, operands.Length);
			newOperands[operands.Length] = n;
			operands = newOperands;
		}
		
		/// <summary> Gets the operands for this operator from the stack </summary>
		public abstract void  getOperands(Stack s);
		
		/// <summary> Gets the operands ie. the children of the node</summary>
		protected internal virtual ParseItem[] getOperands()
		{
			return operands;
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?