📄 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 + -