00001 /* 00002 www.sourceforge.net/projects/tinyxpath 00003 Copyright (c) 2002-2004 Yves Berquin (yvesb@users.sourceforge.net) 00004 00005 This software is provided 'as-is', without any express or implied 00006 warranty. In no event will the authors be held liable for any 00007 damages arising from the use of this software. 00008 00009 Permission is granted to anyone to use this software for any 00010 purpose, including commercial applications, and to alter it and 00011 redistribute it freely, subject to the following restrictions: 00012 00013 1. The origin of this software must not be misrepresented; you must 00014 not claim that you wrote the original software. If you use this 00015 software in a product, an acknowledgment in the product documentation 00016 would be appreciated but is not required. 00017 00018 2. Altered source versions must be plainly marked as such, and 00019 must not be misrepresented as being the original software. 00020 00021 3. This notice may not be removed or altered from any source 00022 distribution. 00023 */ 00024 00031 #ifndef __TINYSYNTAX_H 00032 #define __TINYSYNTAX_H 00033 00034 #include <assert.h> 00035 #include <stdio.h> 00036 #include "tokenlist.h" 00037 00038 namespace TinyXPath 00039 { 00040 00042 class syntax_error 00043 { 00044 public : 00045 syntax_error (const char * cp_mess = NULL) 00046 { 00047 if (cp_mess && strlen (cp_mess) < sizeof (ca_mess) - 1) 00048 strcpy (ca_mess, cp_mess); 00049 else 00050 ca_mess [0] = 0; 00051 } 00052 char ca_mess [200]; 00053 } ; 00054 00056 class syntax_overflow {} ; 00057 00060 class token_syntax_decoder : public token_list 00061 { 00062 protected : 00064 unsigned u_nb_recurs; 00065 bool o_recognize (xpath_construct xc_current, bool o_final); 00066 public : 00067 token_syntax_decoder () : token_list () {} 00068 virtual ~ token_syntax_decoder () {} 00069 void v_syntax_decode (); 00071 virtual void v_action (xpath_construct xc_rule, unsigned u_sub, 00072 unsigned u_variable = 0, const char * cp_literal = "") = 0; 00073 virtual int i_get_action_counter () = 0; 00074 } ; 00075 00076 } 00077 00078 #endif