parser.h

Go to the documentation of this file.
00001 
00002 // -*- mode: c++; c-basic-offset:4 -*-
00003 
00004 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
00005 // Access Protocol.
00006 
00007 // Copyright (c) 2002,2003 OPeNDAP, Inc.
00008 // Author: James Gallagher <jgallagher@opendap.org>
00009 //
00010 // This library is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU Lesser General Public
00012 // License as published by the Free Software Foundation; either
00013 // version 2.1 of the License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 //
00024 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
00025 
00026 // (c) COPYRIGHT URI/MIT 1994-1999
00027 // Please read the full copyright statement in the file COPYRIGHT_URI.
00028 //
00029 // Authors:
00030 //      jhrg,jimg       James Gallagher <jgallagher@gso.uri.edu>
00031 
00032 // Constants, types and function prototypes for use with the DAP parsers.
00033 //
00034 // jhrg 2/3/96
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;  // nominally a pointer to an object
00068     Error *_error;  // a pointer to an Error object
00069     int _status;  // parser 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 

Generated on Wed Jun 27 12:56:39 2007 for libdap++ by  doxygen 1.4.7