上面要涉及到运算符优先顺序查找表。
给你提供一下。其他的你慢慢弄。
Var
SearchTable:array[Char,Char] of Char;
SearchTable['+','+']:='>';
SearchTable['-','+']:='>';
SearchTable['*','+']:='>';
SearchTable['/','+']:='>';
SearchTable['(','+']:='<';
SearchTable[')','+']:='>';
SearchTable[',','+']:=' ';
SearchTable['#','+']:='<';
SearchTable['+','-']:='>';
SearchTable['-','-']:='>';
SearchTable['*','-']:='>';
SearchTable['/','-']:='>';
SearchTable['(','-']:='<';
SearchTable[')','-']:='>';
SearchTable[',','-']:=' ';
SearchTable['#','-']:='<';
SearchTable['+','*']:='<';
SearchTable['-','*']:='<';
SearchTable['*','*']:='>';
SearchTable['/','*']:='>';
SearchTable['(','*']:='<';
SearchTable[')','*']:='>';
SearchTable[',','*']:=' ';
SearchTable['#','*']:='<';
SearchTable['+','/']:='<';
SearchTable['-','/']:='<';
SearchTable['*','/']:='>';
SearchTable['/','/']:='>';
SearchTable['(','/']:='<';
SearchTable[')','/']:='>';
SearchTable[',','/']:=' ';
SearchTable['#','/']:='<';
SearchTable['+','(']:='<';
SearchTable['-','(']:='<';
SearchTable['*','(']:='<';
SearchTable['/','(']:='<';
SearchTable['(','(']:='<';
SearchTable[')','(']:=' ';
SearchTable[',','(']:=' ';
SearchTable['#','(']:='<';
SearchTable['+','(']:='>';
SearchTable['-',')']:='>';
SearchTable['*',')']:='>';
SearchTable['/',')']:='>';
SearchTable['(',')']:='=';
SearchTable[')',')']:='>';
SearchTable[',',')']:=' ';
SearchTable['#',')']:=' ';
SearchTable['+','#']:='>';
SearchTable['-','#']:='>';
SearchTable['*','#']:='>';
SearchTable['/','#']:='>';
SearchTable['(','#']:=' ';
SearchTable[')','#']:='>';
SearchTable[',','#']:=' ';
SearchTable['#','#']:='=';