?? expressionreader.cs
字號:
using System;
using System.Collections.Generic;
using System.Text;
namespace syn
{
class ExpressionReader
{
private string expression = null;
private int curPos = 0; // Indicate where is the beginning of reading block
private int movPos = 0; // Indicate where is the ending of reading block
public ExpressionReader(string expression)
{
this.expression = expression;
}
public void ResetPointer()
{
this.curPos = this.movPos = 0;
}
public ExpressAtom NextAtom()
{
ExpressAtom atom = null;
while (movPos < expression.Length)
{
// Here, I suppose all operands are single char, otherwise change it to the Number style below
if (Operator.IsOperator(expression[movPos]))
{
atom = new ExpressAtom(new Operator( expression[movPos]));
break;
}
if(Operand.IsOperand(expression[movPos]))
{
curPos = movPos;
do
{
movPos++;
if(movPos>=expression.Length)
break;
} while ( Operand.IsOperand(expression[movPos]));
atom = new ExpressAtom(new Operand( expression.Substring(curPos, movPos - curPos)));
movPos--;
break;
}
movPos++;
curPos = movPos;
}
// adjust posision pointer
movPos++;
curPos = movPos;
return atom;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -