00001
00002
00003
00005
00006 * Copyright (c) 1996-2000 Erwin Coumans <[email protected]>
00007 *
00008 * Permission to use, copy, modify, distribute and sell this software
00009 * and its documentation for any purpose is hereby granted without fee,
00010 * provided that the above copyright notice appear in all copies and
00011 * that both that copyright notice and this permission notice appear
00012 * in supporting documentation. Erwin Coumans makes no
00013 * representations about the suitability of this software for any
00014 * purpose. It is provided "as is" without express or implied warranty.
00015 *
00016 */
00017 #ifndef __INPUTPARSER_H__
00018 #define __INPUTPARSER_H__
00019
00020 class CParser;
00021 #include "Expression.h"
00022
00023
00024 class CParser {
00025 public:
00026 CParser();
00027 virtual ~CParser();
00028
00029 float GetFloat(CCString txt);
00030 CValue* GetValue(CCString txt, bool bFallbackToText=false);
00031 CExpression* ProcessText(CCString intext);
00032 void SetContext(CValue* context);
00033
00034 private:
00035 enum symbols {errorsym, lbracksym, rbracksym, cellsym, commasym,
00036 opsym, constsym, sumsym, ifsym, whocodedsym, eolsym,idsym};
00037 enum optype { OPplus, OPminus, OPtimes, OPdivide, OPand, OPor, OPequal,
00038 OPunequal, OPgreater, OPless, OPgreaterequal, OPlessequal, OPnot };
00039 enum consttype { booltype, inttype, floattype, stringtype };
00040
00041 int sym,
00042 opkind,
00043 constkind;
00044
00045 char ch;
00046 int chcount;
00047 CExpression *errmsg;
00048
00049 CCString text,
00050 const_as_string;
00051 bool boolvalue;
00052 CValue* m_identifierContext;
00053
00054
00055 void ScanError(CCString str);
00056 CExpression* Error(CCString str);
00057 void NextCh();
00058 void TermChar(char c);
00059 void DigRep();
00060 void CharRep();
00061 void GrabString(int start);
00062 void NextSym();
00063 int MakeInt();
00064 CCString Symbol2Str(int s);
00065 void Term(int s);
00066 int Priority(int optor);
00067 CExpression *Ex(int i);
00068 CExpression *Expr();
00069
00070 };
00071
00072 #endif