Debian Codegraph @

src/tinyxpath/lex_util.h

raw symbols SCIP
1 /*
2 www.sourceforge.net/projects/tinyxpath
3 Copyright (c) 2002-2004 Yves Berquin ([email protected])
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any
7 damages arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any
10 purpose, including commercial applications, and to alter it and
11 redistribute it freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must
14 not claim that you wrote the original software. If you use this
15 software in a product, an acknowledgment in the product documentation
16 would be appreciated but is not required.
17
18 2. Altered source versions must be plainly marked as such, and
19 must not be misrepresented as being the original software.
20
21 3. This notice may not be removed or altered from any source
22 distribution.
23 */
24
25 /**
26 \file tinyutil.h
27 \author Yves Berquin
28 Miscellaneous utilities for the TinyXPath project
29 */
30
31 #ifndef __TINYUTIL_H
32 #define __TINYUTIL_H
33
34 #include "tinyxpath_conf.h"
35 #include "tinyxml.h"
36
37 #ifdef _MSC_VER
38 #pragma warning (disable : 4514)
39 #endif
40
41 namespace TinyXPath
42 {
43
44 typedef unsigned char _byte_;
45
46 /// Lexical XPath elements
47 enum lexico {
48 // single chars
49
50 lex_null, lex_none, lex_space, lex_digit, lex_bchar, lex_extend, lex_slash, lex_at,
51 lex_dot, lex_minus, lex_under, lex_colon, lex_scolon, lex_2_quote, lex_1_quote,
52 lex_dollar, lex_oparen, lex_cparen, lex_star, lex_plus, lex_comma, lex_lt,
53 lex_gt, lex_equal, lex_obrack, lex_cbrack, lex_orchar, lex_exclam,
54
55 // constructions
56
57 lex_ncname, lex_number, lex_literal, lex_2_colon, lex_2_slash, lex_2_dot, lex_not_equal,
58 lex_lt_equal, lex_gt_equal,
59
60 // keywords
61
62 lex_start_keyword,
63 lex_or = lex_start_keyword, lex_and, lex_mod, lex_div,
64
65 lex_start_axis_name,
66 lex_ancestor = lex_start_axis_name, lex_ancestor_or_self, lex_attribute, lex_child, lex_descendant,
67 lex_descendant_or_self, lex_following, lex_following_sibling, lex_namespace,
68 lex_parent, lex_preceding, lex_preceding_sibling, lex_self,
69 lex_end_axis_name = lex_self,
70
71 lex_processing_instruction,
72 lex_comment, lex_node, lex_text,
73 lex_end_keyword = lex_text
74
75 };
76
77 /// XPath constructions. The ordinals are rules of XPath or XML definitions in w3c
78 enum xpath_construct {
79 xpath_unknown = 0,
80 xpath_location_path = 1,
81 xpath_absolute_location_path = 2,
82 xpath_relative_location_path = 3,
83 xpath_step = 4,
84 xpath_axis_specifier = 5,
85 xpath_axis_name = 6,
86 xpath_node_test = 7,
87 xpath_predicate = 8,
88 xpath_predicate_expr = 9,
89 xpath_abbreviated_absolute_location_path = 10,
90 xpath_abbrieviated_step = 12,
91 xpath_abbreviated_axis_specifier = 13,
92 xpath_expr = 14,
93 xpath_primary_expr = 15,
94 xpath_function_call = 16,
95 xpath_argument = 17,
96 xpath_union_expr = 18,
97 xpath_path_expr = 19,
98 xpath_filter_expr = 20,
99 xpath_or_expr = 21,
100 xpath_and_expr = 22,
101 xpath_equality_expr = 23,
102 xpath_relational_expr = 24,
103 xpath_additive_expr = 25,
104 xpath_multiplicative_expr = 26,
105 xpath_unary_expr = 27,
106 xpath_multiply_operator = 34,
107 xpath_variable_reference = 36,
108 xpath_name_test = 37,
109 xpath_xml_q_name = 206,
110 xpath_xml_prefix = 207,
111 xpath_xml_local_part = 208};
112
113 enum xpath_sub {
114 xpath_absolute_location_path_slash_rel,
115 xpath_absolute_location_path_slash,
116 xpath_absolute_location_path_abbrev,
117 xpath_relative_location_path_rel_step,
118 xpath_relative_location_path_rel_double_slash_step,
119 xpath_relative_location_path_step,
120 xpath_step_abbrev,
121 xpath_step_full,
122 xpath_primary_expr_variable,
123 xpath_primary_expr_paren_expr,
124 xpath_primary_expr_literal,
125 xpath_primary_expr_number,
126 xpath_primary_expr_function_call,
127 xpath_name_test_star,
128 xpath_name_test_ncname,
129 xpath_name_test_qname,
130 xpath_xml_q_name_colon,
131 xpath_xml_q_name_simple,
132 xpath_axis_specifier_at,
133 xpath_axis_specifier_axis_name,
134 xpath_axis_specifier_empty,
135 xpath_path_expr_location_path,
136 xpath_path_expr_filter,
137 xpath_path_expr_slash,
138 xpath_path_expr_2_slash,
139 xpath_filter_expr_primary,
140 xpath_filter_expr_predicate,
141 xpath_location_path_rel,
142 xpath_location_path_abs,
143 xpath_node_test_reserved_keyword,
144 xpath_node_test_pi,
145 xpath_node_test_pi_lit,
146 xpath_node_test_name_test,
147 xpath_equality_expr_equal,
148 xpath_equality_expr_not_equal,
149 xpath_equality_expr_simple,
150 xpath_union_expr_simple,
151 xpath_union_expr_union,
152 xpath_additive_expr_simple,
153 xpath_additive_expr_plus,
154 xpath_additive_expr_minus,
155 xpath_additive_expr_more_plus,
156 xpath_additive_expr_more_minus,
157 xpath_or_expr_simple,
158 xpath_or_expr_or,
159 xpath_and_expr_simple,
160 xpath_and_expr_and,
161 xpath_relational_expr_simple,
162 xpath_relational_expr_lt,
163 xpath_relational_expr_gt,
164 xpath_relational_expr_lte,
165 xpath_relational_expr_gte,
166 xpath_unary_expr_simple,
167 xpath_unary_expr_minus,
168 xpath_multiplicative_expr_simple,
169 xpath_multiplicative_expr_star,
170 xpath_multiplicative_expr_div,
171 xpath_multiplicative_expr_mod,
172 dummy
173 } ;
174
175 extern const char * cp_disp_class_lex (lexico lex_in);
176 extern bool o_is_axis_name (lexico lex_test);
177 extern lexico lex_get_class (_byte_ b_in);
178 extern lexico lex_test_id (const _byte_ * bp_str, unsigned u_size, lexico);
179 extern TIXML_STRING S_remove_lead_trail (const char * cp_in);
180 extern void v_assign_int_to_string (TIXML_STRING & S_string, int i_val);
181 extern void v_assign_double_to_string (TIXML_STRING & S_string, double d_val);
182 #ifdef TINYXPATH_DEBUG
183 extern const char * cp_disp_construct (xpath_construct xc);
184 extern void v_generate_ascii_htm ();
185 extern const char * cp_disp_class (_byte_ b_in);
186 #endif
187 }
188
189 #endif