00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _TPARSER
00024 #define _TPARSER
00025
00026 #include "equ.h"
00027 #include "func.h"
00028
00029 struct Token
00030 {
00031 Token *Last;
00032 Token *Next;
00033 func_type Type;
00034 NumVar Value;
00035 };
00036
00037 class Parser
00038 {
00039 public:
00040 Parser();
00041 ~Parser();
00042 Equation *TextToTree(char *);
00043 void TreeToText(Equation *);
00044 void TidyUpEqn(Equation *);
00045
00046 private:
00047 void PassOne();
00048 void PassTwo();
00049 void ErrorCheck();
00050 void Digit(char *, double *, bool *, int *);
00051 void Alpha(char *,char *);
00052 void Symbol(char *);
00053 void EndFunc(char *);
00054 void EndNum(double *, bool *, int *);
00055 void AddToken(func_type);
00056 bool Priority(func_type, func_type);
00057 void RemoveBrackets();
00058 void TidyUp();
00059 void TidyNode(Node *&);
00060 void TreeToText();
00061 char * TreeToText(Node *);
00062 void NodeText(int, Node *, char *, int &);
00063
00064 private:
00065 char *EquationText;
00066 Token *EquationTokenStart;
00067 Token *EquationTokenEnd;
00068 Equation *equation;
00069 };
00070
00071 #endif