00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __SR_EXPRESSION_PARSER_H
00021 #define __SR_EXPRESSION_PARSER_H
00022
00023
00024
00025 #include "SR_SemprocPrefix.h"
00026 #include "SR_SemprocDefinitions.h"
00027
00028 #include "SR_LexicalAnalyzer.h"
00029 #include "SR_SymbolTable.h"
00030 #include "SR_ExpressionEvaluator.h"
00031
00032 #include "ptypes.h"
00033 #include "pstdio.h"
00034 #include "pmemory.h"
00035
00036 #include "ESR_ReturnCode.h"
00037 #include "ESR_Session.h"
00038 #include "SR_Grammar.h"
00039
00040 #define SR_SemprocFunctionPtr SR_GrammarDispatchFunction
00041
00045 enum
00046 {
00050 LHS_REQUIRED,
00051
00055 OP_ASSIGN_REQUIRED,
00056
00060 IDENTIFIER_REQUIRED,
00061
00065 OP_ANY_REQUIRED,
00066 };
00067
00072 typedef struct FunctionCallback_t
00073 {
00077 SR_SemprocFunctionPtr pfunction;
00078
00082 void* userData;
00083
00084 }
00085 FunctionCallback;
00086
00087
00091 typedef struct ExpressionParser_t
00092 {
00096 int state;
00097
00101 LCHAR lhs[MAX_STRING_LEN];
00102
00106 LCHAR op[MAX_STRING_LEN];
00107
00111 LCHAR identifiers[MAX_RHS_IDENTIFIERS][MAX_STRING_LEN];
00112
00116 size_t idCount;
00117
00122 LCHAR *ptokenBuf;
00123
00124
00125
00126
00127
00128
00132 HashMap *pfunctions;
00133
00137 FunctionCallback functions[MAX_FUNCTION_CALLBACKS];
00138
00142 FunctionCallback *next;
00143
00148 SR_SemprocFunctionPtr pfunction;
00149
00153 void* userData;
00154
00158 LCHAR functionName[MAX_STRING_LEN];
00159
00163 ESR_BOOL needToExecuteFunction;
00164 }
00165 ExpressionParser;
00166
00167
00173 SREC_SEMPROC_API ESR_ReturnCode EP_Init(ExpressionParser **self);
00174
00180 SREC_SEMPROC_API ESR_ReturnCode EP_Free(ExpressionParser *self);
00181
00190 SREC_SEMPROC_API ESR_ReturnCode EP_parse(ExpressionParser* self, LexicalAnalyzer* lexAnalyzer,
00191 SymbolTable* symtable, ExpressionEvaluator* evaluator,
00192 HashMap** hashmap);
00193
00202 SREC_SEMPROC_API ESR_ReturnCode EP_RegisterFunction(ExpressionParser* self, const LCHAR* name, void* data, SR_SemprocFunctionPtr pfunction);
00203
00210 SREC_SEMPROC_API ESR_ReturnCode EP_LookUpFunction(ExpressionParser* self, LCHAR* name, void** data, SR_SemprocFunctionPtr* pfunction);
00211
00212
00213 #endif