html-template-pro 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. data/.autotest +9 -0
  2. data/ARTISTIC +131 -0
  3. data/History.txt +4 -0
  4. data/LGPL +504 -0
  5. data/Manifest.txt +221 -0
  6. data/README.rdoc +52 -0
  7. data/Rakefile +18 -0
  8. data/benchmark.rb +136 -0
  9. data/config/website.yml +2 -0
  10. data/ext/html/template/internal/Pro.xs +679 -0
  11. data/ext/html/template/internal/builtin_findfile.inc +361 -0
  12. data/ext/html/template/internal/calc.h +26 -0
  13. data/ext/html/template/internal/calc.inc +120 -0
  14. data/ext/html/template/internal/callback_stubs.inc +63 -0
  15. data/ext/html/template/internal/expr.c +2267 -0
  16. data/ext/html/template/internal/expr.y +476 -0
  17. data/ext/html/template/internal/expr_iface.c +94 -0
  18. data/ext/html/template/internal/exprpstr.h +36 -0
  19. data/ext/html/template/internal/exprpstr.inc +144 -0
  20. data/ext/html/template/internal/exprtool.h +99 -0
  21. data/ext/html/template/internal/exprtool.inc +289 -0
  22. data/ext/html/template/internal/exprtype.h +62 -0
  23. data/ext/html/template/internal/exprval.h +30 -0
  24. data/ext/html/template/internal/extconf.rb +6 -0
  25. data/ext/html/template/internal/internal.c +449 -0
  26. data/ext/html/template/internal/loadfile.h +11 -0
  27. data/ext/html/template/internal/loadfile.inc +171 -0
  28. data/ext/html/template/internal/pabidecl.h +54 -0
  29. data/ext/html/template/internal/pabstract.h +426 -0
  30. data/ext/html/template/internal/parse_expr.h +15 -0
  31. data/ext/html/template/internal/pbuffer.c +76 -0
  32. data/ext/html/template/internal/pbuffer.h +31 -0
  33. data/ext/html/template/internal/pmiscdef.h +54 -0
  34. data/ext/html/template/internal/pparam.h +101 -0
  35. data/ext/html/template/internal/ppport.h +1098 -0
  36. data/ext/html/template/internal/procore.c +1189 -0
  37. data/ext/html/template/internal/procore.h +18 -0
  38. data/ext/html/template/internal/proparam.c +443 -0
  39. data/ext/html/template/internal/proparam.h +571 -0
  40. data/ext/html/template/internal/proscope.h +32 -0
  41. data/ext/html/template/internal/proscope.inc +107 -0
  42. data/ext/html/template/internal/prostate.h +49 -0
  43. data/ext/html/template/internal/prostate.inc +24 -0
  44. data/ext/html/template/internal/provalue.h +14 -0
  45. data/ext/html/template/internal/pstring.h +60 -0
  46. data/ext/html/template/internal/pstrutils.h +25 -0
  47. data/ext/html/template/internal/pstrutils.inc +150 -0
  48. data/ext/html/template/internal/tagstack.h +30 -0
  49. data/ext/html/template/internal/tagstack.inc +65 -0
  50. data/ext/html/template/internal/tmpllog.c +62 -0
  51. data/ext/html/template/internal/tmpllog.h +27 -0
  52. data/ext/html/template/internal/tmplpro.h +218 -0
  53. data/ext/html/template/internal/tmplpro_version.c +35 -0
  54. data/lib/html/template/pro.rb +225 -0
  55. data/script/console +10 -0
  56. data/script/destroy +14 -0
  57. data/script/generate +14 -0
  58. data/script/txt2html +71 -0
  59. data/tasks/extconf.rake +13 -0
  60. data/tasks/extconf/tmplpro.rake +43 -0
  61. data/templates-Pro/a.incl +1 -0
  62. data/templates-Pro/empty.incl +0 -0
  63. data/templates-Pro/include/1/a.incl +1 -0
  64. data/templates-Pro/include/2.out +3 -0
  65. data/templates-Pro/include/2.tmpl +1 -0
  66. data/templates-Pro/include/2/a.incl +1 -0
  67. data/templates-Pro/include/3.tmpl +1 -0
  68. data/templates-Pro/include/4.tmpl +1 -0
  69. data/templates-Pro/include/a.incl +1 -0
  70. data/templates-Pro/test_broken.tmpl +25 -0
  71. data/templates-Pro/test_broken1.out +1 -0
  72. data/templates-Pro/test_broken1.tmpl +1 -0
  73. data/templates-Pro/test_esc1.out +4 -0
  74. data/templates-Pro/test_esc1.tmpl +4 -0
  75. data/templates-Pro/test_esc2.out +5 -0
  76. data/templates-Pro/test_esc2.tmpl +6 -0
  77. data/templates-Pro/test_esc3.out +4 -0
  78. data/templates-Pro/test_esc3.tmpl +4 -0
  79. data/templates-Pro/test_esc4.out +3 -0
  80. data/templates-Pro/test_esc4.tmpl +4 -0
  81. data/templates-Pro/test_expr1.out +26 -0
  82. data/templates-Pro/test_expr1.tmpl +26 -0
  83. data/templates-Pro/test_expr2.out +34 -0
  84. data/templates-Pro/test_expr2.tmpl +34 -0
  85. data/templates-Pro/test_expr3.out +6 -0
  86. data/templates-Pro/test_expr3.tmpl +6 -0
  87. data/templates-Pro/test_expr4.out +4 -0
  88. data/templates-Pro/test_expr4.tmpl +4 -0
  89. data/templates-Pro/test_expr5.out +18 -0
  90. data/templates-Pro/test_expr5.tmpl +18 -0
  91. data/templates-Pro/test_expr6.out +18 -0
  92. data/templates-Pro/test_expr6.tmpl +18 -0
  93. data/templates-Pro/test_expr7.out +44 -0
  94. data/templates-Pro/test_expr7.tmpl +20 -0
  95. data/templates-Pro/test_expr8.out +15 -0
  96. data/templates-Pro/test_expr8.tmpl +15 -0
  97. data/templates-Pro/test_if1.out +25 -0
  98. data/templates-Pro/test_if1.tmpl +28 -0
  99. data/templates-Pro/test_if2.out +17 -0
  100. data/templates-Pro/test_if2.tmpl +25 -0
  101. data/templates-Pro/test_if3.out +12 -0
  102. data/templates-Pro/test_if3.tmpl +14 -0
  103. data/templates-Pro/test_if4.out +15 -0
  104. data/templates-Pro/test_if4.tmpl +31 -0
  105. data/templates-Pro/test_if5.out +16 -0
  106. data/templates-Pro/test_if5.tmpl +16 -0
  107. data/templates-Pro/test_if6.out +15 -0
  108. data/templates-Pro/test_if6.tmpl +31 -0
  109. data/templates-Pro/test_if7.out +14 -0
  110. data/templates-Pro/test_if7.tmpl +18 -0
  111. data/templates-Pro/test_include1.out +23 -0
  112. data/templates-Pro/test_include1.tmpl +7 -0
  113. data/templates-Pro/test_include2.out +120 -0
  114. data/templates-Pro/test_include2.tmpl +10 -0
  115. data/templates-Pro/test_include3.out +8 -0
  116. data/templates-Pro/test_include3.tmpl +8 -0
  117. data/templates-Pro/test_include4.out +7 -0
  118. data/templates-Pro/test_include4.tmpl +6 -0
  119. data/templates-Pro/test_include5.out +7 -0
  120. data/templates-Pro/test_include5.tmpl +6 -0
  121. data/templates-Pro/test_loop1.erb +17 -0
  122. data/templates-Pro/test_loop1.out +12 -0
  123. data/templates-Pro/test_loop1.tmpl +16 -0
  124. data/templates-Pro/test_loop2.erb +19 -0
  125. data/templates-Pro/test_loop2.out +40 -0
  126. data/templates-Pro/test_loop2.tmpl +19 -0
  127. data/templates-Pro/test_loop3.out +38 -0
  128. data/templates-Pro/test_loop3.tmpl +40 -0
  129. data/templates-Pro/test_loop4.out +44 -0
  130. data/templates-Pro/test_loop4.tmpl +20 -0
  131. data/templates-Pro/test_loop5.out +9 -0
  132. data/templates-Pro/test_loop5.tmpl +11 -0
  133. data/templates-Pro/test_loop6.out +33 -0
  134. data/templates-Pro/test_loop6.tmpl +15 -0
  135. data/templates-Pro/test_malloc.tmpl +1 -0
  136. data/templates-Pro/test_userfunc1.out +14 -0
  137. data/templates-Pro/test_userfunc1.tmpl +14 -0
  138. data/templates-Pro/test_userfunc2.out +35 -0
  139. data/templates-Pro/test_userfunc2.tmpl +5 -0
  140. data/templates-Pro/test_userfunc3.out +5 -0
  141. data/templates-Pro/test_userfunc3.tmpl +5 -0
  142. data/templates-Pro/test_userfunc4.out +10 -0
  143. data/templates-Pro/test_userfunc4.tmpl +10 -0
  144. data/templates-Pro/test_userfunc5.out +4 -0
  145. data/templates-Pro/test_userfunc5.tmpl +4 -0
  146. data/templates-Pro/test_userfunc6.out +4 -0
  147. data/templates-Pro/test_userfunc6.tmpl +4 -0
  148. data/templates-Pro/test_var1.erb +23 -0
  149. data/templates-Pro/test_var1.out +20 -0
  150. data/templates-Pro/test_var1.tmpl +23 -0
  151. data/templates-Pro/test_var2.erb +7 -0
  152. data/templates-Pro/test_var2.out +6 -0
  153. data/templates-Pro/test_var2.tmpl +7 -0
  154. data/templates-Pro/test_var3.out +14 -0
  155. data/templates-Pro/test_var3.tmpl +16 -0
  156. data/templates/case_loop.tmpl +3 -0
  157. data/templates/context.tmpl +3 -0
  158. data/templates/counter.tmpl +2 -0
  159. data/templates/default.tmpl +1 -0
  160. data/templates/default_escape.tmpl +4 -0
  161. data/templates/double_loop.tmpl +7 -0
  162. data/templates/escape.tmpl +5 -0
  163. data/templates/global-loops.tmpl +9 -0
  164. data/templates/globals.tmpl +11 -0
  165. data/templates/if.tmpl +7 -0
  166. data/templates/ifelse.tmpl +6 -0
  167. data/templates/include.tmpl +14 -0
  168. data/templates/include_path/a.tmpl +2 -0
  169. data/templates/include_path/b.tmpl +1 -0
  170. data/templates/include_path/inner.tmpl +1 -0
  171. data/templates/include_path/one.tmpl +2 -0
  172. data/templates/include_path2/inner.tmpl +1 -0
  173. data/templates/included.tmpl +4 -0
  174. data/templates/included2.tmpl +3 -0
  175. data/templates/js.tmpl +1 -0
  176. data/templates/long_loops.tmpl +307 -0
  177. data/templates/loop-context.tmpl +2 -0
  178. data/templates/loop-if.tmpl +9 -0
  179. data/templates/medium.tmpl +217 -0
  180. data/templates/multiline_tags.tmpl +7 -0
  181. data/templates/newline_test1.tmpl +1 -0
  182. data/templates/newline_test2.tmpl +1 -0
  183. data/templates/other-loop.tmpl +7 -0
  184. data/templates/outer.tmpl +3 -0
  185. data/templates/query-test.tmpl +21 -0
  186. data/templates/query-test2.tmpl +12 -0
  187. data/templates/recursive.tmpl +2 -0
  188. data/templates/searchpath/included.tmpl +4 -0
  189. data/templates/searchpath/three.tmpl +1 -0
  190. data/templates/searchpath/two.tmpl +2 -0
  191. data/templates/simple-loop-nonames.tmpl +13 -0
  192. data/templates/simple-loop.tmpl +12 -0
  193. data/templates/simple.tmpl +9 -0
  194. data/templates/unless.tmpl +5 -0
  195. data/templates/urlescape.tmpl +3 -0
  196. data/templates/vanguard1.tmpl +2 -0
  197. data/templates/vanguard2.tmpl +3 -0
  198. data/test/templates/complex.tmpl +24 -0
  199. data/test/templates/foo.tmpl +6 -0
  200. data/test/templates/func.tmpl +2 -0
  201. data/test/templates/loop.tmpl +14 -0
  202. data/test/templates/negative.tmpl +1 -0
  203. data/test/templates/numerics.tmpl +6 -0
  204. data/test/templates/register.tmpl +2 -0
  205. data/test/test_basic.rb +23 -0
  206. data/test/test_coderefs.rb +16 -0
  207. data/test/test_complex.rb +106 -0
  208. data/test/test_helper.rb +3 -0
  209. data/test/test_html_template.rb +583 -0
  210. data/test/test_html_template_internal_extn.rb +10 -0
  211. data/test/test_html_template_pro.rb +177 -0
  212. data/test/test_path_like_variable_scope.rb +59 -0
  213. data/test/test_random.rb +21 -0
  214. data/test/test_realloc.rb +16 -0
  215. data/test/test_register.rb +25 -0
  216. data/test/test_tmplpro.rb +9 -0
  217. data/test/tests.rb +9 -0
  218. data/website/index.txt +57 -0
  219. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  220. data/website/stylesheets/screen.css +159 -0
  221. data/website/template.html.erb +50 -0
  222. metadata +303 -0
