00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef _parser_h
00037 #define _parser_h
00038
00039 #ifndef _error_h
00040 #include "Error.h"
00041 #endif
00042
00043 #define YYDEBUG 1
00044 #undef YYERROR_VERBOSE
00045 #define YY_NO_UNPUT 1
00046
00047 #define ID_MAX 256
00048
00049 #ifndef TRUE
00050 #define TRUE 1
00051 #define FALSE 0
00052 #endif
00053
00065 struct parser_arg
00066 {
00067 void *_object;
00068 Error *_error;
00069 int _status;
00070
00071 parser_arg() : _object(0), _error(0), _status(1)
00072 {}
00073 parser_arg(void *obj) : _object(obj), _error(0), _status(1)
00074 {}
00075 virtual ~parser_arg()
00076 {
00077 if (_error) {
00078 delete _error; _error = 0;
00079 }
00080 }
00081
00082 void *object()
00083 {
00084 return _object;
00085 }
00086 void set_object(void *obj)
00087 {
00088 _object = obj;
00089 }
00090 Error *error()
00091 {
00092 return _error;
00093 }
00094 void set_error(Error *obj)
00095 {
00096 _error = obj;
00097 }
00098 int status()
00099 {
00100 return _status;
00101 }
00102 void set_status(int val = 0)
00103 {
00104 _status = val;
00105 }
00106 };
00107
00127 void parse_error(parser_arg *arg, const char *s, const int line_num = 0,
00128 const char *context = 0);
00129 void parse_error(const string &msg, const int line_num,
00130 const char *context = 0);
00132
00147 void save_str(char *dst, const char *src, const int line_num);
00148 void save_str(string &dst, const char *src, const int);
00149
00150 bool is_keyword(string id, const string &keyword);
00151
00163 int check_byte(const char *val);
00164
00172 int check_int16(const char *val);
00173 int check_uint16(const char *val);
00174 int check_int32(const char *val);
00175 int check_uint32(const char *val);
00176
00181 int check_float32(const char *val);
00182 int check_float64(const char *val);
00183
00188 int check_url(const char *val);
00189
00190 #endif // _parser_h
00191