Blender V2.61 - r43446

InputParser.h

Go to the documentation of this file.
00001 /*
00002  * Parser.h: interface for the CParser class.
00003  * Eindhoven University of Technology 1997
00004  * OOPS team (Serge vd Boom, Erwin Coumans, Tom Geelen, Wynke Stuylemeier)
00005  * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
00006  *
00007  * Permission to use, copy, modify, distribute and sell this software
00008  * and its documentation for any purpose is hereby granted without fee,
00009  * provided that the above copyright notice appear in all copies and
00010  * that both that copyright notice and this permission notice appear
00011  * in supporting documentation.  Erwin Coumans makes no
00012  * representations about the suitability of this software for any
00013  * purpose.  It is provided "as is" without express or implied warranty.
00014  *
00015  */
00016 
00021 #ifndef __INPUTPARSER_H__
00022 #define __INPUTPARSER_H__
00023 
00024 class CParser;
00025 #include "Expression.h"
00026 
00027 
00028 class CParser
00029 {
00030 public:
00031     CParser();
00032     virtual             ~CParser();
00033 
00034     float               GetFloat(STR_String& txt);
00035     CValue*             GetValue(STR_String& txt, bool bFallbackToText=false);
00036     CExpression*        ProcessText(const char *intext);
00037     void                SetContext(CValue* context);
00038 
00039 private:
00040     enum symbols {
00041         errorsym,
00042         lbracksym,
00043         rbracksym,
00044         cellsym,
00045         commasym,
00046         opsym,
00047         constsym,
00048         sumsym,
00049         ifsym,
00050         whocodedsym,
00051         eolsym,
00052         idsym
00053     };          // all kinds of symbols
00054 
00055     enum optype {
00056         OPmodulus,
00057         OPplus,
00058         OPminus,
00059         OPtimes,
00060         OPdivide,
00061         OPand,
00062         OPor,
00063         OPequal,
00064         OPunequal,
00065         OPgreater,
00066         OPless,
00067         OPgreaterequal,
00068         OPlessequal,
00069         OPnot
00070     };      // all kinds of operators
00071 
00072     enum consttype {
00073         booltype,
00074         inttype,
00075         floattype,
00076         stringtype
00077     };      // all kinds of constants
00078     
00079     int sym,                    // current symbol
00080         opkind,                 // kind of operator, if symbol is an operator
00081         constkind;              // kind of operator, if symbol is a constant
00082     
00083     char ch;                    // current character
00084     int chcount;                // index to character in input string
00085     CExpression *errmsg;        // contains a errormessage, if scanner error
00086     
00087     STR_String text,                // contains a copy of the original text
00088         const_as_string;        // string representation of the symbol, if symbol is a constant
00089     bool boolvalue;             // value of the boolean, if symbol is a constant of type boolean
00090     CValue* m_identifierContext;// context in which identifiers are looked up
00091     
00092     
00093     void ScanError(const char *str);
00094     CExpression* Error(const char *str);
00095     void NextCh();
00096     void TermChar(char c);
00097     void DigRep();
00098     void CharRep();
00099     void GrabString(int start);
00100     void GrabRealString(int start);
00101     void NextSym();
00102 #if 0   /* not used yet */
00103     int MakeInt();
00104 #endif
00105     STR_String Symbol2Str(int s);
00106     void Term(int s);
00107     int Priority(int optor);
00108     CExpression *Ex(int i);
00109     CExpression *Expr();
00110     
00111     
00112 #ifdef WITH_CXX_GUARDEDALLOC
00113 public:
00114     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CParser"); }
00115     void operator delete( void *mem ) { MEM_freeN(mem); }
00116 #endif
00117 };
00118 
00119 #endif
00120