@@ -0,0 +1,63 @@
1
+ /*
2
+ * File: callback_stubs.c
3
+ * Author: Igor Vlasenko <vlasenko@imath.kiev.ua>
4
+ * Created: Tue Jul 14 22:47:11 2009
5
+ */
6
+
7
+ #include "pstring.h"
8
+ #include "pbuffer.h"
9
+
10
+ struct builtin_writer_state {
11
+ size_t size;
12
+ pbuffer buffer;
13
+ };
14
+
15
+
16
+ /* writer_functype stub */
17
+ /* endnext points on next character to end of interval as in c++ */
18
+ static void BACKCALL stub_write_chars_to_stdout (ABSTRACT_WRITER* none,const char* begin, const char* endnext) {
19
+ if (endnext==begin) return;
20
+ if (0==fwrite(begin, sizeof(char), endnext-begin, stdout)) {
21
+ tmpl_log(TMPL_LOG_ERROR,"find_file_func stub: can't fwrite to stdout\n");
22
+ }
23
+ }
24
+
25
+ /* writer_functype stub */
26
+ /* endnext points at the character next to the end of the interval */
27
+ static void BACKCALL stub_write_chars_to_pbuffer (ABSTRACT_WRITER* state,const char* begin, const char* endnext) {
28
+ size_t addlen = endnext-begin;
29
+ size_t oldlen;
30
+ pbuffer* pbuf;
31
+ if (addlen==0) return;
32
+ oldlen = ((struct builtin_writer_state*) state)->size;
33
+ pbuf = &((struct builtin_writer_state*) state)->buffer;
34
+ pbuffer_resize(pbuf, oldlen + addlen + 1);
35
+ memcpy(pbuffer_string(pbuf) + oldlen, begin, addlen);
36
+ ((struct builtin_writer_state*) state)->size += addlen;
37
+ }
38
+
39
+ static ABSTRACT_USERFUNC* BACKCALL stub_is_expr_userfnc_func (ABSTRACT_FUNCMAP* af, PSTRING name) {
40
+ tmpl_log(TMPL_LOG_ERROR,"is_expr_userfnc_func stub: EXPR is not initialized properly. user func dispatcher was not supplied.");
41
+ return NULL;
42
+ }
43
+
44
+ static PSTRING BACKCALL stub_load_file_func (ABSTRACT_FILTER* none, const char* filename) {
45
+ tmpl_log(TMPL_LOG_ERROR,"load_file_func stub: callback function for filters was not specified.");
46
+ return mmap_load_file(filename);
47
+ }
48
+
49
+ static int BACKCALL stub_unload_file_func (ABSTRACT_FILTER* none, PSTRING memarea) {
50
+ tmpl_log(TMPL_LOG_ERROR,"unload_file_func stub: callback function for filters was not specified.");
51
+ return mmap_unload_file(memarea);
52
+ }
53
+
54
+ static int BACKCALL stub_get_ABSTRACT_ARRAY_length_func (ABSTRACT_DATASTATE* none1, ABSTRACT_ARRAY* none) {
55
+ return -1; /* treat all arrays as arrays of undefined length */
56
+ }
57
+
58
+
59
+ /*
60
+ * Local Variables:
61
+ * mode: c
62
+ * End:
63
+ */
@@ -0,0 +1,2267 @@
1
+ /* A Bison parser, made by GNU Bison 2.3. */
2
+
3
+ /* Skeleton implementation for Bison's Yacc-like parsers in C
4
+
5
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6
+ Free Software Foundation, Inc.
7
+
8
+ This program is free software; you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation; either version 2, or (at your option)
11
+ any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program; if not, write to the Free Software
20
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
21
+ Boston, MA 02110-1301, USA. */
22
+
23
+ /* As a special exception, you may create a larger work that contains
24
+ part or all of the Bison parser skeleton and distribute that work
25
+ under terms of your choice, so long as that work isn't itself a
26
+ parser generator using the skeleton or a modified version thereof
27
+ as a parser skeleton. Alternatively, if you modify or redistribute
28
+ the parser skeleton itself, you may (at your option) remove this
29
+ special exception, which will cause the skeleton and the resulting
30
+ Bison output files to be licensed under the GNU General Public
31
+ License without this special exception.
32
+
33
+ This special exception was added by the Free Software Foundation in
34
+ version 2.2 of Bison. */
35
+
36
+ /* C LALR(1) parser skeleton written by Richard Stallman, by
37
+ simplifying the original so-called "semantic" parser. */
38
+
39
+ /* All symbols defined below should begin with yy or YY, to avoid
40
+ infringing on user name space. This should be done even for local
41
+ variables, as they might otherwise be expanded by user macros.
42
+ There are some unavoidable exceptions within include files to
43
+ define necessary library symbols; they are noted "INFRINGES ON
44
+ USER NAME SPACE" below. */
45
+
46
+ /* Identify Bison output. */
47
+ #define YYBISON 1
48
+
49
+ /* Bison version. */
50
+ #define YYBISON_VERSION "2.3"
51
+
52
+ /* Skeleton name. */
53
+ #define YYSKELETON_NAME "yacc.c"
54
+
55
+ /* Pure parsers. */
56
+ #define YYPURE 1
57
+
58
+ /* Using locations. */
59
+ #define YYLSP_NEEDED 0
60
+
61
+
62
+
63
+ /* Tokens. */
64
+ #ifndef YYTOKENTYPE
65
+ # define YYTOKENTYPE
66
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
67
+ know about them. */
68
+ enum yytokentype {
69
+ NUM = 258,
70
+ EXTFUNC = 259,
71
+ VAR = 260,
72
+ BUILTIN_FNC_DD = 261,
73
+ BUILTIN_FNC_DDD = 262,
74
+ BUILTIN_FNC_EE = 263,
75
+ OR = 264,
76
+ AND = 265,
77
+ strCMP = 266,
78
+ strNE = 267,
79
+ strEQ = 268,
80
+ strLE = 269,
81
+ strLT = 270,
82
+ strGE = 271,
83
+ strGT = 272,
84
+ numNE = 273,
85
+ numEQ = 274,
86
+ numLE = 275,
87
+ numLT = 276,
88
+ numGE = 277,
89
+ numGT = 278,
90
+ reNOTLIKE = 279,
91
+ reLIKE = 280,
92
+ NEG = 281,
93
+ NOT = 282
94
+ };
95
+ #endif
96
+ /* Tokens. */
97
+ #define NUM 258
98
+ #define EXTFUNC 259
99
+ #define VAR 260
100
+ #define BUILTIN_FNC_DD 261
101
+ #define BUILTIN_FNC_DDD 262
102
+ #define BUILTIN_FNC_EE 263
103
+ #define OR 264
104
+ #define AND 265
105
+ #define strCMP 266
106
+ #define strNE 267
107
+ #define strEQ 268
108
+ #define strLE 269
109
+ #define strLT 270
110
+ #define strGE 271
111
+ #define strGT 272
112
+ #define numNE 273
113
+ #define numEQ 274
114
+ #define numLE 275
115
+ #define numLT 276
116
+ #define numGE 277
117
+ #define numGT 278
118
+ #define reNOTLIKE 279
119
+ #define reLIKE 280
120
+ #define NEG 281
121
+ #define NOT 282
122
+
123
+
124
+
125
+
126
+ /* Copy the first part of user declarations. */
127
+ #line 7 "expr.y"
128
+
129
+ #include <math.h> /* For math functions, cos(), sin(), etc. */
130
+ #include <stdio.h> /* for printf */
131
+ #include <stdlib.h> /* for malloc */
132
+ #include <ctype.h> /* for yylex alnum */
133
+ #include "calc.h" /* Contains definition of `symrec'. */
134
+ #include "tmpllog.h"
135
+ #include "pabstract.h"
136
+ #include "prostate.h"
137
+ #include "provalue.h"
138
+ #include "pparam.h"
139
+ #include "pmiscdef.h"
140
+ /* for expr-specific only */
141
+ #include "exprtool.h"
142
+ #include "exprpstr.h"
143
+ #include "parse_expr.h"
144
+ /* Remember unsigned char assert on win32
145
+ Debug Assertion Failed! f:\dd\vctools\crt_bld\self_x86\crt\src \isctype.c Expression:(unsigned)(c + 1) <= 256
146
+ */
147
+
148
+
149
+ /* Enabling traces. */
150
+ #ifndef YYDEBUG
151
+ # define YYDEBUG 0
152
+ #endif
153
+
154
+ /* Enabling verbose error messages. */
155
+ #ifdef YYERROR_VERBOSE
156
+ # undef YYERROR_VERBOSE
157
+ # define YYERROR_VERBOSE 1
158
+ #else
159
+ # define YYERROR_VERBOSE 0
160
+ #endif
161
+
162
+ /* Enabling the token table. */
163
+ #ifndef YYTOKEN_TABLE
164
+ # define YYTOKEN_TABLE 0
165
+ #endif
166
+
167
+ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
168
+ typedef union YYSTYPE
169
+ #line 27 "expr.y"
170
+ {
171
+ struct exprval numval; /* For returning numbers. */
172
+ const symrec_const *tptr; /* For returning symbol-table pointers. */
173
+ struct user_func_call extfunc; /* for user-defined function name */
174
+ }
175
+ /* Line 193 of yacc.c. */
176
+ #line 177 "y.tab.c"
177
+ YYSTYPE;
178
+ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
179
+ # define YYSTYPE_IS_DECLARED 1
180
+ # define YYSTYPE_IS_TRIVIAL 1
181
+ #endif
182
+
183
+
184
+
185
+ /* Copy the second part of user declarations. */
186
+ #line 32 "expr.y"
187
+
188
+ /* the second section is required as we use YYSTYPE here */
189
+ static void yyerror (struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr, char const *);
190
+ static int yylex (YYSTYPE *lvalp, struct tmplpro_state* state, struct expr_parser* exprobj);
191
+
192
+
193
+ /* Line 216 of yacc.c. */
194
+ #line 195 "y.tab.c"
195
+
196
+ #ifdef short
197
+ # undef short
198
+ #endif
199
+
200
+ #ifdef YYTYPE_UINT8
201
+ typedef YYTYPE_UINT8 yytype_uint8;
202
+ #else
203
+ typedef unsigned char yytype_uint8;
204
+ #endif
205
+
206
+ #ifdef YYTYPE_INT8
207
+ typedef YYTYPE_INT8 yytype_int8;
208
+ #elif (defined __STDC__ || defined __C99__FUNC__ \
209
+ || defined __cplusplus || defined _MSC_VER)
210
+ typedef signed char yytype_int8;
211
+ #else
212
+ typedef short int yytype_int8;
213
+ #endif
214
+
215
+ #ifdef YYTYPE_UINT16
216
+ typedef YYTYPE_UINT16 yytype_uint16;
217
+ #else
218
+ typedef unsigned short int yytype_uint16;
219
+ #endif
220
+
221
+ #ifdef YYTYPE_INT16
222
+ typedef YYTYPE_INT16 yytype_int16;
223
+ #else
224
+ typedef short int yytype_int16;
225
+ #endif
226
+
227
+ #ifndef YYSIZE_T
228
+ # ifdef __SIZE_TYPE__
229
+ # define YYSIZE_T __SIZE_TYPE__
230
+ # elif defined size_t
231
+ # define YYSIZE_T size_t
232
+ # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
233
+ || defined __cplusplus || defined _MSC_VER)
234
+ # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
235
+ # define YYSIZE_T size_t
236
+ # else
237
+ # define YYSIZE_T unsigned int
238
+ # endif
239
+ #endif
240
+
241
+ #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
242
+
243
+ #ifndef YY_
244
+ # if YYENABLE_NLS
245
+ # if ENABLE_NLS
246
+ # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
247
+ # define YY_(msgid) dgettext ("bison-runtime", msgid)
248
+ # endif
249
+ # endif
250
+ # ifndef YY_
251
+ # define YY_(msgid) msgid
252
+ # endif
253
+ #endif
254
+
255
+ /* Suppress unused-variable warnings by "using" E. */
256
+ #if ! defined lint || defined __GNUC__
257
+ # define YYUSE(e) ((void) (e))
258
+ #else
259
+ # define YYUSE(e) /* empty */
260
+ #endif
261
+
262
+ /* Identity function, used to suppress warnings about constant conditions. */
263
+ #ifndef lint
264
+ # define YYID(n) (n)
265
+ #else
266
+ #if (defined __STDC__ || defined __C99__FUNC__ \
267
+ || defined __cplusplus || defined _MSC_VER)
268
+ static int
269
+ YYID (int i)
270
+ #else
271
+ static int
272
+ YYID (i)
273
+ int i;
274
+ #endif
275
+ {
276
+ return i;
277
+ }
278
+ #endif
279
+
280
+ #if ! defined yyoverflow || YYERROR_VERBOSE
281
+
282
+ /* The parser invokes alloca or malloc; define the necessary symbols. */
283
+
284
+ # ifdef YYSTACK_USE_ALLOCA
285
+ # if YYSTACK_USE_ALLOCA
286
+ # ifdef __GNUC__
287
+ # define YYSTACK_ALLOC __builtin_alloca
288
+ # elif defined __BUILTIN_VA_ARG_INCR
289
+ # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
290
+ # elif defined _AIX
291
+ # define YYSTACK_ALLOC __alloca
292
+ # elif defined _MSC_VER
293
+ # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
294
+ # define alloca _alloca
295
+ # else
296
+ # define YYSTACK_ALLOC alloca
297
+ # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
298
+ || defined __cplusplus || defined _MSC_VER)
299
+ # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
300
+ # ifndef _STDLIB_H
301
+ # define _STDLIB_H 1
302
+ # endif
303
+ # endif
304
+ # endif
305
+ # endif
306
+ # endif
307
+
308
+ # ifdef YYSTACK_ALLOC
309
+ /* Pacify GCC's `empty if-body' warning. */
310
+ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
311
+ # ifndef YYSTACK_ALLOC_MAXIMUM
312
+ /* The OS might guarantee only one guard page at the bottom of the stack,
313
+ and a page size can be as small as 4096 bytes. So we cannot safely
314
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
315
+ to allow for a few compiler-allocated temporary stack slots. */
316
+ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
317
+ # endif
318
+ # else
319
+ # define YYSTACK_ALLOC YYMALLOC
320
+ # define YYSTACK_FREE YYFREE
321
+ # ifndef YYSTACK_ALLOC_MAXIMUM
322
+ # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
323
+ # endif
324
+ # if (defined __cplusplus && ! defined _STDLIB_H \
325
+ && ! ((defined YYMALLOC || defined malloc) \
326
+ && (defined YYFREE || defined free)))
327
+ # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
328
+ # ifndef _STDLIB_H
329
+ # define _STDLIB_H 1
330
+ # endif
331
+ # endif
332
+ # ifndef YYMALLOC
333
+ # define YYMALLOC malloc
334
+ # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
335
+ || defined __cplusplus || defined _MSC_VER)
336
+ void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
337
+ # endif
338
+ # endif
339
+ # ifndef YYFREE
340
+ # define YYFREE free
341
+ # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
342
+ || defined __cplusplus || defined _MSC_VER)
343
+ void free (void *); /* INFRINGES ON USER NAME SPACE */
344
+ # endif
345
+ # endif
346
+ # endif
347
+ #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
348
+
349
+
350
+ #if (! defined yyoverflow \
351
+ && (! defined __cplusplus \
352
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
353
+
354
+ /* A type that is properly aligned for any stack member. */
355
+ union yyalloc
356
+ {
357
+ yytype_int16 yyss;
358
+ YYSTYPE yyvs;
359
+ };
360
+
361
+ /* The size of the maximum gap between one aligned stack and the next. */
362
+ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
363
+
364
+ /* The size of an array large to enough to hold all stacks, each with
365
+ N elements. */
366
+ # define YYSTACK_BYTES(N) \
367
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
368
+ + YYSTACK_GAP_MAXIMUM)
369
+
370
+ /* Copy COUNT objects from FROM to TO. The source and destination do
371
+ not overlap. */
372
+ # ifndef YYCOPY
373
+ # if defined __GNUC__ && 1 < __GNUC__
374
+ # define YYCOPY(To, From, Count) \
375
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
376
+ # else
377
+ # define YYCOPY(To, From, Count) \
378
+ do \
379
+ { \
380
+ YYSIZE_T yyi; \
381
+ for (yyi = 0; yyi < (Count); yyi++) \
382
+ (To)[yyi] = (From)[yyi]; \
383
+ } \
384
+ while (YYID (0))
385
+ # endif
386
+ # endif
387
+
388
+ /* Relocate STACK from its old location to the new one. The
389
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
390
+ elements in the stack, and YYPTR gives the new location of the
391
+ stack. Advance YYPTR to a properly aligned location for the next
392
+ stack. */
393
+ # define YYSTACK_RELOCATE(Stack) \
394
+ do \
395
+ { \
396
+ YYSIZE_T yynewbytes; \
397
+ YYCOPY (&yyptr->Stack, Stack, yysize); \
398
+ Stack = &yyptr->Stack; \
399
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
400
+ yyptr += yynewbytes / sizeof (*yyptr); \
401
+ } \
402
+ while (YYID (0))
403
+
404
+ #endif
405
+
406
+ /* YYFINAL -- State number of the termination state. */
407
+ #define YYFINAL 22
408
+ /* YYLAST -- Last index in YYTABLE. */
409
+ #define YYLAST 375
410
+
411
+ /* YYNTOKENS -- Number of terminals. */
412
+ #define YYNTOKENS 40
413
+ /* YYNNTS -- Number of nonterminals. */
414
+ #define YYNNTS 4
415
+ /* YYNRULES -- Number of rules. */
416
+ #define YYNRULES 39
417
+ /* YYNRULES -- Number of states. */
418
+ #define YYNSTATES 84
419
+
420
+ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
421
+ #define YYUNDEFTOK 2
422
+ #define YYMAXUTOK 282
423
+
424
+ #define YYTRANSLATE(YYX) \
425
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
426
+
427
+ /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
428
+ static const yytype_uint8 yytranslate[] =
429
+ {
430
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
432
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
433
+ 2, 2, 2, 33, 2, 2, 2, 32, 2, 2,
434
+ 38, 37, 30, 29, 39, 28, 2, 31, 2, 2,
435
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
436
+ 18, 2, 19, 2, 2, 2, 2, 2, 2, 2,
437
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
438
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439
+ 2, 2, 2, 2, 36, 2, 2, 2, 2, 2,
440
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
441
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
442
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
443
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
444
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
446
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
447
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
448
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
449
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
450
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
451
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
452
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
453
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
454
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
455
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
456
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
457
+ 15, 16, 17, 20, 21, 22, 23, 24, 25, 26,
458
+ 27, 34, 35
459
+ };
460
+
461
+ #if YYDEBUG
462
+ /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
463
+ YYRHS. */
464
+ static const yytype_uint8 yyprhs[] =
465
+ {
466
+ 0, 0, 3, 5, 7, 9, 12, 16, 20, 25,
467
+ 32, 37, 41, 45, 49, 53, 57, 60, 64, 68,
468
+ 72, 76, 80, 84, 88, 92, 96, 99, 102, 106,
469
+ 110, 114, 118, 122, 126, 130, 134, 138, 142, 146
470
+ };
471
+
472
+ /* YYRHS -- A `-1'-separated list of the rules' RHS. */
473
+ static const yytype_int8 yyrhs[] =
474
+ {
475
+ 41, 0, -1, 42, -1, 3, -1, 5, -1, 43,
476
+ 37, -1, 4, 38, 37, -1, 8, 38, 37, -1,
477
+ 6, 38, 42, 37, -1, 7, 38, 42, 39, 42,
478
+ 37, -1, 8, 38, 42, 37, -1, 42, 29, 42,
479
+ -1, 42, 28, 42, -1, 42, 30, 42, -1, 42,
480
+ 32, 42, -1, 42, 31, 42, -1, 28, 42, -1,
481
+ 42, 36, 42, -1, 42, 10, 42, -1, 42, 9,
482
+ 42, -1, 42, 24, 42, -1, 42, 22, 42, -1,
483
+ 42, 20, 42, -1, 42, 21, 42, -1, 42, 19,
484
+ 42, -1, 42, 18, 42, -1, 33, 42, -1, 35,
485
+ 42, -1, 38, 42, 37, -1, 42, 11, 42, -1,
486
+ 42, 16, 42, -1, 42, 14, 42, -1, 42, 12,
487
+ 42, -1, 42, 13, 42, -1, 42, 17, 42, -1,
488
+ 42, 15, 42, -1, 42, 27, 42, -1, 42, 26,
489
+ 42, -1, 4, 38, 42, -1, 43, 39, 42, -1
490
+ };
491
+
492
+ /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
493
+ static const yytype_uint8 yyrline[] =
494
+ {
495
+ 0, 59, 59, 67, 68, 70, 74, 79, 86, 92,
496
+ 98, 102, 103, 104, 105, 136, 148, 159, 165, 166,
497
+ 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
498
+ 180, 181, 182, 183, 184, 185, 186, 187, 190, 195
499
+ };
500
+ #endif
501
+
502
+ #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
503
+ /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
504
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
505
+ static const char *const yytname[] =
506
+ {
507
+ "$end", "error", "$undefined", "NUM", "EXTFUNC", "VAR",
508
+ "BUILTIN_FNC_DD", "BUILTIN_FNC_DDD", "BUILTIN_FNC_EE", "OR", "AND",
509
+ "strCMP", "strNE", "strEQ", "strLE", "strLT", "strGE", "strGT", "'<'",
510
+ "'>'", "numNE", "numEQ", "numLE", "numLT", "numGE", "numGT", "reNOTLIKE",
511
+ "reLIKE", "'-'", "'+'", "'*'", "'/'", "'%'", "'!'", "NEG", "NOT", "'^'",
512
+ "')'", "'('", "','", "$accept", "line", "numEXP", "arglist", 0
513
+ };
514
+ #endif
515
+
516
+ # ifdef YYPRINT
517
+ /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
518
+ token YYLEX-NUM. */
519
+ static const yytype_uint16 yytoknum[] =
520
+ {
521
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
522
+ 265, 266, 267, 268, 269, 270, 271, 272, 60, 62,
523
+ 273, 274, 275, 276, 277, 278, 279, 280, 45, 43,
524
+ 42, 47, 37, 33, 281, 282, 94, 41, 40, 44
525
+ };
526
+ # endif
527
+
528
+ /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
529
+ static const yytype_uint8 yyr1[] =
530
+ {
531
+ 0, 40, 41, 42, 42, 42, 42, 42, 42, 42,
532
+ 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
533
+ 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
534
+ 42, 42, 42, 42, 42, 42, 42, 42, 43, 43
535
+ };
536
+
537
+ /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
538
+ static const yytype_uint8 yyr2[] =
539
+ {
540
+ 0, 2, 1, 1, 1, 2, 3, 3, 4, 6,
541
+ 4, 3, 3, 3, 3, 3, 2, 3, 3, 3,
542
+ 3, 3, 3, 3, 3, 3, 2, 2, 3, 3,
543
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
544
+ };
545
+
546
+ /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
547
+ STATE-NUM when YYTABLE doesn't specify something else to do. Zero
548
+ means the default is an error. */
549
+ static const yytype_uint8 yydefact[] =
550
+ {
551
+ 0, 3, 0, 4, 0, 0, 0, 0, 0, 0,
552
+ 0, 0, 2, 0, 0, 0, 0, 0, 16, 26,
553
+ 27, 0, 1, 0, 0, 0, 0, 0, 0, 0,
554
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
555
+ 0, 0, 0, 0, 0, 0, 5, 0, 6, 38,
556
+ 0, 0, 7, 0, 28, 19, 18, 29, 32, 33,
557
+ 31, 35, 30, 34, 25, 24, 22, 23, 21, 20,
558
+ 37, 36, 12, 11, 13, 15, 14, 17, 39, 8,
559
+ 0, 10, 0, 9
560
+ };
561
+
562
+ /* YYDEFGOTO[NTERM-NUM]. */
563
+ static const yytype_int8 yydefgoto[] =
564
+ {
565
+ -1, 11, 12, 13
566
+ };
567
+
568
+ /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
569
+ STATE-NUM. */
570
+ #define YYPACT_NINF -34
571
+ static const yytype_int16 yypact[] =
572
+ {
573
+ 53, -34, -27, -34, -26, -25, -24, 53, 53, 53,
574
+ 53, 5, 230, -33, 39, 53, 53, 47, -21, -21,
575
+ -21, 114, -34, 53, 53, 53, 53, 53, 53, 53,
576
+ 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
577
+ 53, 53, 53, 53, 53, 53, -34, 53, -34, 230,
578
+ 143, 83, -34, 172, -34, 257, 283, 309, 309, 309,
579
+ 309, 309, 309, 309, 328, 328, 328, 328, 328, 328,
580
+ 339, 339, 32, 32, -21, -21, -21, -21, 230, -34,
581
+ 53, -34, 201, -34
582
+ };
583
+
584
+ /* YYPGOTO[NTERM-NUM]. */
585
+ static const yytype_int8 yypgoto[] =
586
+ {
587
+ -34, -34, -7, -34
588
+ };
589
+
590
+ /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
591
+ positive, shift that token. If negative, reduce the rule which
592
+ number is the opposite. If zero, do what YYDEFACT says.
593
+ If YYTABLE_NINF, syntax error. */
594
+ #define YYTABLE_NINF -1
595
+ static const yytype_int8 yytable[] =
596
+ {
597
+ 18, 19, 20, 21, 46, 22, 47, 49, 50, 51,
598
+ 53, 14, 15, 16, 17, 45, 55, 56, 57, 58,
599
+ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
600
+ 69, 70, 71, 72, 73, 74, 75, 76, 77, 0,
601
+ 78, 0, 1, 2, 3, 4, 5, 6, 0, 0,
602
+ 1, 2, 3, 4, 5, 6, 1, 2, 3, 4,
603
+ 5, 6, 42, 43, 44, 0, 0, 7, 45, 0,
604
+ 0, 0, 8, 82, 9, 7, 48, 10, 0, 0,
605
+ 8, 7, 9, 0, 52, 10, 8, 0, 9, 0,
606
+ 0, 10, 23, 24, 25, 26, 27, 28, 29, 30,
607
+ 31, 32, 33, 34, 35, 36, 0, 37, 0, 38,
608
+ 39, 40, 41, 42, 43, 44, 0, 0, 0, 45,
609
+ 0, 0, 80, 23, 24, 25, 26, 27, 28, 29,
610
+ 30, 31, 32, 33, 34, 35, 36, 0, 37, 0,
611
+ 38, 39, 40, 41, 42, 43, 44, 0, 0, 0,
612
+ 45, 54, 23, 24, 25, 26, 27, 28, 29, 30,
613
+ 31, 32, 33, 34, 35, 36, 0, 37, 0, 38,
614
+ 39, 40, 41, 42, 43, 44, 0, 0, 0, 45,
615
+ 79, 23, 24, 25, 26, 27, 28, 29, 30, 31,
616
+ 32, 33, 34, 35, 36, 0, 37, 0, 38, 39,
617
+ 40, 41, 42, 43, 44, 0, 0, 0, 45, 81,
618
+ 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
619
+ 33, 34, 35, 36, 0, 37, 0, 38, 39, 40,
620
+ 41, 42, 43, 44, 0, 0, 0, 45, 83, 23,
621
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
622
+ 34, 35, 36, 0, 37, 0, 38, 39, 40, 41,
623
+ 42, 43, 44, 0, 0, 0, 45, 24, 25, 26,
624
+ 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
625
+ 0, 37, 0, 38, 39, 40, 41, 42, 43, 44,
626
+ 0, 0, 0, 45, 25, 26, 27, 28, 29, 30,
627
+ 31, 32, 33, 34, 35, 36, 0, 37, 0, 38,
628
+ 39, 40, 41, 42, 43, 44, 0, 0, 0, 45,
629
+ -1, -1, -1, -1, -1, -1, -1, 32, 33, 34,
630
+ 35, 36, 0, 37, 0, 38, 39, 40, 41, 42,
631
+ 43, 44, 0, 0, 0, 45, -1, -1, -1, -1,
632
+ -1, 0, -1, 0, 38, 39, 40, 41, 42, 43,
633
+ 44, 0, 0, 0, 45, -1, -1, 40, 41, 42,
634
+ 43, 44, 0, 0, 0, 45
635
+ };
636
+
637
+ static const yytype_int8 yycheck[] =
638
+ {
639
+ 7, 8, 9, 10, 37, 0, 39, 14, 15, 16,
640
+ 17, 38, 38, 38, 38, 36, 23, 24, 25, 26,
641
+ 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
642
+ 37, 38, 39, 40, 41, 42, 43, 44, 45, -1,
643
+ 47, -1, 3, 4, 5, 6, 7, 8, -1, -1,
644
+ 3, 4, 5, 6, 7, 8, 3, 4, 5, 6,
645
+ 7, 8, 30, 31, 32, -1, -1, 28, 36, -1,
646
+ -1, -1, 33, 80, 35, 28, 37, 38, -1, -1,
647
+ 33, 28, 35, -1, 37, 38, 33, -1, 35, -1,
648
+ -1, 38, 9, 10, 11, 12, 13, 14, 15, 16,
649
+ 17, 18, 19, 20, 21, 22, -1, 24, -1, 26,
650
+ 27, 28, 29, 30, 31, 32, -1, -1, -1, 36,
651
+ -1, -1, 39, 9, 10, 11, 12, 13, 14, 15,
652
+ 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
653
+ 26, 27, 28, 29, 30, 31, 32, -1, -1, -1,
654
+ 36, 37, 9, 10, 11, 12, 13, 14, 15, 16,
655
+ 17, 18, 19, 20, 21, 22, -1, 24, -1, 26,
656
+ 27, 28, 29, 30, 31, 32, -1, -1, -1, 36,
657
+ 37, 9, 10, 11, 12, 13, 14, 15, 16, 17,
658
+ 18, 19, 20, 21, 22, -1, 24, -1, 26, 27,
659
+ 28, 29, 30, 31, 32, -1, -1, -1, 36, 37,
660
+ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
661
+ 19, 20, 21, 22, -1, 24, -1, 26, 27, 28,
662
+ 29, 30, 31, 32, -1, -1, -1, 36, 37, 9,
663
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
664
+ 20, 21, 22, -1, 24, -1, 26, 27, 28, 29,
665
+ 30, 31, 32, -1, -1, -1, 36, 10, 11, 12,
666
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
667
+ -1, 24, -1, 26, 27, 28, 29, 30, 31, 32,
668
+ -1, -1, -1, 36, 11, 12, 13, 14, 15, 16,
669
+ 17, 18, 19, 20, 21, 22, -1, 24, -1, 26,
670
+ 27, 28, 29, 30, 31, 32, -1, -1, -1, 36,
671
+ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
672
+ 21, 22, -1, 24, -1, 26, 27, 28, 29, 30,
673
+ 31, 32, -1, -1, -1, 36, 18, 19, 20, 21,
674
+ 22, -1, 24, -1, 26, 27, 28, 29, 30, 31,
675
+ 32, -1, -1, -1, 36, 26, 27, 28, 29, 30,
676
+ 31, 32, -1, -1, -1, 36
677
+ };
678
+
679
+ /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
680
+ symbol of state STATE-NUM. */
681
+ static const yytype_uint8 yystos[] =
682
+ {
683
+ 0, 3, 4, 5, 6, 7, 8, 28, 33, 35,
684
+ 38, 41, 42, 43, 38, 38, 38, 38, 42, 42,
685
+ 42, 42, 0, 9, 10, 11, 12, 13, 14, 15,
686
+ 16, 17, 18, 19, 20, 21, 22, 24, 26, 27,
687
+ 28, 29, 30, 31, 32, 36, 37, 39, 37, 42,
688
+ 42, 42, 37, 42, 37, 42, 42, 42, 42, 42,
689
+ 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
690
+ 42, 42, 42, 42, 42, 42, 42, 42, 42, 37,
691
+ 39, 37, 42, 37
692
+ };
693
+
694
+ #define yyerrok (yyerrstatus = 0)
695
+ #define yyclearin (yychar = YYEMPTY)
696
+ #define YYEMPTY (-2)
697
+ #define YYEOF 0
698
+
699
+ #define YYACCEPT goto yyacceptlab
700
+ #define YYABORT goto yyabortlab
701
+ #define YYERROR goto yyerrorlab
702
+
703
+
704
+ /* Like YYERROR except do call yyerror. This remains here temporarily
705
+ to ease the transition to the new meaning of YYERROR, for GCC.
706
+ Once GCC version 2 has supplanted version 1, this can go. */
707
+
708
+ #define YYFAIL goto yyerrlab
709
+
710
+ #define YYRECOVERING() (!!yyerrstatus)
711
+
712
+ #define YYBACKUP(Token, Value) \
713
+ do \
714
+ if (yychar == YYEMPTY && yylen == 1) \
715
+ { \
716
+ yychar = (Token); \
717
+ yylval = (Value); \
718
+ yytoken = YYTRANSLATE (yychar); \
719
+ YYPOPSTACK (1); \
720
+ goto yybackup; \
721
+ } \
722
+ else \
723
+ { \
724
+ yyerror (state, exprobj, expr_retval_ptr, YY_("syntax error: cannot back up")); \
725
+ YYERROR; \
726
+ } \
727
+ while (YYID (0))
728
+
729
+
730
+ #define YYTERROR 1
731
+ #define YYERRCODE 256
732
+
733
+
734
+ /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
735
+ If N is 0, then set CURRENT to the empty location which ends
736
+ the previous symbol: RHS[0] (always defined). */
737
+
738
+ #define YYRHSLOC(Rhs, K) ((Rhs)[K])
739
+ #ifndef YYLLOC_DEFAULT
740
+ # define YYLLOC_DEFAULT(Current, Rhs, N) \
741
+ do \
742
+ if (YYID (N)) \
743
+ { \
744
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
745
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
746
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
747
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
748
+ } \
749
+ else \
750
+ { \
751
+ (Current).first_line = (Current).last_line = \
752
+ YYRHSLOC (Rhs, 0).last_line; \
753
+ (Current).first_column = (Current).last_column = \
754
+ YYRHSLOC (Rhs, 0).last_column; \
755
+ } \
756
+ while (YYID (0))
757
+ #endif
758
+
759
+
760
+ /* YY_LOCATION_PRINT -- Print the location on the stream.
761
+ This macro was not mandated originally: define only if we know
762
+ we won't break user code: when these are the locations we know. */
763
+
764
+ #ifndef YY_LOCATION_PRINT
765
+ # if YYLTYPE_IS_TRIVIAL
766
+ # define YY_LOCATION_PRINT(File, Loc) \
767
+ fprintf (File, "%d.%d-%d.%d", \
768
+ (Loc).first_line, (Loc).first_column, \
769
+ (Loc).last_line, (Loc).last_column)
770
+ # else
771
+ # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
772
+ # endif
773
+ #endif
774
+
775
+
776
+ /* YYLEX -- calling `yylex' with the right arguments. */
777
+
778
+ #ifdef YYLEX_PARAM
779
+ # define YYLEX yylex (&yylval, YYLEX_PARAM)
780
+ #else
781
+ # define YYLEX yylex (&yylval, state, exprobj)
782
+ #endif
783
+
784
+ /* Enable debugging if requested. */
785
+ #if YYDEBUG
786
+
787
+ # ifndef YYFPRINTF
788
+ # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
789
+ # define YYFPRINTF fprintf
790
+ # endif
791
+
792
+ # define YYDPRINTF(Args) \
793
+ do { \
794
+ if (yydebug) \
795
+ YYFPRINTF Args; \
796
+ } while (YYID (0))
797
+
798
+ # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
799
+ do { \
800
+ if (yydebug) \
801
+ { \
802
+ YYFPRINTF (stderr, "%s ", Title); \
803
+ yy_symbol_print (stderr, \
804
+ Type, Value, state, exprobj, expr_retval_ptr); \
805
+ YYFPRINTF (stderr, "\n"); \
806
+ } \
807
+ } while (YYID (0))
808
+
809
+
810
+ /*--------------------------------.
811
+ | Print this symbol on YYOUTPUT. |
812
+ `--------------------------------*/
813
+
814
+ /*ARGSUSED*/
815
+ #if (defined __STDC__ || defined __C99__FUNC__ \
816
+ || defined __cplusplus || defined _MSC_VER)
817
+ static void
818
+ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr)
819
+ #else
820
+ static void
821
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep, state, exprobj, expr_retval_ptr)
822
+ FILE *yyoutput;
823
+ int yytype;
824
+ YYSTYPE const * const yyvaluep;
825
+ struct tmplpro_state* state;
826
+ struct expr_parser* exprobj;
827
+ PSTRING* expr_retval_ptr;
828
+ #endif
829
+ {
830
+ if (!yyvaluep)
831
+ return;
832
+ YYUSE (state);
833
+ YYUSE (exprobj);
834
+ YYUSE (expr_retval_ptr);
835
+ # ifdef YYPRINT
836
+ if (yytype < YYNTOKENS)
837
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
838
+ # else
839
+ YYUSE (yyoutput);
840
+ # endif
841
+ switch (yytype)
842
+ {
843
+ default:
844
+ break;
845
+ }
846
+ }
847
+
848
+
849
+ /*--------------------------------.
850
+ | Print this symbol on YYOUTPUT. |
851
+ `--------------------------------*/
852
+
853
+ #if (defined __STDC__ || defined __C99__FUNC__ \
854
+ || defined __cplusplus || defined _MSC_VER)
855
+ static void
856
+ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr)
857
+ #else
858
+ static void
859
+ yy_symbol_print (yyoutput, yytype, yyvaluep, state, exprobj, expr_retval_ptr)
860
+ FILE *yyoutput;
861
+ int yytype;
862
+ YYSTYPE const * const yyvaluep;
863
+ struct tmplpro_state* state;
864
+ struct expr_parser* exprobj;
865
+ PSTRING* expr_retval_ptr;
866
+ #endif
867
+ {
868
+ if (yytype < YYNTOKENS)
869
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
870
+ else
871
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
872
+
873
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep, state, exprobj, expr_retval_ptr);
874
+ YYFPRINTF (yyoutput, ")");
875
+ }
876
+
877
+ /*------------------------------------------------------------------.
878
+ | yy_stack_print -- Print the state stack from its BOTTOM up to its |
879
+ | TOP (included). |
880
+ `------------------------------------------------------------------*/
881
+
882
+ #if (defined __STDC__ || defined __C99__FUNC__ \
883
+ || defined __cplusplus || defined _MSC_VER)
884
+ static void
885
+ yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
886
+ #else
887
+ static void
888
+ yy_stack_print (bottom, top)
889
+ yytype_int16 *bottom;
890
+ yytype_int16 *top;
891
+ #endif
892
+ {
893
+ YYFPRINTF (stderr, "Stack now");
894
+ for (; bottom <= top; ++bottom)
895
+ YYFPRINTF (stderr, " %d", *bottom);
896
+ YYFPRINTF (stderr, "\n");
897
+ }
898
+
899
+ # define YY_STACK_PRINT(Bottom, Top) \
900
+ do { \
901
+ if (yydebug) \
902
+ yy_stack_print ((Bottom), (Top)); \
903
+ } while (YYID (0))
904
+
905
+
906
+ /*------------------------------------------------.
907
+ | Report that the YYRULE is going to be reduced. |
908
+ `------------------------------------------------*/
909
+
910
+ #if (defined __STDC__ || defined __C99__FUNC__ \
911
+ || defined __cplusplus || defined _MSC_VER)
912
+ static void
913
+ yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr)
914
+ #else
915
+ static void
916
+ yy_reduce_print (yyvsp, yyrule, state, exprobj, expr_retval_ptr)
917
+ YYSTYPE *yyvsp;
918
+ int yyrule;
919
+ struct tmplpro_state* state;
920
+ struct expr_parser* exprobj;
921
+ PSTRING* expr_retval_ptr;
922
+ #endif
923
+ {
924
+ int yynrhs = yyr2[yyrule];
925
+ int yyi;
926
+ unsigned long int yylno = yyrline[yyrule];
927
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
928
+ yyrule - 1, yylno);
929
+ /* The symbols being reduced. */
930
+ for (yyi = 0; yyi < yynrhs; yyi++)
931
+ {
932
+ fprintf (stderr, " $%d = ", yyi + 1);
933
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
934
+ &(yyvsp[(yyi + 1) - (yynrhs)])
935
+ , state, exprobj, expr_retval_ptr);
936
+ fprintf (stderr, "\n");
937
+ }
938
+ }
939
+
940
+ # define YY_REDUCE_PRINT(Rule) \
941
+ do { \
942
+ if (yydebug) \
943
+ yy_reduce_print (yyvsp, Rule, state, exprobj, expr_retval_ptr); \
944
+ } while (YYID (0))
945
+
946
+ /* Nonzero means print parse trace. It is left uninitialized so that
947
+ multiple parsers can coexist. */
948
+ int yydebug;
949
+ #else /* !YYDEBUG */
950
+ # define YYDPRINTF(Args)
951
+ # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
952
+ # define YY_STACK_PRINT(Bottom, Top)
953
+ # define YY_REDUCE_PRINT(Rule)
954
+ #endif /* !YYDEBUG */
955
+
956
+
957
+ /* YYINITDEPTH -- initial size of the parser's stacks. */
958
+ #ifndef YYINITDEPTH
959
+ # define YYINITDEPTH 200
960
+ #endif
961
+
962
+ /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
963
+ if the built-in stack extension method is used).
964
+
965
+ Do not make this value too large; the results are undefined if
966
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
967
+ evaluated with infinite-precision integer arithmetic. */
968
+
969
+ #ifndef YYMAXDEPTH
970
+ # define YYMAXDEPTH 10000
971
+ #endif
972
+
973
+
974
+
975
+ #if YYERROR_VERBOSE
976
+
977
+ # ifndef yystrlen
978
+ # if defined __GLIBC__ && defined _STRING_H
979
+ # define yystrlen strlen
980
+ # else
981
+ /* Return the length of YYSTR. */
982
+ #if (defined __STDC__ || defined __C99__FUNC__ \
983
+ || defined __cplusplus || defined _MSC_VER)
984
+ static YYSIZE_T
985
+ yystrlen (const char *yystr)
986
+ #else
987
+ static YYSIZE_T
988
+ yystrlen (yystr)
989
+ const char *yystr;
990
+ #endif
991
+ {
992
+ YYSIZE_T yylen;
993
+ for (yylen = 0; yystr[yylen]; yylen++)
994
+ continue;
995
+ return yylen;
996
+ }
997
+ # endif
998
+ # endif
999
+
1000
+ # ifndef yystpcpy
1001
+ # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1002
+ # define yystpcpy stpcpy
1003
+ # else
1004
+ /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1005
+ YYDEST. */
1006
+ #if (defined __STDC__ || defined __C99__FUNC__ \
1007
+ || defined __cplusplus || defined _MSC_VER)
1008
+ static char *
1009
+ yystpcpy (char *yydest, const char *yysrc)
1010
+ #else
1011
+ static char *
1012
+ yystpcpy (yydest, yysrc)
1013
+ char *yydest;
1014
+ const char *yysrc;
1015
+ #endif
1016
+ {
1017
+ char *yyd = yydest;
1018
+ const char *yys = yysrc;
1019
+
1020
+ while ((*yyd++ = *yys++) != '\0')
1021
+ continue;
1022
+
1023
+ return yyd - 1;
1024
+ }
1025
+ # endif
1026
+ # endif
1027
+
1028
+ # ifndef yytnamerr
1029
+ /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1030
+ quotes and backslashes, so that it's suitable for yyerror. The
1031
+ heuristic is that double-quoting is unnecessary unless the string
1032
+ contains an apostrophe, a comma, or backslash (other than
1033
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
1034
+ null, do not copy; instead, return the length of what the result
1035
+ would have been. */
1036
+ static YYSIZE_T
1037
+ yytnamerr (char *yyres, const char *yystr)
1038
+ {
1039
+ if (*yystr == '"')
1040
+ {
1041
+ YYSIZE_T yyn = 0;
1042
+ char const *yyp = yystr;
1043
+
1044
+ for (;;)
1045
+ switch (*++yyp)
1046
+ {
1047
+ case '\'':
1048
+ case ',':
1049
+ goto do_not_strip_quotes;
1050
+
1051
+ case '\\':
1052
+ if (*++yyp != '\\')
1053
+ goto do_not_strip_quotes;
1054
+ /* Fall through. */
1055
+ default:
1056
+ if (yyres)
1057
+ yyres[yyn] = *yyp;
1058
+ yyn++;
1059
+ break;
1060
+
1061
+ case '"':
1062
+ if (yyres)
1063
+ yyres[yyn] = '\0';
1064
+ return yyn;
1065
+ }
1066
+ do_not_strip_quotes: ;
1067
+ }
1068
+
1069
+ if (! yyres)
1070
+ return yystrlen (yystr);
1071
+
1072
+ return yystpcpy (yyres, yystr) - yyres;
1073
+ }
1074
+ # endif
1075
+
1076
+ /* Copy into YYRESULT an error message about the unexpected token
1077
+ YYCHAR while in state YYSTATE. Return the number of bytes copied,
1078
+ including the terminating null byte. If YYRESULT is null, do not
1079
+ copy anything; just return the number of bytes that would be
1080
+ copied. As a special case, return 0 if an ordinary "syntax error"
1081
+ message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1082
+ size calculation. */
1083
+ static YYSIZE_T
1084
+ yysyntax_error (char *yyresult, int yystate, int yychar)
1085
+ {
1086
+ int yyn = yypact[yystate];
1087
+
1088
+ if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1089
+ return 0;
1090
+ else
1091
+ {
1092
+ int yytype = YYTRANSLATE (yychar);
1093
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1094
+ YYSIZE_T yysize = yysize0;
1095
+ YYSIZE_T yysize1;
1096
+ int yysize_overflow = 0;
1097
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1098
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1099
+ int yyx;
1100
+
1101
+ # if 0
1102
+ /* This is so xgettext sees the translatable formats that are
1103
+ constructed on the fly. */
1104
+ YY_("syntax error, unexpected %s");
1105
+ YY_("syntax error, unexpected %s, expecting %s");
1106
+ YY_("syntax error, unexpected %s, expecting %s or %s");
1107
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1108
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1109
+ # endif
1110
+ char *yyfmt;
1111
+ char const *yyf;
1112
+ static char const yyunexpected[] = "syntax error, unexpected %s";
1113
+ static char const yyexpecting[] = ", expecting %s";
1114
+ static char const yyor[] = " or %s";
1115
+ char yyformat[sizeof yyunexpected
1116
+ + sizeof yyexpecting - 1
1117
+ + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1118
+ * (sizeof yyor - 1))];
1119
+ char const *yyprefix = yyexpecting;
1120
+
1121
+ /* Start YYX at -YYN if negative to avoid negative indexes in
1122
+ YYCHECK. */
1123
+ int yyxbegin = yyn < 0 ? -yyn : 0;
1124
+
1125
+ /* Stay within bounds of both yycheck and yytname. */
1126
+ int yychecklim = YYLAST - yyn + 1;
1127
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1128
+ int yycount = 1;
1129
+
1130
+ yyarg[0] = yytname[yytype];
1131
+ yyfmt = yystpcpy (yyformat, yyunexpected);
1132
+
1133
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1134
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1135
+ {
1136
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1137
+ {
1138
+ yycount = 1;
1139
+ yysize = yysize0;
1140
+ yyformat[sizeof yyunexpected - 1] = '\0';
1141
+ break;
1142
+ }
1143
+ yyarg[yycount++] = yytname[yyx];
1144
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1145
+ yysize_overflow |= (yysize1 < yysize);
1146
+ yysize = yysize1;
1147
+ yyfmt = yystpcpy (yyfmt, yyprefix);
1148
+ yyprefix = yyor;
1149
+ }
1150
+
1151
+ yyf = YY_(yyformat);
1152
+ yysize1 = yysize + yystrlen (yyf);
1153
+ yysize_overflow |= (yysize1 < yysize);
1154
+ yysize = yysize1;
1155
+
1156
+ if (yysize_overflow)
1157
+ return YYSIZE_MAXIMUM;
1158
+
1159
+ if (yyresult)
1160
+ {
1161
+ /* Avoid sprintf, as that infringes on the user's name space.
1162
+ Don't have undefined behavior even if the translation
1163
+ produced a string with the wrong number of "%s"s. */
1164
+ char *yyp = yyresult;
1165
+ int yyi = 0;
1166
+ while ((*yyp = *yyf) != '\0')
1167
+ {
1168
+ if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1169
+ {
1170
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
1171
+ yyf += 2;
1172
+ }
1173
+ else
1174
+ {
1175
+ yyp++;
1176
+ yyf++;
1177
+ }
1178
+ }
1179
+ }
1180
+ return yysize;
1181
+ }
1182
+ }
1183
+ #endif /* YYERROR_VERBOSE */
1184
+
1185
+
1186
+ /*-----------------------------------------------.
1187
+ | Release the memory associated to this symbol. |
1188
+ `-----------------------------------------------*/
1189
+
1190
+ /*ARGSUSED*/
1191
+ #if (defined __STDC__ || defined __C99__FUNC__ \
1192
+ || defined __cplusplus || defined _MSC_VER)
1193
+ static void
1194
+ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr)
1195
+ #else
1196
+ static void
1197
+ yydestruct (yymsg, yytype, yyvaluep, state, exprobj, expr_retval_ptr)
1198
+ const char *yymsg;
1199
+ int yytype;
1200
+ YYSTYPE *yyvaluep;
1201
+ struct tmplpro_state* state;
1202
+ struct expr_parser* exprobj;
1203
+ PSTRING* expr_retval_ptr;
1204
+ #endif
1205
+ {
1206
+ YYUSE (yyvaluep);
1207
+ YYUSE (state);
1208
+ YYUSE (exprobj);
1209
+ YYUSE (expr_retval_ptr);
1210
+
1211
+ if (!yymsg)
1212
+ yymsg = "Deleting";
1213
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1214
+
1215
+ switch (yytype)
1216
+ {
1217
+
1218
+ default:
1219
+ break;
1220
+ }
1221
+ }
1222
+
1223
+
1224
+ /* Prevent warnings from -Wmissing-prototypes. */
1225
+
1226
+ #ifdef YYPARSE_PARAM
1227
+ #if defined __STDC__ || defined __cplusplus
1228
+ int yyparse (void *YYPARSE_PARAM);
1229
+ #else
1230
+ int yyparse ();
1231
+ #endif
1232
+ #else /* ! YYPARSE_PARAM */
1233
+ #if defined __STDC__ || defined __cplusplus
1234
+ int yyparse (struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr);
1235
+ #else
1236
+ int yyparse ();
1237
+ #endif
1238
+ #endif /* ! YYPARSE_PARAM */
1239
+
1240
+
1241
+
1242
+
1243
+
1244
+
1245
+ /*----------.
1246
+ | yyparse. |
1247
+ `----------*/
1248
+
1249
+ #ifdef YYPARSE_PARAM
1250
+ #if (defined __STDC__ || defined __C99__FUNC__ \
1251
+ || defined __cplusplus || defined _MSC_VER)
1252
+ int
1253
+ yyparse (void *YYPARSE_PARAM)
1254
+ #else
1255
+ int
1256
+ yyparse (YYPARSE_PARAM)
1257
+ void *YYPARSE_PARAM;
1258
+ #endif
1259
+ #else /* ! YYPARSE_PARAM */
1260
+ #if (defined __STDC__ || defined __C99__FUNC__ \
1261
+ || defined __cplusplus || defined _MSC_VER)
1262
+ int
1263
+ yyparse (struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr)
1264
+ #else
1265
+ int
1266
+ yyparse (state, exprobj, expr_retval_ptr)
1267
+ struct tmplpro_state* state;
1268
+ struct expr_parser* exprobj;
1269
+ PSTRING* expr_retval_ptr;
1270
+ #endif
1271
+ #endif
1272
+ {
1273
+ /* The look-ahead symbol. */
1274
+ int yychar;
1275
+
1276
+ /* The semantic value of the look-ahead symbol. */
1277
+ YYSTYPE yylval;
1278
+
1279
+ /* Number of syntax errors so far. */
1280
+ int yynerrs;
1281
+
1282
+ int yystate;
1283
+ int yyn;
1284
+ int yyresult;
1285
+ /* Number of tokens to shift before error messages enabled. */
1286
+ int yyerrstatus;
1287
+ /* Look-ahead token as an internal (translated) token number. */
1288
+ int yytoken = 0;
1289
+ #if YYERROR_VERBOSE
1290
+ /* Buffer for error messages, and its allocated size. */
1291
+ char yymsgbuf[128];
1292
+ char *yymsg = yymsgbuf;
1293
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1294
+ #endif
1295
+
1296
+ /* Three stacks and their tools:
1297
+ `yyss': related to states,
1298
+ `yyvs': related to semantic values,
1299
+ `yyls': related to locations.
1300
+
1301
+ Refer to the stacks thru separate pointers, to allow yyoverflow
1302
+ to reallocate them elsewhere. */
1303
+
1304
+ /* The state stack. */
1305
+ yytype_int16 yyssa[YYINITDEPTH];
1306
+ yytype_int16 *yyss = yyssa;
1307
+ yytype_int16 *yyssp;
1308
+
1309
+ /* The semantic value stack. */
1310
+ YYSTYPE yyvsa[YYINITDEPTH];
1311
+ YYSTYPE *yyvs = yyvsa;
1312
+ YYSTYPE *yyvsp;
1313
+
1314
+
1315
+
1316
+ #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1317
+
1318
+ YYSIZE_T yystacksize = YYINITDEPTH;
1319
+
1320
+ /* The variables used to return semantic value and location from the
1321
+ action routines. */
1322
+ YYSTYPE yyval;
1323
+
1324
+
1325
+ /* The number of symbols on the RHS of the reduced rule.
1326
+ Keep to zero when no symbol should be popped. */
1327
+ int yylen = 0;
1328
+
1329
+ YYDPRINTF ((stderr, "Starting parse\n"));
1330
+
1331
+ yystate = 0;
1332
+ yyerrstatus = 0;
1333
+ yynerrs = 0;
1334
+ yychar = YYEMPTY; /* Cause a token to be read. */
1335
+
1336
+ /* Initialize stack pointers.
1337
+ Waste one element of value and location stack
1338
+ so that they stay on the same level as the state stack.
1339
+ The wasted elements are never initialized. */
1340
+
1341
+ yyssp = yyss;
1342
+ yyvsp = yyvs;
1343
+
1344
+ goto yysetstate;
1345
+
1346
+ /*------------------------------------------------------------.
1347
+ | yynewstate -- Push a new state, which is found in yystate. |
1348
+ `------------------------------------------------------------*/
1349
+ yynewstate:
1350
+ /* In all cases, when you get here, the value and location stacks
1351
+ have just been pushed. So pushing a state here evens the stacks. */
1352
+ yyssp++;
1353
+
1354
+ yysetstate:
1355
+ *yyssp = yystate;
1356
+
1357
+ if (yyss + yystacksize - 1 <= yyssp)
1358
+ {
1359
+ /* Get the current used size of the three stacks, in elements. */
1360
+ YYSIZE_T yysize = yyssp - yyss + 1;
1361
+
1362
+ #ifdef yyoverflow
1363
+ {
1364
+ /* Give user a chance to reallocate the stack. Use copies of
1365
+ these so that the &'s don't force the real ones into
1366
+ memory. */
1367
+ YYSTYPE *yyvs1 = yyvs;
1368
+ yytype_int16 *yyss1 = yyss;
1369
+
1370
+
1371
+ /* Each stack pointer address is followed by the size of the
1372
+ data in use in that stack, in bytes. This used to be a
1373
+ conditional around just the two extra args, but that might
1374
+ be undefined if yyoverflow is a macro. */
1375
+ yyoverflow (YY_("memory exhausted"),
1376
+ &yyss1, yysize * sizeof (*yyssp),
1377
+ &yyvs1, yysize * sizeof (*yyvsp),
1378
+
1379
+ &yystacksize);
1380
+
1381
+ yyss = yyss1;
1382
+ yyvs = yyvs1;
1383
+ }
1384
+ #else /* no yyoverflow */
1385
+ # ifndef YYSTACK_RELOCATE
1386
+ goto yyexhaustedlab;
1387
+ # else
1388
+ /* Extend the stack our own way. */
1389
+ if (YYMAXDEPTH <= yystacksize)
1390
+ goto yyexhaustedlab;
1391
+ yystacksize *= 2;
1392
+ if (YYMAXDEPTH < yystacksize)
1393
+ yystacksize = YYMAXDEPTH;
1394
+
1395
+ {
1396
+ yytype_int16 *yyss1 = yyss;
1397
+ union yyalloc *yyptr =
1398
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1399
+ if (! yyptr)
1400
+ goto yyexhaustedlab;
1401
+ YYSTACK_RELOCATE (yyss);
1402
+ YYSTACK_RELOCATE (yyvs);
1403
+
1404
+ # undef YYSTACK_RELOCATE
1405
+ if (yyss1 != yyssa)
1406
+ YYSTACK_FREE (yyss1);
1407
+ }
1408
+ # endif
1409
+ #endif /* no yyoverflow */
1410
+
1411
+ yyssp = yyss + yysize - 1;
1412
+ yyvsp = yyvs + yysize - 1;
1413
+
1414
+
1415
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1416
+ (unsigned long int) yystacksize));
1417
+
1418
+ if (yyss + yystacksize - 1 <= yyssp)
1419
+ YYABORT;
1420
+ }
1421
+
1422
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1423
+
1424
+ goto yybackup;
1425
+
1426
+ /*-----------.
1427
+ | yybackup. |
1428
+ `-----------*/
1429
+ yybackup:
1430
+
1431
+ /* Do appropriate processing given the current state. Read a
1432
+ look-ahead token if we need one and don't already have one. */
1433
+
1434
+ /* First try to decide what to do without reference to look-ahead token. */
1435
+ yyn = yypact[yystate];
1436
+ if (yyn == YYPACT_NINF)
1437
+ goto yydefault;
1438
+
1439
+ /* Not known => get a look-ahead token if don't already have one. */
1440
+
1441
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1442
+ if (yychar == YYEMPTY)
1443
+ {
1444
+ YYDPRINTF ((stderr, "Reading a token: "));
1445
+ yychar = YYLEX;
1446
+ }
1447
+
1448
+ if (yychar <= YYEOF)
1449
+ {
1450
+ yychar = yytoken = YYEOF;
1451
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
1452
+ }
1453
+ else
1454
+ {
1455
+ yytoken = YYTRANSLATE (yychar);
1456
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1457
+ }
1458
+
1459
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
1460
+ detect an error, take that action. */
1461
+ yyn += yytoken;
1462
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1463
+ goto yydefault;
1464
+ yyn = yytable[yyn];
1465
+ if (yyn <= 0)
1466
+ {
1467
+ if (yyn == 0 || yyn == YYTABLE_NINF)
1468
+ goto yyerrlab;
1469
+ yyn = -yyn;
1470
+ goto yyreduce;
1471
+ }
1472
+
1473
+ if (yyn == YYFINAL)
1474
+ YYACCEPT;
1475
+
1476
+ /* Count tokens shifted since error; after three, turn off error
1477
+ status. */
1478
+ if (yyerrstatus)
1479
+ yyerrstatus--;
1480
+
1481
+ /* Shift the look-ahead token. */
1482
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1483
+
1484
+ /* Discard the shifted token unless it is eof. */
1485
+ if (yychar != YYEOF)
1486
+ yychar = YYEMPTY;
1487
+
1488
+ yystate = yyn;
1489
+ *++yyvsp = yylval;
1490
+
1491
+ goto yynewstate;
1492
+
1493
+
1494
+ /*-----------------------------------------------------------.
1495
+ | yydefault -- do the default action for the current state. |
1496
+ `-----------------------------------------------------------*/
1497
+ yydefault:
1498
+ yyn = yydefact[yystate];
1499
+ if (yyn == 0)
1500
+ goto yyerrlab;
1501
+ goto yyreduce;
1502
+
1503
+
1504
+ /*-----------------------------.
1505
+ | yyreduce -- Do a reduction. |
1506
+ `-----------------------------*/
1507
+ yyreduce:
1508
+ /* yyn is the number of a rule to reduce with. */
1509
+ yylen = yyr2[yyn];
1510
+
1511
+ /* If YYLEN is nonzero, implement the default value of the action:
1512
+ `$$ = $1'.
1513
+
1514
+ Otherwise, the following line sets YYVAL to garbage.
1515
+ This behavior is undocumented and Bison
1516
+ users should not rely upon it. Assigning to YYVAL
1517
+ unconditionally makes the parser a bit smaller, and it avoids a
1518
+ GCC warning that YYVAL may be used uninitialized. */
1519
+ yyval = yyvsp[1-yylen];
1520
+
1521
+
1522
+ YY_REDUCE_PRINT (yyn);
1523
+ switch (yyn)
1524
+ {
1525
+ case 2:
1526
+ #line 60 "expr.y"
1527
+ {
1528
+ expr_to_str1(state, &(yyvsp[(1) - (1)].numval));
1529
+ *expr_retval_ptr=(yyvsp[(1) - (1)].numval).val.strval;
1530
+ }
1531
+ break;
1532
+
1533
+ case 3:
1534
+ #line 67 "expr.y"
1535
+ { (yyval.numval) = (yyvsp[(1) - (1)].numval); }
1536
+ break;
1537
+
1538
+ case 4:
1539
+ #line 68 "expr.y"
1540
+ { (yyval.numval).type=EXPR_TYPE_DBL; (yyval.numval).val.dblval = (yyvsp[(1) - (1)].tptr)->var; }
1541
+ break;
1542
+
1543
+ case 5:
1544
+ #line 71 "expr.y"
1545
+ {
1546
+ (yyval.numval) = call_expr_userfunc(exprobj, state->param, (yyvsp[(1) - (2)].extfunc));
1547
+ }
1548
+ break;
1549
+
1550
+ case 6:
1551
+ #line 75 "expr.y"
1552
+ {
1553
+ (yyvsp[(1) - (3)].extfunc).arglist=state->param->InitExprArglistFuncPtr(state->param->ext_calluserfunc_state);
1554
+ (yyval.numval) = call_expr_userfunc(exprobj, state->param, (yyvsp[(1) - (3)].extfunc));
1555
+ }
1556
+ break;
1557
+
1558
+ case 7:
1559
+ #line 80 "expr.y"
1560
+ {
1561
+ struct exprval e = NEW_EXPRVAL(EXPR_TYPE_PSTR);
1562
+ e.val.strval.begin = NULL;
1563
+ e.val.strval.endnext = NULL;
1564
+ (yyval.numval) = (*((func_t_ee)(yyvsp[(1) - (3)].tptr)->fnctptr))(exprobj, e);
1565
+ }
1566
+ break;
1567
+
1568
+ case 8:
1569
+ #line 87 "expr.y"
1570
+ {
1571
+ (yyval.numval).type=EXPR_TYPE_DBL;
1572
+ expr_to_dbl1(exprobj, &(yyvsp[(3) - (4)].numval));
1573
+ (yyval.numval).val.dblval = (*((func_t_dd)(yyvsp[(1) - (4)].tptr)->fnctptr))((yyvsp[(3) - (4)].numval).val.dblval);
1574
+ }
1575
+ break;
1576
+
1577
+ case 9:
1578
+ #line 93 "expr.y"
1579
+ {
1580
+ (yyval.numval).type=EXPR_TYPE_DBL;
1581
+ expr_to_dbl(exprobj, &(yyvsp[(3) - (6)].numval), &(yyvsp[(5) - (6)].numval));
1582
+ (yyval.numval).val.dblval = (*((func_t_ddd)(yyvsp[(1) - (6)].tptr)->fnctptr))((yyvsp[(3) - (6)].numval).val.dblval,(yyvsp[(5) - (6)].numval).val.dblval);
1583
+ }
1584
+ break;
1585
+
1586
+ case 10:
1587
+ #line 99 "expr.y"
1588
+ {
1589
+ (yyval.numval) = (*((func_t_ee)(yyvsp[(1) - (4)].tptr)->fnctptr))(exprobj,(yyvsp[(3) - (4)].numval));
1590
+ }
1591
+ break;
1592
+
1593
+ case 11:
1594
+ #line 102 "expr.y"
1595
+ { DO_MATHOP(exprobj, (yyval.numval),+,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1596
+ break;
1597
+
1598
+ case 12:
1599
+ #line 103 "expr.y"
1600
+ { DO_MATHOP(exprobj, (yyval.numval),-,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1601
+ break;
1602
+
1603
+ case 13:
1604
+ #line 104 "expr.y"
1605
+ { DO_MATHOP(exprobj, (yyval.numval),*,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1606
+ break;
1607
+
1608
+ case 14:
1609
+ #line 106 "expr.y"
1610
+ {
1611
+ (yyval.numval).type=EXPR_TYPE_INT;
1612
+ expr_to_int(exprobj, &(yyvsp[(1) - (3)].numval),&(yyvsp[(3) - (3)].numval));
1613
+ (yyval.numval).val.intval = (yyvsp[(1) - (3)].numval).val.intval % (yyvsp[(3) - (3)].numval).val.intval;
1614
+ }
1615
+ break;
1616
+
1617
+ case 15:
1618
+ #line 137 "expr.y"
1619
+ {
1620
+ (yyval.numval).type=EXPR_TYPE_DBL;
1621
+ expr_to_dbl(exprobj, &(yyvsp[(1) - (3)].numval),&(yyvsp[(3) - (3)].numval));
1622
+ if ((yyvsp[(3) - (3)].numval).val.dblval)
1623
+ (yyval.numval).val.dblval = (yyvsp[(1) - (3)].numval).val.dblval / (yyvsp[(3) - (3)].numval).val.dblval;
1624
+ else
1625
+ {
1626
+ (yyval.numval).val.dblval = 0;
1627
+ log_expr(exprobj, TMPL_LOG_ERROR, "%s\n", "division by zero");
1628
+ }
1629
+ }
1630
+ break;
1631
+
1632
+ case 16:
1633
+ #line 149 "expr.y"
1634
+ {
1635
+ switch ((yyval.numval).type=(yyvsp[(2) - (2)].numval).type) {
1636
+ case EXPR_TYPE_INT:
1637
+ (yyval.numval).val.intval = -(yyvsp[(2) - (2)].numval).val.intval;
1638
+ ;break;
1639
+ case EXPR_TYPE_DBL:
1640
+ (yyval.numval).val.dblval = -(yyvsp[(2) - (2)].numval).val.dblval;
1641
+ ;break;
1642
+ }
1643
+ }
1644
+ break;
1645
+
1646
+ case 17:
1647
+ #line 160 "expr.y"
1648
+ {
1649
+ (yyval.numval).type=EXPR_TYPE_DBL;
1650
+ expr_to_dbl(exprobj, &(yyvsp[(1) - (3)].numval),&(yyvsp[(3) - (3)].numval));
1651
+ (yyval.numval).val.dblval = pow ((yyvsp[(1) - (3)].numval).val.dblval, (yyvsp[(3) - (3)].numval).val.dblval);
1652
+ }
1653
+ break;
1654
+
1655
+ case 18:
1656
+ #line 165 "expr.y"
1657
+ { DO_LOGOP(exprobj, (yyval.numval),&&,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1658
+ break;
1659
+
1660
+ case 19:
1661
+ #line 166 "expr.y"
1662
+ { DO_LOGOP(exprobj, (yyval.numval),||,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1663
+ break;
1664
+
1665
+ case 20:
1666
+ #line 167 "expr.y"
1667
+ { DO_CMPOP(exprobj, (yyval.numval),>=,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1668
+ break;
1669
+
1670
+ case 21:
1671
+ #line 168 "expr.y"
1672
+ { DO_CMPOP(exprobj, (yyval.numval),<=,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1673
+ break;
1674
+
1675
+ case 22:
1676
+ #line 169 "expr.y"
1677
+ { DO_CMPOP(exprobj, (yyval.numval),!=,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1678
+ break;
1679
+
1680
+ case 23:
1681
+ #line 170 "expr.y"
1682
+ { DO_CMPOP(exprobj, (yyval.numval),==,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1683
+ break;
1684
+
1685
+ case 24:
1686
+ #line 171 "expr.y"
1687
+ { DO_CMPOP(exprobj, (yyval.numval),>,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1688
+ break;
1689
+
1690
+ case 25:
1691
+ #line 172 "expr.y"
1692
+ { DO_CMPOP(exprobj, (yyval.numval),<,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval)); }
1693
+ break;
1694
+
1695
+ case 26:
1696
+ #line 173 "expr.y"
1697
+ { DO_LOGOP1(exprobj, (yyval.numval),!,(yyvsp[(2) - (2)].numval)); }
1698
+ break;
1699
+
1700
+ case 27:
1701
+ #line 174 "expr.y"
1702
+ { DO_LOGOP1(exprobj, (yyval.numval),!,(yyvsp[(2) - (2)].numval)); }
1703
+ break;
1704
+
1705
+ case 28:
1706
+ #line 175 "expr.y"
1707
+ { (yyval.numval) = (yyvsp[(2) - (3)].numval); }
1708
+ break;
1709
+
1710
+ case 29:
1711
+ #line 176 "expr.y"
1712
+ {
1713
+ expr_to_str(state, &(yyvsp[(1) - (3)].numval),&(yyvsp[(3) - (3)].numval));
1714
+ (yyval.numval).type=EXPR_TYPE_INT; (yyval.numval).val.intval = pstring_ge ((yyvsp[(1) - (3)].numval).val.strval,(yyvsp[(3) - (3)].numval).val.strval)-pstring_le ((yyvsp[(1) - (3)].numval).val.strval,(yyvsp[(3) - (3)].numval).val.strval);
1715
+ }
1716
+ break;
1717
+
1718
+ case 30:
1719
+ #line 180 "expr.y"
1720
+ { DO_TXTOP((yyval.numval),pstring_ge,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1721
+ break;
1722
+
1723
+ case 31:
1724
+ #line 181 "expr.y"
1725
+ { DO_TXTOP((yyval.numval),pstring_le,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1726
+ break;
1727
+
1728
+ case 32:
1729
+ #line 182 "expr.y"
1730
+ { DO_TXTOP((yyval.numval),pstring_ne,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1731
+ break;
1732
+
1733
+ case 33:
1734
+ #line 183 "expr.y"
1735
+ { DO_TXTOP((yyval.numval),pstring_eq,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1736
+ break;
1737
+
1738
+ case 34:
1739
+ #line 184 "expr.y"
1740
+ { DO_TXTOP((yyval.numval),pstring_gt,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1741
+ break;
1742
+
1743
+ case 35:
1744
+ #line 185 "expr.y"
1745
+ { DO_TXTOP((yyval.numval),pstring_lt,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1746
+ break;
1747
+
1748
+ case 36:
1749
+ #line 186 "expr.y"
1750
+ { DO_TXTOP((yyval.numval),re_like,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1751
+ break;
1752
+
1753
+ case 37:
1754
+ #line 187 "expr.y"
1755
+ { DO_TXTOP((yyval.numval),re_notlike,(yyvsp[(1) - (3)].numval),(yyvsp[(3) - (3)].numval),state);}
1756
+ break;
1757
+
1758
+ case 38:
1759
+ #line 190 "expr.y"
1760
+ {
1761
+ (yyvsp[(1) - (3)].extfunc).arglist=state->param->InitExprArglistFuncPtr(state->param->ext_calluserfunc_state);
1762
+ pusharg_expr_userfunc(exprobj,state->param,(yyvsp[(1) - (3)].extfunc),(yyvsp[(3) - (3)].numval));
1763
+ (yyval.extfunc) = (yyvsp[(1) - (3)].extfunc);
1764
+ }
1765
+ break;
1766
+
1767
+ case 39:
1768
+ #line 195 "expr.y"
1769
+ { pusharg_expr_userfunc(exprobj,state->param,(yyvsp[(1) - (3)].extfunc),(yyvsp[(3) - (3)].numval)); (yyval.extfunc) = (yyvsp[(1) - (3)].extfunc); }
1770
+ break;
1771
+
1772
+
1773
+ /* Line 1267 of yacc.c. */
1774
+ #line 1775 "y.tab.c"
1775
+ default: break;
1776
+ }
1777
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1778
+
1779
+ YYPOPSTACK (yylen);
1780
+ yylen = 0;
1781
+ YY_STACK_PRINT (yyss, yyssp);
1782
+
1783
+ *++yyvsp = yyval;
1784
+
1785
+
1786
+ /* Now `shift' the result of the reduction. Determine what state
1787
+ that goes to, based on the state we popped back to and the rule
1788
+ number reduced by. */
1789
+
1790
+ yyn = yyr1[yyn];
1791
+
1792
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1793
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1794
+ yystate = yytable[yystate];
1795
+ else
1796
+ yystate = yydefgoto[yyn - YYNTOKENS];
1797
+
1798
+ goto yynewstate;
1799
+
1800
+
1801
+ /*------------------------------------.
1802
+ | yyerrlab -- here on detecting error |
1803
+ `------------------------------------*/
1804
+ yyerrlab:
1805
+ /* If not already recovering from an error, report this error. */
1806
+ if (!yyerrstatus)
1807
+ {
1808
+ ++yynerrs;
1809
+ #if ! YYERROR_VERBOSE
1810
+ yyerror (state, exprobj, expr_retval_ptr, YY_("syntax error"));
1811
+ #else
1812
+ {
1813
+ YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1814
+ if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1815
+ {
1816
+ YYSIZE_T yyalloc = 2 * yysize;
1817
+ if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1818
+ yyalloc = YYSTACK_ALLOC_MAXIMUM;
1819
+ if (yymsg != yymsgbuf)
1820
+ YYSTACK_FREE (yymsg);
1821
+ yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1822
+ if (yymsg)
1823
+ yymsg_alloc = yyalloc;
1824
+ else
1825
+ {
1826
+ yymsg = yymsgbuf;
1827
+ yymsg_alloc = sizeof yymsgbuf;
1828
+ }
1829
+ }
1830
+
1831
+ if (0 < yysize && yysize <= yymsg_alloc)
1832
+ {
1833
+ (void) yysyntax_error (yymsg, yystate, yychar);
1834
+ yyerror (state, exprobj, expr_retval_ptr, yymsg);
1835
+ }
1836
+ else
1837
+ {
1838
+ yyerror (state, exprobj, expr_retval_ptr, YY_("syntax error"));
1839
+ if (yysize != 0)
1840
+ goto yyexhaustedlab;
1841
+ }
1842
+ }
1843
+ #endif
1844
+ }
1845
+
1846
+
1847
+
1848
+ if (yyerrstatus == 3)
1849
+ {
1850
+ /* If just tried and failed to reuse look-ahead token after an
1851
+ error, discard it. */
1852
+
1853
+ if (yychar <= YYEOF)
1854
+ {
1855
+ /* Return failure if at end of input. */
1856
+ if (yychar == YYEOF)
1857
+ YYABORT;
1858
+ }
1859
+ else
1860
+ {
1861
+ yydestruct ("Error: discarding",
1862
+ yytoken, &yylval, state, exprobj, expr_retval_ptr);
1863
+ yychar = YYEMPTY;
1864
+ }
1865
+ }
1866
+
1867
+ /* Else will try to reuse look-ahead token after shifting the error
1868
+ token. */
1869
+ goto yyerrlab1;
1870
+
1871
+
1872
+ /*---------------------------------------------------.
1873
+ | yyerrorlab -- error raised explicitly by YYERROR. |
1874
+ `---------------------------------------------------*/
1875
+ yyerrorlab:
1876
+
1877
+ /* Pacify compilers like GCC when the user code never invokes
1878
+ YYERROR and the label yyerrorlab therefore never appears in user
1879
+ code. */
1880
+ if (/*CONSTCOND*/ 0)
1881
+ goto yyerrorlab;
1882
+
1883
+ /* Do not reclaim the symbols of the rule which action triggered
1884
+ this YYERROR. */
1885
+ YYPOPSTACK (yylen);
1886
+ yylen = 0;
1887
+ YY_STACK_PRINT (yyss, yyssp);
1888
+ yystate = *yyssp;
1889
+ goto yyerrlab1;
1890
+
1891
+
1892
+ /*-------------------------------------------------------------.
1893
+ | yyerrlab1 -- common code for both syntax error and YYERROR. |
1894
+ `-------------------------------------------------------------*/
1895
+ yyerrlab1:
1896
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
1897
+
1898
+ for (;;)
1899
+ {
1900
+ yyn = yypact[yystate];
1901
+ if (yyn != YYPACT_NINF)
1902
+ {
1903
+ yyn += YYTERROR;
1904
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1905
+ {
1906
+ yyn = yytable[yyn];
1907
+ if (0 < yyn)
1908
+ break;
1909
+ }
1910
+ }
1911
+
1912
+ /* Pop the current state because it cannot handle the error token. */
1913
+ if (yyssp == yyss)
1914
+ YYABORT;
1915
+
1916
+
1917
+ yydestruct ("Error: popping",
1918
+ yystos[yystate], yyvsp, state, exprobj, expr_retval_ptr);
1919
+ YYPOPSTACK (1);
1920
+ yystate = *yyssp;
1921
+ YY_STACK_PRINT (yyss, yyssp);
1922
+ }
1923
+
1924
+ if (yyn == YYFINAL)
1925
+ YYACCEPT;
1926
+
1927
+ *++yyvsp = yylval;
1928
+
1929
+
1930
+ /* Shift the error token. */
1931
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1932
+
1933
+ yystate = yyn;
1934
+ goto yynewstate;
1935
+
1936
+
1937
+ /*-------------------------------------.
1938
+ | yyacceptlab -- YYACCEPT comes here. |
1939
+ `-------------------------------------*/
1940
+ yyacceptlab:
1941
+ yyresult = 0;
1942
+ goto yyreturn;
1943
+
1944
+ /*-----------------------------------.
1945
+ | yyabortlab -- YYABORT comes here. |
1946
+ `-----------------------------------*/
1947
+ yyabortlab:
1948
+ yyresult = 1;
1949
+ goto yyreturn;
1950
+
1951
+ #ifndef yyoverflow
1952
+ /*-------------------------------------------------.
1953
+ | yyexhaustedlab -- memory exhaustion comes here. |
1954
+ `-------------------------------------------------*/
1955
+ yyexhaustedlab:
1956
+ yyerror (state, exprobj, expr_retval_ptr, YY_("memory exhausted"));
1957
+ yyresult = 2;
1958
+ /* Fall through. */
1959
+ #endif
1960
+
1961
+ yyreturn:
1962
+ if (yychar != YYEOF && yychar != YYEMPTY)
1963
+ yydestruct ("Cleanup: discarding lookahead",
1964
+ yytoken, &yylval, state, exprobj, expr_retval_ptr);
1965
+ /* Do not reclaim the symbols of the rule which action triggered
1966
+ this YYABORT or YYACCEPT. */
1967
+ YYPOPSTACK (yylen);
1968
+ YY_STACK_PRINT (yyss, yyssp);
1969
+ while (yyssp != yyss)
1970
+ {
1971
+ yydestruct ("Cleanup: popping",
1972
+ yystos[*yyssp], yyvsp, state, exprobj, expr_retval_ptr);
1973
+ YYPOPSTACK (1);
1974
+ }
1975
+ #ifndef yyoverflow
1976
+ if (yyss != yyssa)
1977
+ YYSTACK_FREE (yyss);
1978
+ #endif
1979
+ #if YYERROR_VERBOSE
1980
+ if (yymsg != yymsgbuf)
1981
+ YYSTACK_FREE (yymsg);
1982
+ #endif
1983
+ /* Make sure YYID is used. */
1984
+ return YYID (yyresult);
1985
+ }
1986
+
1987
+
1988
+ #line 199 "expr.y"
1989
+
1990
+
1991
+ /* Called by yyparse on error. */
1992
+ static void
1993
+ yyerror (struct tmplpro_state* state, struct expr_parser* exprobj, PSTRING* expr_retval_ptr, char const *s)
1994
+ {
1995
+ log_expr(exprobj, TMPL_LOG_ERROR, "not a valid expression: %s\n", s);
1996
+ }
1997
+
1998
+ #include "calc.inc"
1999
+
2000
+ static
2001
+ const symrec_const
2002
+ #ifndef __cplusplus
2003
+ const
2004
+ #endif
2005
+ builtin_funcs_symrec[] =
2006
+ {
2007
+ /* built-in funcs */
2008
+ {"sin", BUILTIN_FNC_DD, 0, sin},
2009
+ {"cos", BUILTIN_FNC_DD, 0, cos},
2010
+ {"atan", BUILTIN_FNC_DD, 0, atan},
2011
+ {"log", BUILTIN_FNC_DD, 0, log},
2012
+ {"exp", BUILTIN_FNC_DD, 0, exp},
2013
+ {"sqrt", BUILTIN_FNC_DD, 0, sqrt},
2014
+ {"atan2", BUILTIN_FNC_DDD, 0, atan2},
2015
+ {"abs", BUILTIN_FNC_EE, 0, builtin_abs},
2016
+ {"defined", BUILTIN_FNC_EE, 0, builtin_defined},
2017
+ {"int", BUILTIN_FNC_EE, 0, builtin_int},
2018
+ {"hex", BUILTIN_FNC_EE, 0, builtin_hex},
2019
+ {"length", BUILTIN_FNC_EE, 0, builtin_length},
2020
+ {"oct", BUILTIN_FNC_EE, 0, builtin_oct},
2021
+ {"rand", BUILTIN_FNC_EE, 0, builtin_rand},
2022
+ {"srand", BUILTIN_FNC_EE, 0, builtin_srand},
2023
+ {"version", BUILTIN_FNC_EE, 0, builtin_version},
2024
+ /* end mark */
2025
+ {0, 0, 0}
2026
+ };
2027
+
2028
+ static
2029
+ const symrec_const
2030
+ #ifndef __cplusplus
2031
+ const
2032
+ #endif
2033
+ builtin_ops_symrec[] =
2034
+ {
2035
+ /* built-in ops */
2036
+ {"eq", strEQ, 0, NULL},
2037
+ {"ne", strNE, 0, NULL},
2038
+ {"gt", strGT, 0, NULL},
2039
+ {"ge", strGE, 0, NULL},
2040
+ {"lt", strLT, 0, NULL},
2041
+ {"le", strLE, 0, NULL},
2042
+ {"cmp", strCMP, 0, NULL},
2043
+ {"or", OR, 0, NULL},
2044
+ {"and",AND, 0, NULL},
2045
+ {"not",NOT, 0, NULL},
2046
+ /* end mark */
2047
+ {0, 0, 0}
2048
+ };
2049
+
2050
+ TMPLPRO_LOCAL
2051
+ PSTRING
2052
+ parse_expr(PSTRING expression, struct tmplpro_state* state)
2053
+ {
2054
+ PSTRING expr_retval;
2055
+ struct expr_parser exprobj;
2056
+ expr_retval.begin=expression.begin;
2057
+ expr_retval.endnext=expression.begin;
2058
+ exprobj.expr_curpos=expression.begin;
2059
+ exprobj.exprarea=expression;
2060
+ exprobj.state = state;
2061
+ exprobj.is_expect_quote_like=1;
2062
+ yyparse (state, &exprobj, &expr_retval);
2063
+ if (NULL!=expr_retval.begin && NULL==expr_retval.endnext) log_expr(&exprobj, TMPL_LOG_ERROR, "parse_expr internal warning: %s\n", "endnext is null pointer");
2064
+ return expr_retval;
2065
+ }
2066
+
2067
+ static
2068
+ void
2069
+ log_expr(struct expr_parser* exprobj, int loglevel, const char* fmt, ...)
2070
+ {
2071
+ va_list vl;
2072
+ va_start(vl, fmt);
2073
+ log_state(exprobj->state, loglevel, "in EXPR:at pos " MOD_TD " [" MOD_TD "]: ",
2074
+ TO_PTRDIFF_T((exprobj->expr_curpos)-(exprobj->state->top)),
2075
+ TO_PTRDIFF_T((exprobj->expr_curpos)-(exprobj->exprarea).begin));
2076
+ tmpl_log(loglevel, fmt, vl);
2077
+ va_end(vl);
2078
+ }
2079
+
2080
+ static
2081
+ PSTRING
2082
+ fill_symbuf (struct expr_parser* exprobj, int is_accepted(unsigned char)) {
2083
+ /* skip first char, already tested */
2084
+ PSTRING retval = {exprobj->expr_curpos++};
2085
+ while (exprobj->expr_curpos < (exprobj->exprarea).endnext && is_accepted(*exprobj->expr_curpos)) exprobj->expr_curpos++;
2086
+ retval.endnext= exprobj->expr_curpos;
2087
+ return retval;
2088
+ }
2089
+
2090
+ static
2091
+ int
2092
+ is_alnum_lex (unsigned char c)
2093
+ {
2094
+ return (c == '_' || isalnum (c));
2095
+ }
2096
+
2097
+ static
2098
+ int
2099
+ is_not_identifier_ext_end (unsigned char c)
2100
+ {
2101
+ return (c != '}');
2102
+ }
2103
+
2104
+ #define TESTOP(c1,c2,z) if (c1 == c) { char d=*++(exprobj->expr_curpos); if (c2 != d) return c; else (exprobj->expr_curpos)++; return z; }
2105
+ #define TESTOP3(c1,c2,c3,num2,str3) if (c1 == c) { char d=*++(exprobj->expr_curpos); if (c2 == d) {(exprobj->expr_curpos)++; return num2;} else if (c3 == d) {(exprobj->expr_curpos)++; exprobj->is_expect_quote_like=1; return str3;} else return c; }
2106
+
2107
+ static
2108
+ int
2109
+ yylex (YYSTYPE *lvalp, struct tmplpro_state* state, struct expr_parser* exprobj)
2110
+ {
2111
+ register unsigned char c = 0;
2112
+ int is_identifier_ext;
2113
+ /* TODO: newline? */
2114
+ /* Ignore white space, get first nonwhite character. */
2115
+ while ((exprobj->expr_curpos)<(exprobj->exprarea).endnext && ((c = *(exprobj->expr_curpos)) == ' ' || c == '\t')) (exprobj->expr_curpos)++;
2116
+ if ((exprobj->expr_curpos)>=(exprobj->exprarea).endnext) return 0;
2117
+
2118
+ /* Char starts a quote => read a string */
2119
+ if ('\''==c || '"'==c || (exprobj->is_expect_quote_like && '/'==c) ) {
2120
+ PSTRING strvalue;
2121
+ unsigned char terminal_quote=c;
2122
+ int escape_flag = 0;
2123
+ c =* ++(exprobj->expr_curpos);
2124
+ strvalue.begin = exprobj->expr_curpos;
2125
+ strvalue.endnext = exprobj->expr_curpos;
2126
+
2127
+ while ((exprobj->expr_curpos)<(exprobj->exprarea).endnext && c != terminal_quote) {
2128
+ /* any escaped char with \ , incl. quote */
2129
+ if ('\\' == c) {
2130
+ escape_flag = 1;
2131
+ exprobj->expr_curpos+=2;
2132
+ c =*(exprobj->expr_curpos);
2133
+ } else {
2134
+ c = * ++(exprobj->expr_curpos);
2135
+ }
2136
+ }
2137
+
2138
+ strvalue.endnext = exprobj->expr_curpos;
2139
+ if ((exprobj->expr_curpos)<(exprobj->exprarea).endnext && ((c = *(exprobj->expr_curpos)) == terminal_quote)) (exprobj->expr_curpos)++;
2140
+ if (escape_flag) {
2141
+ (*lvalp).numval.type=EXPR_TYPE_UPSTR;
2142
+ } else {
2143
+ (*lvalp).numval.type=EXPR_TYPE_PSTR;
2144
+ }
2145
+ (*lvalp).numval.val.strval=strvalue;
2146
+ exprobj->is_expect_quote_like=0;
2147
+ return NUM;
2148
+ }
2149
+
2150
+ exprobj->is_expect_quote_like=0;
2151
+ /* Char starts a number => parse the number. */
2152
+ if (c == '.' || isdigit (c))
2153
+ {
2154
+ (*lvalp).numval=exp_read_number (exprobj, &(exprobj->expr_curpos), (exprobj->exprarea).endnext);
2155
+ return NUM;
2156
+ }
2157
+
2158
+ /*
2159
+ * Emiliano Bruni extension to Expr:
2160
+ * original HTML::Template allows almost arbitrary chars in parameter names,
2161
+ * but original HTML::Template::Expr (as to 0.04) allows only
2162
+ * var to be m![A-Za-z_][A-Za-z0-9_]*!.
2163
+ * with this extension, arbitrary chars can be used
2164
+ * if bracketed in ${}, as, for example, EXPR="${foo.bar} eq 'a'".
2165
+ * first it was bracketing in {}, but it is changed
2166
+ *
2167
+ * COMPATIBILITY WARNING.
2168
+ * Currently, this extension is not present in HTML::Template::Expr (as of 0.04).
2169
+ */
2170
+ /* Let's try to see if this is an identifier between two { } - Emiliano */
2171
+ is_identifier_ext = (int) (c == '{' || c == '$');
2172
+
2173
+ /* Char starts an identifier => read the name. */
2174
+ /* variables with _leading_underscore are allowed too */
2175
+ if (isalpha (c) || c=='_' || is_identifier_ext) {
2176
+ const symrec_const *s;
2177
+ PSTRING name;
2178
+ if (is_identifier_ext) {
2179
+ (exprobj->expr_curpos)++; /* jump over $ or { */
2180
+ if ('$' == c && '{' == *(exprobj->expr_curpos)) {
2181
+ (exprobj->expr_curpos)++; /* jump over { */
2182
+ #ifndef ALLOW_OLD_BRACKETING_IN_EXPR
2183
+ } else {
2184
+ log_expr(exprobj, TMPL_LOG_ERROR, "{} bracketing is deprecated. Use ${} bracketing.\n");
2185
+ #endif
2186
+ }
2187
+ name=fill_symbuf(exprobj, is_not_identifier_ext_end);
2188
+ if ((exprobj->expr_curpos)<(exprobj->exprarea).endnext) (exprobj->expr_curpos)++; /* Jump the last } - Emiliano */
2189
+ } else {
2190
+ name=fill_symbuf(exprobj, is_alnum_lex);
2191
+ }
2192
+ s = getsym (builtin_ops_symrec, name);
2193
+ if (s != 0) {
2194
+ (*lvalp).tptr = s;
2195
+ return s->type;
2196
+ }
2197
+
2198
+ {
2199
+ PSTRING varvalue;
2200
+ const char* next_char= exprobj->expr_curpos;
2201
+ /* optimization: funcs is always followed by ( */
2202
+ while ((next_char<(exprobj->exprarea).endnext) && isspace(*next_char)) next_char++;
2203
+ if ((*next_char)=='(') {
2204
+ /* user-defined functions have precedence over buit-in */
2205
+ if (((*lvalp).extfunc.func=(state->param->IsExprUserfncFuncPtr)(state->param->expr_func_map, name))) {
2206
+ return EXTFUNC;
2207
+ }
2208
+ s = getsym (builtin_funcs_symrec, name);
2209
+ if (s != 0) {
2210
+ (*lvalp).tptr = s;
2211
+ return s->type;
2212
+ }
2213
+ }
2214
+ varvalue=_get_variable_value(state->param, name);
2215
+ if (varvalue.begin==NULL) {
2216
+ int loglevel = state->param->warn_unused ? TMPL_LOG_ERROR : TMPL_LOG_INFO;
2217
+ log_expr(exprobj,loglevel, "non-initialized variable %.*s\n",(int)(varvalue.endnext-varvalue.begin),varvalue.begin);
2218
+ }
2219
+ (*lvalp).numval.type=EXPR_TYPE_PSTR;
2220
+ (*lvalp).numval.val.strval=varvalue;
2221
+ return NUM;
2222
+ }
2223
+ }
2224
+
2225
+ TESTOP3('=','=','~',numEQ,reLIKE)
2226
+ TESTOP3('!','=','~',numNE,reNOTLIKE)
2227
+ TESTOP('>','=',numGE)
2228
+ TESTOP('<','=',numLE)
2229
+ TESTOP('&','&',AND)
2230
+ TESTOP('|','|',OR)
2231
+
2232
+ /* Any other character is a token by itself. */
2233
+ (exprobj->expr_curpos)++;
2234
+ return c;
2235
+ }
2236
+
2237
+ static
2238
+ struct exprval
2239
+ call_expr_userfunc(struct expr_parser* exprobj, struct tmplpro_param* param, struct user_func_call USERFUNC) {
2240
+ struct exprval emptyval = {EXPR_TYPE_PSTR};
2241
+ emptyval.val.strval.begin=NULL;
2242
+ emptyval.val.strval.endnext=NULL;
2243
+ exprobj->userfunc_call = emptyval;
2244
+ param->CallExprUserfncFuncPtr(param->ext_calluserfunc_state, USERFUNC.arglist, USERFUNC.func, &(exprobj->userfunc_call));
2245
+ if (param->debug>6) _tmplpro_expnum_debug (exprobj->userfunc_call, "EXPR: function call: returned ");
2246
+ param->FreeExprArglistFuncPtr(USERFUNC.arglist);
2247
+ USERFUNC.arglist = NULL;
2248
+ /* never happen; tmplpro_set_expr_as_* never set EXPR_TYPE_NULL *
2249
+ * if (exprobj->userfunc_call.type == EXPR_TYPE_NULL) exprobj->userfunc_call.type = EXPR_TYPE_PSTR; */
2250
+ return exprobj->userfunc_call;
2251
+ }
2252
+
2253
+ static
2254
+ void
2255
+ pusharg_expr_userfunc(struct expr_parser* exprobj, struct tmplpro_param* param, struct user_func_call USERFUNC, struct exprval arg) {
2256
+ if (arg.type == EXPR_TYPE_UPSTR) {
2257
+ arg.val.strval=expr_unescape_pstring_val(&(exprobj->state->expr_left_pbuffer),arg.val.strval);
2258
+ arg.type=EXPR_TYPE_PSTR;
2259
+ }
2260
+ exprobj->userfunc_call = arg;
2261
+ param->PushExprArglistFuncPtr(USERFUNC.arglist,&(exprobj->userfunc_call));
2262
+ if (param->debug>6) _tmplpro_expnum_debug (arg, "EXPR: arglist: pushed ");
2263
+ }
2264
+
2265
+ #include "exprtool.inc"
2266
+ #include "exprpstr.inc"
2267
+