fix for building with collada and some other warnings
[blender.git] / source / gameengine / Expressions / InputParser.h
1 /*
2  * Parser.h: interface for the CParser class.
3  * Eindhoven University of Technology 1997
4  * OOPS team (Serge vd Boom, Erwin Coumans, Tom Geelen, Wynke Stuylemeier)
5  * $Id$
6  * Copyright (c) 1996-2000 Erwin Coumans <coockie@acm.org>
7  *
8  * Permission to use, copy, modify, distribute and sell this software
9  * and its documentation for any purpose is hereby granted without fee,
10  * provided that the above copyright notice appear in all copies and
11  * that both that copyright notice and this permission notice appear
12  * in supporting documentation.  Erwin Coumans makes no
13  * representations about the suitability of this software for any
14  * purpose.  It is provided "as is" without express or implied warranty.
15  *
16  */
17
18 /** \file InputParser.h
19  *  \ingroup expressions
20  */
21
22 #ifndef __INPUTPARSER_H__
23 #define __INPUTPARSER_H__
24
25 class CParser;
26 #include "Expression.h"
27
28
29 class CParser
30 {
31 public:
32         CParser();
33         virtual                         ~CParser();
34
35         float                           GetFloat(STR_String& txt);
36         CValue*                         GetValue(STR_String& txt, bool bFallbackToText=false);
37         CExpression*            ProcessText(const char *intext);
38         void                            SetContext(CValue* context);
39
40 private:
41         enum symbols {
42                 errorsym,
43                 lbracksym,
44                 rbracksym,
45                 cellsym,
46                 commasym,
47                 opsym,
48                 constsym,
49                 sumsym,
50                 ifsym,
51                 whocodedsym,
52                 eolsym,
53                 idsym
54         };                      // all kinds of symbols
55
56         enum optype {
57                 OPmodulus,
58                 OPplus,
59                 OPminus,
60                 OPtimes,
61                 OPdivide,
62                 OPand,
63                 OPor,
64                 OPequal,
65                 OPunequal,
66                 OPgreater,
67                 OPless,
68                 OPgreaterequal,
69                 OPlessequal,
70                 OPnot
71         };              // all kinds of operators
72
73         enum consttype {
74                 booltype,
75                 inttype,
76                 floattype,
77                 stringtype
78         };              // all kinds of constants
79         
80         int sym,                                        // current symbol
81                 opkind,                                 // kind of operator, if symbol is an operator
82                 constkind;                              // kind of operator, if symbol is a constant
83         
84         char ch;                                        // current character
85         int chcount;                            // index to character in input string
86         CExpression *errmsg;            // contains a errormessage, if scanner error
87         
88         STR_String text,                                // contains a copy of the original text
89                 const_as_string;                // string representation of the symbol, if symbol is a constant
90         bool boolvalue;                         // value of the boolean, if symbol is a constant of type boolean
91         CValue* m_identifierContext;// context in which identifiers are looked up
92         
93         
94         void ScanError(const char *str);
95         CExpression* Error(const char *str);
96         void NextCh();
97         void TermChar(char c);
98         void DigRep();
99         void CharRep();
100         void GrabString(int start);
101         void GrabRealString(int start);
102         void NextSym();
103 #if 0   /* not used yet */
104         int MakeInt();
105 #endif
106         STR_String Symbol2Str(int s);
107         void Term(int s);
108         int Priority(int optor);
109         CExpression *Ex(int i);
110         CExpression *Expr();
111         
112         
113 #ifdef WITH_CXX_GUARDEDALLOC
114 public:
115         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CParser"); }
116         void operator delete( void *mem ) { MEM_freeN(mem); }
117 #endif
118 };
119
120 #endif
121