rmultimarkdown 6.2.2.1 → 6.4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/ext/Makefile +2 -2
  3. data/ext/mmd/aho-corasick.c +12 -8
  4. data/ext/mmd/beamer.c +29 -0
  5. data/ext/mmd/critic_markup.c +100 -4
  6. data/ext/mmd/critic_markup.h +7 -0
  7. data/ext/mmd/d_string.c +502 -119
  8. data/ext/mmd/epub.c +2 -4
  9. data/ext/mmd/file.c +436 -0
  10. data/ext/mmd/file.h +153 -0
  11. data/ext/mmd/html.c +130 -37
  12. data/ext/mmd/include/d_string.h +20 -19
  13. data/ext/mmd/include/libMultiMarkdown.h +42 -27
  14. data/ext/mmd/include/token.h +15 -15
  15. data/ext/mmd/latex.c +107 -30
  16. data/ext/mmd/lexer.c +19 -7
  17. data/ext/mmd/lexer.h +2 -2
  18. data/ext/mmd/memoir.c +29 -0
  19. data/ext/mmd/mmd.c +65 -39
  20. data/ext/mmd/object_pool.h +4 -4
  21. data/ext/mmd/opendocument-content.c +95 -13
  22. data/ext/mmd/opendocument.c +315 -313
  23. data/ext/mmd/opml-lexer.c +2183 -0
  24. data/ext/mmd/opml-lexer.h +157 -0
  25. data/ext/mmd/opml-parser.c +1193 -0
  26. data/ext/mmd/opml-parser.h +15 -0
  27. data/ext/mmd/opml-reader.c +435 -0
  28. data/ext/mmd/opml-reader.h +111 -0
  29. data/ext/mmd/opml.c +511 -0
  30. data/ext/mmd/opml.h +115 -0
  31. data/ext/mmd/parser.c +2 -0
  32. data/ext/mmd/rng.c +1 -1
  33. data/ext/mmd/scanners.c +51663 -24824
  34. data/ext/mmd/stack.c +4 -2
  35. data/ext/mmd/stack.h +8 -8
  36. data/ext/mmd/textbundle.c +2 -4
  37. data/ext/mmd/token.c +24 -12
  38. data/ext/mmd/token_pairs.c +2 -2
  39. data/ext/mmd/token_pairs.h +10 -10
  40. data/ext/mmd/transclude.c +1 -226
  41. data/ext/mmd/transclude.h +0 -8
  42. data/ext/mmd/uuid.c +3 -3
  43. data/ext/mmd/version.h +3 -3
  44. data/ext/mmd/writer.c +99 -30
  45. data/ext/mmd/writer.h +11 -0
  46. data/lib/multi_markdown.bundle +0 -0
  47. data/lib/multi_markdown/version.rb +1 -1
  48. metadata +13 -5
  49. data/ext/mmd/fodt.c +0 -2288
  50. data/ext/mmd/fodt.h +0 -81
@@ -0,0 +1,157 @@
1
+ /**
2
+
3
+ MultiMarkdown -- Lightweight markup processor to produce HTML, LaTeX, and more.
4
+
5
+ @file opml-lexer.h
6
+
7
+ @brief
8
+
9
+
10
+ @author Fletcher T. Penney
11
+ @bug
12
+
13
+ **/
14
+
15
+ /*
16
+
17
+ Copyright © 2016 - 2018 Fletcher T. Penney.
18
+
19
+
20
+ The `MultiMarkdown 6` project is released under the MIT License..
21
+
22
+ GLibFacade.c and GLibFacade.h are from the MultiMarkdown v4 project:
23
+
24
+ https://github.com/fletcher/MultiMarkdown-4/
25
+
26
+ MMD 4 is released under both the MIT License and GPL.
27
+
28
+
29
+ CuTest is released under the zlib/libpng license. See CuTest.c for the
30
+ text of the license.
31
+
32
+ uthash library:
33
+ Copyright (c) 2005-2016, Troy D. Hanson
34
+
35
+ Licensed under Revised BSD license
36
+
37
+ miniz library:
38
+ Copyright 2013-2014 RAD Game Tools and Valve Software
39
+ Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
40
+
41
+ Licensed under the MIT license
42
+
43
+ argtable3 library:
44
+ Copyright (C) 1998-2001,2003-2011,2013 Stewart Heitmann
45
+ <sheitmann@users.sourceforge.net>
46
+ All rights reserved.
47
+
48
+ Licensed under the Revised BSD License
49
+
50
+
51
+ ## The MIT License ##
52
+
53
+ Permission is hereby granted, free of charge, to any person obtaining
54
+ a copy of this software and associated documentation files (the
55
+ "Software"), to deal in the Software without restriction, including
56
+ without limitation the rights to use, copy, modify, merge, publish,
57
+ distribute, sublicense, and/or sell copies of the Software, and to
58
+ permit persons to whom the Software is furnished to do so, subject to
59
+ the following conditions:
60
+
61
+ The above copyright notice and this permission notice shall be
62
+ included in all copies or substantial portions of the Software.
63
+
64
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
65
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
66
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
67
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
68
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
69
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
70
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
71
+
72
+
73
+ ## Revised BSD License ##
74
+
75
+ Redistribution and use in source and binary forms, with or without
76
+ modification, are permitted provided that the following conditions are
77
+ met:
78
+ * Redistributions of source code must retain the above copyright
79
+ notice, this list of conditions and the following disclaimer.
80
+ * Redistributions in binary form must reproduce the above
81
+ copyright notice, this list of conditions and the following
82
+ disclaimer in the documentation and/or other materials provided
83
+ with the distribution.
84
+ * Neither the name of the <organization> nor the
85
+ names of its contributors may be used to endorse or promote
86
+ products derived from this software without specific prior
87
+ written permission.
88
+
89
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
90
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
91
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
92
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT
93
+ HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
94
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
95
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR
96
+ PROFITS OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
97
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
98
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
99
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
100
+
101
+
102
+ */
103
+
104
+
105
+ #ifndef OPML_LEXER_MULTIMARKDOWN_H
106
+ #define OPML_LEXER_MULTIMARKDOWN_H
107
+
108
+ enum opml_tokens {
109
+ OPML_XML,
110
+ OPML_OPML_OPEN,
111
+ OPML_OPML_CLOSE,
112
+ OPML_HEAD_OPEN,
113
+ OPML_HEAD_CLOSE,
114
+ OPML_TITLE_OPEN,
115
+ OPML_TITLE_CLOSE,
116
+ OPML_BODY_OPEN,
117
+ OPML_BODY_CLOSE,
118
+ OPML_WSNL,
119
+ };
120
+
121
+ /// Re2c scanner data -- this structure is used by the re2c
122
+ /// lexer to track progress and offsets within the source
123
+ /// string. They can be used to create "tokens" that match
124
+ /// sections of the text with an abstract syntax tree.
125
+ struct Scanner {
126
+ const char * start; //!< Start of current token
127
+ const char * cur; //!< Character currently being matched
128
+ const char * ptr; //!< Used for backtracking by re2c
129
+ const char * ctx;
130
+ };
131
+
132
+ typedef struct Scanner Scanner;
133
+
134
+
135
+ /// Scan for the next opml token
136
+ int opml_scan(
137
+ Scanner * s, //!< Pointer to Scanner state structure
138
+ const char * stop //!< Pointer to position in string at which to stop parsing
139
+ );
140
+
141
+
142
+ /// skip through text attribute to find value
143
+ size_t scan_text(const char * c);
144
+
145
+
146
+ /// skip through _note attribute to find value
147
+ size_t scan_note(const char * c);
148
+
149
+
150
+ /// find end of double quoted value
151
+ size_t scan_double_quoted(const char * c);
152
+
153
+ /// Does the string include encoded newline?
154
+ size_t scan_encoded_newline(const char * c, size_t len);
155
+
156
+
157
+ #endif
@@ -0,0 +1,1193 @@
1
+ /*
2
+ ** 2000-05-29
3
+ **
4
+ ** The author disclaims copyright to this source code. In place of
5
+ ** a legal notice, here is a blessing:
6
+ **
7
+ ** May you do good and not evil.
8
+ ** May you find forgiveness for yourself and forgive others.
9
+ ** May you share freely, never taking more than you give.
10
+ **
11
+ *************************************************************************
12
+ ** Driver template for the LEMON parser generator.
13
+ **
14
+ ** The "lemon" program processes an LALR(1) input grammar file, then uses
15
+ ** this template to construct a parser. The "lemon" program inserts text
16
+ ** at each "%%" line. Also, any "P-a-r-s-e" identifer prefix (without the
17
+ ** interstitial "-" characters) contained in this template is changed into
18
+ ** the value of the %name directive from the grammar. Otherwise, the content
19
+ ** of this template is copied straight through into the generate parser
20
+ ** source file.
21
+ **
22
+ ** The following is the concatenation of all %include directives from the
23
+ ** input grammar file:
24
+ */
25
+ #include <stdio.h>
26
+ /************ Begin %include sections from the grammar ************************/
27
+
28
+ #include <assert.h>
29
+ #include <stdio.h>
30
+ #include <stdlib.h>
31
+
32
+ #include "libMultiMarkdown.h"
33
+ #include "mmd.h"
34
+ #include "parser.h"
35
+ #include "token.h"
36
+ /**************** End of %include directives **********************************/
37
+ /* These constants specify the various numeric values for terminal symbols
38
+ ** in a format understandable to "makeheaders". This section is blank unless
39
+ ** "lemon" is run with the "-m" command-line option.
40
+ ***************** Begin makeheaders token definitions *************************/
41
+ /**************** End makeheaders token definitions ***************************/
42
+
43
+ /* The next sections is a series of control #defines.
44
+ ** various aspects of the generated parser.
45
+ ** YYCODETYPE is the data type used to store the integer codes
46
+ ** that represent terminal and non-terminal symbols.
47
+ ** "unsigned char" is used if there are fewer than
48
+ ** 256 symbols. Larger types otherwise.
49
+ ** YYNOCODE is a number of type YYCODETYPE that is not used for
50
+ ** any terminal or nonterminal symbol.
51
+ ** YYFALLBACK If defined, this indicates that one or more tokens
52
+ ** (also known as: "terminal symbols") have fall-back
53
+ ** values which should be used if the original symbol
54
+ ** would not parse. This permits keywords to sometimes
55
+ ** be used as identifiers, for example.
56
+ ** YYACTIONTYPE is the data type used for "action codes" - numbers
57
+ ** that indicate what to do in response to the next
58
+ ** token.
59
+ ** OPMLTOKENTYPE is the data type used for minor type for terminal
60
+ ** symbols. Background: A "minor type" is a semantic
61
+ ** value associated with a terminal or non-terminal
62
+ ** symbols. For example, for an "ID" terminal symbol,
63
+ ** the minor type might be the name of the identifier.
64
+ ** Each non-terminal can have a different minor type.
65
+ ** Terminal symbols all have the same minor type, though.
66
+ ** This macros defines the minor type for terminal
67
+ ** symbols.
68
+ ** YYMINORTYPE is the data type used for all minor types.
69
+ ** This is typically a union of many types, one of
70
+ ** which is OPMLTOKENTYPE. The entry in the union
71
+ ** for terminal symbols is called "yy0".
72
+ ** YYSTACKDEPTH is the maximum depth of the parser's stack. If
73
+ ** zero the stack is dynamically sized using realloc()
74
+ ** OPMLARG_SDECL A static variable declaration for the %extra_argument
75
+ ** OPMLARG_PDECL A parameter declaration for the %extra_argument
76
+ ** OPMLARG_STORE Code to store %extra_argument into yypParser
77
+ ** OPMLARG_FETCH Code to extract %extra_argument from yypParser
78
+ ** YYERRORSYMBOL is the code number of the error symbol. If not
79
+ ** defined, then do no error processing.
80
+ ** YYNSTATE the combined number of states.
81
+ ** YYNRULE the number of rules in the grammar
82
+ ** YY_MAX_SHIFT Maximum value for shift actions
83
+ ** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
84
+ ** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
85
+ ** YY_MIN_REDUCE Maximum value for reduce actions
86
+ ** YY_ERROR_ACTION The yy_action[] code for syntax error
87
+ ** YY_ACCEPT_ACTION The yy_action[] code for accept
88
+ ** YY_NO_ACTION The yy_action[] code for no-op
89
+ */
90
+ #ifndef INTERFACE
91
+ #define INTERFACE 1
92
+ #endif
93
+ /************* Begin control #defines *****************************************/
94
+ #define YYCODETYPE unsigned char
95
+ #define YYNOCODE 26
96
+ #define YYACTIONTYPE unsigned char
97
+ #define OPMLTOKENTYPE token *
98
+ typedef union {
99
+ int yyinit;
100
+ OPMLTOKENTYPE yy0;
101
+ } YYMINORTYPE;
102
+ #ifndef YYSTACKDEPTH
103
+ #define YYSTACKDEPTH 100
104
+ #endif
105
+ #define OPMLARG_SDECL mmd_engine * engine ;
106
+ #define OPMLARG_PDECL , mmd_engine * engine
107
+ #define OPMLARG_FETCH mmd_engine * engine = yypParser->engine
108
+ #define OPMLARG_STORE yypParser->engine = engine
109
+ #define YYNSTATE 18
110
+ #define YYNRULE 17
111
+ #define YY_MAX_SHIFT 17
112
+ #define YY_MIN_SHIFTREDUCE 33
113
+ #define YY_MAX_SHIFTREDUCE 49
114
+ #define YY_MIN_REDUCE 50
115
+ #define YY_MAX_REDUCE 66
116
+ #define YY_ERROR_ACTION 67
117
+ #define YY_ACCEPT_ACTION 68
118
+ #define YY_NO_ACTION 69
119
+ /************* End control #defines *******************************************/
120
+
121
+ /* Define the yytestcase() macro to be a no-op if is not already defined
122
+ ** otherwise.
123
+ **
124
+ ** Applications can choose to define yytestcase() in the %include section
125
+ ** to a macro that can assist in verifying code coverage. For production
126
+ ** code the yytestcase() macro should be turned off. But it is useful
127
+ ** for testing.
128
+ */
129
+ #ifndef yytestcase
130
+ #define yytestcase(X)
131
+ #endif
132
+
133
+
134
+ /* Next are the tables used to determine what action to take based on the
135
+ ** current state and lookahead token. These tables are used to implement
136
+ ** functions that take a state number and lookahead value and return an
137
+ ** action integer.
138
+ **
139
+ ** Suppose the action integer is N. Then the action is determined as
140
+ ** follows
141
+ **
142
+ ** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead
143
+ ** token onto the stack and goto state N.
144
+ **
145
+ ** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then
146
+ ** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE.
147
+ **
148
+ ** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
149
+ ** and YY_MAX_REDUCE
150
+ **
151
+ ** N == YY_ERROR_ACTION A syntax error has occurred.
152
+ **
153
+ ** N == YY_ACCEPT_ACTION The parser accepts its input.
154
+ **
155
+ ** N == YY_NO_ACTION No such action. Denotes unused
156
+ ** slots in the yy_action[] table.
157
+ **
158
+ ** The action table is constructed as a single large table named yy_action[].
159
+ ** Given state S and lookahead X, the action is computed as either:
160
+ **
161
+ ** (A) N = yy_action[ yy_shift_ofst[S] + X ]
162
+ ** (B) N = yy_default[S]
163
+ **
164
+ ** The (A) formula is preferred. The B formula is used instead if:
165
+ ** (1) The yy_shift_ofst[S]+X value is out of range, or
166
+ ** (2) yy_lookahead[yy_shift_ofst[S]+X] is not equal to X, or
167
+ ** (3) yy_shift_ofst[S] equal YY_SHIFT_USE_DFLT.
168
+ ** (Implementation note: YY_SHIFT_USE_DFLT is chosen so that
169
+ ** YY_SHIFT_USE_DFLT+X will be out of range for all possible lookaheads X.
170
+ ** Hence only tests (1) and (2) need to be evaluated.)
171
+ **
172
+ ** The formulas above are for computing the action when the lookahead is
173
+ ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
174
+ ** a reduce action) then the yy_reduce_ofst[] array is used in place of
175
+ ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
176
+ ** YY_SHIFT_USE_DFLT.
177
+ **
178
+ ** The following are the tables generated in this section:
179
+ **
180
+ ** yy_action[] A single table containing all actions.
181
+ ** yy_lookahead[] A table containing the lookahead for each entry in
182
+ ** yy_action. Used to detect hash collisions.
183
+ ** yy_shift_ofst[] For each state, the offset into yy_action for
184
+ ** shifting terminals.
185
+ ** yy_reduce_ofst[] For each state, the offset into yy_action for
186
+ ** shifting non-terminals after a reduce.
187
+ ** yy_default[] Default action for each state.
188
+ **
189
+ *********** Begin parsing tables **********************************************/
190
+ #define YY_ACTTAB_COUNT (57)
191
+ static const YYACTIONTYPE yy_action[] = {
192
+ /* 0 */ 1, 45, 14, 3, 49, 42, 1, 10, 14, 3,
193
+ /* 10 */ 49, 1, 48, 14, 3, 49, 1, 47, 14, 3,
194
+ /* 20 */ 49, 41, 1, 43, 14, 3, 49, 1, 2, 14,
195
+ /* 30 */ 3, 49, 68, 17, 15, 6, 6, 7, 7, 8,
196
+ /* 40 */ 5, 5, 12, 2, 40, 9, 13, 39, 11, 4,
197
+ /* 50 */ 16, 38, 37, 36, 46, 35, 50,
198
+ };
199
+ static const YYCODETYPE yy_lookahead[] = {
200
+ /* 0 */ 11, 12, 13, 14, 15, 10, 11, 1, 13, 14,
201
+ /* 10 */ 15, 11, 12, 13, 14, 15, 11, 12, 13, 14,
202
+ /* 20 */ 15, 10, 11, 24, 13, 14, 15, 11, 9, 13,
203
+ /* 30 */ 14, 15, 17, 18, 21, 23, 24, 23, 24, 5,
204
+ /* 40 */ 23, 24, 22, 9, 8, 20, 21, 6, 7, 3,
205
+ /* 50 */ 19, 6, 4, 4, 12, 2, 0,
206
+ };
207
+ #define YY_SHIFT_USE_DFLT (57)
208
+ #define YY_SHIFT_COUNT (17)
209
+ #define YY_SHIFT_MIN (-11)
210
+ #define YY_SHIFT_MAX (56)
211
+ static const signed char yy_shift_ofst[] = {
212
+ /* 0 */ 6, -11, -5, 16, 34, 0, 5, 11, 41, 19,
213
+ /* 10 */ 46, 36, 45, 48, 42, 49, 53, 56,
214
+ };
215
+ #define YY_REDUCE_USE_DFLT (-2)
216
+ #define YY_REDUCE_COUNT (10)
217
+ #define YY_REDUCE_MIN (-1)
218
+ #define YY_REDUCE_MAX (31)
219
+ static const signed char yy_reduce_ofst[] = {
220
+ /* 0 */ 15, 12, 14, 17, 25, -1, -1, -1, 20, 13,
221
+ /* 10 */ 31,
222
+ };
223
+ static const YYACTIONTYPE yy_default[] = {
224
+ /* 0 */ 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
225
+ /* 10 */ 67, 67, 67, 67, 67, 67, 51, 67,
226
+ };
227
+ /********** End of lemon-generated parsing tables *****************************/
228
+
229
+ /* The next table maps tokens (terminal symbols) into fallback tokens.
230
+ ** If a construct like the following:
231
+ **
232
+ ** %fallback ID X Y Z.
233
+ **
234
+ ** appears in the grammar, then ID becomes a fallback token for X, Y,
235
+ ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
236
+ ** but it does not parse, the type of the token is changed to ID and
237
+ ** the parse is retried before an error is thrown.
238
+ **
239
+ ** This feature can be used, for example, to cause some keywords in a language
240
+ ** to revert to identifiers if they keyword does not apply in the context where
241
+ ** it appears.
242
+ */
243
+ #ifdef YYFALLBACK
244
+ static const YYCODETYPE yyFallback[] = {
245
+ };
246
+ #endif /* YYFALLBACK */
247
+
248
+ /* The following structure represents a single element of the
249
+ ** parser's stack. Information stored includes:
250
+ **
251
+ ** + The state number for the parser at this level of the stack.
252
+ **
253
+ ** + The value of the token stored at this level of the stack.
254
+ ** (In other words, the "major" token.)
255
+ **
256
+ ** + The semantic value stored at this level of the stack. This is
257
+ ** the information used by the action routines in the grammar.
258
+ ** It is sometimes called the "minor" token.
259
+ **
260
+ ** After the "shift" half of a SHIFTREDUCE action, the stateno field
261
+ ** actually contains the reduce action for the second half of the
262
+ ** SHIFTREDUCE.
263
+ */
264
+ struct yyStackEntry {
265
+ YYACTIONTYPE stateno; /* The state-number, or reduce action in SHIFTREDUCE */
266
+ YYCODETYPE major; /* The major token value. This is the code
267
+ ** number for the token at this stack level */
268
+ YYMINORTYPE minor; /* The user-supplied minor token value. This
269
+ ** is the value of the token */
270
+ };
271
+ typedef struct yyStackEntry yyStackEntry;
272
+
273
+ /* The state of the parser is completely contained in an instance of
274
+ ** the following structure */
275
+ struct yyParser {
276
+ yyStackEntry *yytos; /* Pointer to top element of the stack */
277
+ #ifdef YYTRACKMAXSTACKDEPTH
278
+ int yyhwm; /* High-water mark of the stack */
279
+ #endif
280
+ #ifndef YYNOERRORRECOVERY
281
+ int yyerrcnt; /* Shifts left before out of the error */
282
+ #endif
283
+ OPMLARG_SDECL /* A place to hold %extra_argument */
284
+ #if YYSTACKDEPTH<=0
285
+ int yystksz; /* Current side of the stack */
286
+ yyStackEntry *yystack; /* The parser's stack */
287
+ yyStackEntry yystk0; /* First stack entry */
288
+ #else
289
+ yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
290
+ #endif
291
+ };
292
+ typedef struct yyParser yyParser;
293
+
294
+ #ifndef NDEBUG
295
+ #include <stdio.h>
296
+ static FILE *yyTraceFILE = 0;
297
+ static char *yyTracePrompt = 0;
298
+ #endif /* NDEBUG */
299
+
300
+ #ifndef NDEBUG
301
+ /*
302
+ ** Turn parser tracing on by giving a stream to which to write the trace
303
+ ** and a prompt to preface each trace message. Tracing is turned off
304
+ ** by making either argument NULL
305
+ **
306
+ ** Inputs:
307
+ ** <ul>
308
+ ** <li> A FILE* to which trace output should be written.
309
+ ** If NULL, then tracing is turned off.
310
+ ** <li> A prefix string written at the beginning of every
311
+ ** line of trace output. If NULL, then tracing is
312
+ ** turned off.
313
+ ** </ul>
314
+ **
315
+ ** Outputs:
316
+ ** None.
317
+ */
318
+ void OPMLTrace(FILE *TraceFILE, char *zTracePrompt) {
319
+ yyTraceFILE = TraceFILE;
320
+ yyTracePrompt = zTracePrompt;
321
+
322
+ if ( yyTraceFILE == 0 ) {
323
+ yyTracePrompt = 0;
324
+ } else if ( yyTracePrompt == 0 ) {
325
+ yyTraceFILE = 0;
326
+ }
327
+ }
328
+ #endif /* NDEBUG */
329
+
330
+ #ifndef NDEBUG
331
+ /* For tracing shifts, the names of all terminals and nonterminals
332
+ ** are required. The following table supplies these names */
333
+ static const char *const yyTokenName[] = {
334
+ "$", "OPML_XML", "OPML_WSNL", "OPML_OPML_OPEN",
335
+ "OPML_OPML_CLOSE", "OPML_HEAD_OPEN", "OPML_HEAD_CLOSE", "OPML_TITLE_OPEN",
336
+ "OPML_TITLE_CLOSE", "OPML_BODY_OPEN", "OPML_BODY_CLOSE", "OPML_OUTLINE_OPEN",
337
+ "OPML_OUTLINE_CLOSE", "OPML_OUTLINE_PREAMBLE", "OPML_OUTLINE_METADATA", "OPML_OUTLINE_SELF_CLOSE",
338
+ "error", "doc", "doc_xml", "doc_opml",
339
+ "opml_header", "opml_body", "opml_title", "opml_outlines",
340
+ "opml_outline",
341
+ };
342
+ #endif /* NDEBUG */
343
+
344
+ #ifndef NDEBUG
345
+ /* For tracing reduce actions, the names of all rules are required.
346
+ */
347
+ static const char *const yyRuleName[] = {
348
+ /* 0 */ "doc ::= doc_xml",
349
+ /* 1 */ "doc_xml ::= OPML_XML doc_opml",
350
+ /* 2 */ "doc_xml ::= OPML_XML doc_opml OPML_WSNL",
351
+ /* 3 */ "doc_opml ::= OPML_OPML_OPEN opml_header opml_body OPML_OPML_CLOSE",
352
+ /* 4 */ "doc_opml ::= OPML_OPML_OPEN opml_body OPML_OPML_CLOSE",
353
+ /* 5 */ "opml_header ::= OPML_HEAD_OPEN opml_title OPML_HEAD_CLOSE",
354
+ /* 6 */ "opml_header ::= OPML_HEAD_OPEN OPML_HEAD_CLOSE",
355
+ /* 7 */ "opml_title ::= OPML_TITLE_OPEN OPML_TITLE_CLOSE",
356
+ /* 8 */ "opml_body ::= OPML_BODY_OPEN opml_outlines OPML_BODY_CLOSE",
357
+ /* 9 */ "opml_body ::= OPML_BODY_OPEN OPML_BODY_CLOSE",
358
+ /* 10 */ "opml_outlines ::= opml_outlines opml_outline",
359
+ /* 11 */ "opml_outlines ::= opml_outline",
360
+ /* 12 */ "opml_outline ::= OPML_OUTLINE_OPEN OPML_OUTLINE_CLOSE",
361
+ /* 13 */ "opml_outline ::= OPML_OUTLINE_PREAMBLE OPML_OUTLINE_CLOSE",
362
+ /* 14 */ "opml_outline ::= OPML_OUTLINE_OPEN opml_outlines OPML_OUTLINE_CLOSE",
363
+ /* 15 */ "opml_outline ::= OPML_OUTLINE_METADATA opml_outlines OPML_OUTLINE_CLOSE",
364
+ /* 16 */ "opml_outline ::= OPML_OUTLINE_SELF_CLOSE",
365
+ };
366
+ #endif /* NDEBUG */
367
+
368
+
369
+ #if YYSTACKDEPTH<=0
370
+ /*
371
+ ** Try to increase the size of the parser stack. Return the number
372
+ ** of errors. Return 0 on success.
373
+ */
374
+ static int yyGrowStack(yyParser *p) {
375
+ int newSize;
376
+ int idx;
377
+ yyStackEntry *pNew;
378
+
379
+ newSize = p->yystksz * 2 + 100;
380
+ idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
381
+
382
+ if ( p->yystack == &p->yystk0 ) {
383
+ pNew = malloc(newSize * sizeof(pNew[0]));
384
+
385
+ if ( pNew ) {
386
+ pNew[0] = p->yystk0;
387
+ }
388
+ } else {
389
+ pNew = realloc(p->yystack, newSize * sizeof(pNew[0]));
390
+ }
391
+
392
+ if ( pNew ) {
393
+ p->yystack = pNew;
394
+ p->yytos = &p->yystack[idx];
395
+ #ifndef NDEBUG
396
+
397
+ if ( yyTraceFILE ) {
398
+ fprintf(yyTraceFILE, "%sStack grows from %d to %d entries.\n",
399
+ yyTracePrompt, p->yystksz, newSize);
400
+ }
401
+
402
+ #endif
403
+ p->yystksz = newSize;
404
+ }
405
+
406
+ return pNew == 0;
407
+ }
408
+ #endif
409
+
410
+ /* Datatype of the argument to the memory allocated passed as the
411
+ ** second argument to OPMLAlloc() below. This can be changed by
412
+ ** putting an appropriate #define in the %include section of the input
413
+ ** grammar.
414
+ */
415
+ #ifndef YYMALLOCARGTYPE
416
+ #define YYMALLOCARGTYPE size_t
417
+ #endif
418
+
419
+ /*
420
+ ** This function allocates a new parser.
421
+ ** The only argument is a pointer to a function which works like
422
+ ** malloc.
423
+ **
424
+ ** Inputs:
425
+ ** A pointer to the function used to allocate memory.
426
+ **
427
+ ** Outputs:
428
+ ** A pointer to a parser. This pointer is used in subsequent calls
429
+ ** to OPML and OPMLFree.
430
+ */
431
+ void *OPMLAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)) {
432
+ yyParser *pParser;
433
+ pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
434
+
435
+ if ( pParser ) {
436
+ #ifdef YYTRACKMAXSTACKDEPTH
437
+ pParser->yyhwm = 0;
438
+ #endif
439
+ #if YYSTACKDEPTH<=0
440
+ pParser->yytos = NULL;
441
+ pParser->yystack = NULL;
442
+ pParser->yystksz = 0;
443
+
444
+ if ( yyGrowStack(pParser) ) {
445
+ pParser->yystack = &pParser->yystk0;
446
+ pParser->yystksz = 1;
447
+ }
448
+
449
+ #endif
450
+ #ifndef YYNOERRORRECOVERY
451
+ pParser->yyerrcnt = -1;
452
+ #endif
453
+ pParser->yytos = pParser->yystack;
454
+ pParser->yystack[0].stateno = 0;
455
+ pParser->yystack[0].major = 0;
456
+ }
457
+
458
+ return pParser;
459
+ }
460
+
461
+ /* The following function deletes the "minor type" or semantic value
462
+ ** associated with a symbol. The symbol can be either a terminal
463
+ ** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
464
+ ** a pointer to the value to be deleted. The code used to do the
465
+ ** deletions is derived from the %destructor and/or %token_destructor
466
+ ** directives of the input grammar.
467
+ */
468
+ static void yy_destructor(
469
+ yyParser *yypParser, /* The parser */
470
+ YYCODETYPE yymajor, /* Type code for object to destroy */
471
+ YYMINORTYPE *yypminor /* The object to be destroyed */
472
+ ) {
473
+ OPMLARG_FETCH;
474
+
475
+ switch ( yymajor ) {
476
+ /* Here is inserted the actions which take place when a
477
+ ** terminal or non-terminal is destroyed. This can happen
478
+ ** when the symbol is popped from the stack during a
479
+ ** reduce or during error processing or when a parser is
480
+ ** being destroyed before it is finished parsing.
481
+ **
482
+ ** Note: during a reduce, the only symbols destroyed are those
483
+ ** which appear on the RHS of the rule, but which are *not* used
484
+ ** inside the C code.
485
+ */
486
+ /********* Begin destructor definitions ***************************************/
487
+ /********* End destructor definitions *****************************************/
488
+ default:
489
+ break; /* If no destructor action specified: do nothing */
490
+ }
491
+ }
492
+
493
+ /*
494
+ ** Pop the parser's stack once.
495
+ **
496
+ ** If there is a destructor routine associated with the token which
497
+ ** is popped from the stack, then call it.
498
+ */
499
+ static void yy_pop_parser_stack(yyParser *pParser) {
500
+ yyStackEntry *yytos;
501
+ assert( pParser->yytos != 0 );
502
+ assert( pParser->yytos > pParser->yystack );
503
+ yytos = pParser->yytos--;
504
+ #ifndef NDEBUG
505
+
506
+ if ( yyTraceFILE ) {
507
+ fprintf(yyTraceFILE, "%sPopping %s\n",
508
+ yyTracePrompt,
509
+ yyTokenName[yytos->major]);
510
+ }
511
+
512
+ #endif
513
+ yy_destructor(pParser, yytos->major, &yytos->minor);
514
+ }
515
+
516
+ /*
517
+ ** Deallocate and destroy a parser. Destructors are called for
518
+ ** all stack elements before shutting the parser down.
519
+ **
520
+ ** If the YYPARSEFREENEVERNULL macro exists (for example because it
521
+ ** is defined in a %include section of the input grammar) then it is
522
+ ** assumed that the input pointer is never NULL.
523
+ */
524
+ void OPMLFree(
525
+ void *p, /* The parser to be deleted */
526
+ void (*freeProc)(void*) /* Function used to reclaim memory */
527
+ ) {
528
+ yyParser *pParser = (yyParser*)p;
529
+ #ifndef YYPARSEFREENEVERNULL
530
+
531
+ if ( pParser == 0 ) {
532
+ return;
533
+ }
534
+
535
+ #endif
536
+
537
+ while ( pParser->yytos > pParser->yystack ) {
538
+ yy_pop_parser_stack(pParser);
539
+ }
540
+
541
+ #if YYSTACKDEPTH<=0
542
+
543
+ if ( pParser->yystack != &pParser->yystk0 ) {
544
+ free(pParser->yystack);
545
+ }
546
+
547
+ #endif
548
+ (*freeProc)((void*)pParser);
549
+ }
550
+
551
+ /*
552
+ ** Return the peak depth of the stack for a parser.
553
+ */
554
+ #ifdef YYTRACKMAXSTACKDEPTH
555
+ int OPMLStackPeak(void *p) {
556
+ yyParser *pParser = (yyParser*)p;
557
+ return pParser->yyhwm;
558
+ }
559
+ #endif
560
+
561
+ /*
562
+ ** Find the appropriate action for a parser given the terminal
563
+ ** look-ahead token iLookAhead.
564
+ */
565
+ static unsigned int yy_find_shift_action(
566
+ yyParser *pParser, /* The parser */
567
+ YYCODETYPE iLookAhead /* The look-ahead token */
568
+ ) {
569
+ int i;
570
+ int stateno = pParser->yytos->stateno;
571
+
572
+ if ( stateno >= YY_MIN_REDUCE ) {
573
+ return stateno;
574
+ }
575
+
576
+ assert( stateno <= YY_SHIFT_COUNT );
577
+
578
+ do {
579
+ i = yy_shift_ofst[stateno];
580
+ assert( iLookAhead != YYNOCODE );
581
+ i += iLookAhead;
582
+
583
+ if ( i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead ) {
584
+ #ifdef YYFALLBACK
585
+ YYCODETYPE iFallback; /* Fallback token */
586
+
587
+ if ( iLookAhead < sizeof(yyFallback) / sizeof(yyFallback[0])
588
+ && (iFallback = yyFallback[iLookAhead]) != 0 ) {
589
+ #ifndef NDEBUG
590
+
591
+ if ( yyTraceFILE ) {
592
+ fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
593
+ yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
594
+ }
595
+
596
+ #endif
597
+ assert( yyFallback[iFallback] == 0 ); /* Fallback loop must terminate */
598
+ iLookAhead = iFallback;
599
+ continue;
600
+ }
601
+
602
+ #endif
603
+ #ifdef YYWILDCARD
604
+ {
605
+ int j = i - iLookAhead + YYWILDCARD;
606
+
607
+ if (
608
+ #if YY_SHIFT_MIN+YYWILDCARD<0
609
+ j >= 0 &&
610
+ #endif
611
+ #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
612
+ j < YY_ACTTAB_COUNT &&
613
+ #endif
614
+ yy_lookahead[j] == YYWILDCARD && iLookAhead > 0
615
+ ) {
616
+ #ifndef NDEBUG
617
+
618
+ if ( yyTraceFILE ) {
619
+ fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
620
+ yyTracePrompt, yyTokenName[iLookAhead],
621
+ yyTokenName[YYWILDCARD]);
622
+ }
623
+
624
+ #endif /* NDEBUG */
625
+ return yy_action[j];
626
+ }
627
+ }
628
+ #endif /* YYWILDCARD */
629
+ return yy_default[stateno];
630
+ } else {
631
+ return yy_action[i];
632
+ }
633
+ } while (1);
634
+ }
635
+
636
+ /*
637
+ ** Find the appropriate action for a parser given the non-terminal
638
+ ** look-ahead token iLookAhead.
639
+ */
640
+ static int yy_find_reduce_action(
641
+ int stateno, /* Current state number */
642
+ YYCODETYPE iLookAhead /* The look-ahead token */
643
+ ) {
644
+ int i;
645
+ #ifdef YYERRORSYMBOL
646
+
647
+ if ( stateno > YY_REDUCE_COUNT ) {
648
+ return yy_default[stateno];
649
+ }
650
+
651
+ #else
652
+ assert( stateno <= YY_REDUCE_COUNT );
653
+ #endif
654
+ i = yy_reduce_ofst[stateno];
655
+ assert( i != YY_REDUCE_USE_DFLT );
656
+ assert( iLookAhead != YYNOCODE );
657
+ i += iLookAhead;
658
+ #ifdef YYERRORSYMBOL
659
+
660
+ if ( i < 0 || i >= YY_ACTTAB_COUNT || yy_lookahead[i] != iLookAhead ) {
661
+ return yy_default[stateno];
662
+ }
663
+
664
+ #else
665
+ assert( i >= 0 && i < YY_ACTTAB_COUNT );
666
+ assert( yy_lookahead[i] == iLookAhead );
667
+ #endif
668
+ return yy_action[i];
669
+ }
670
+
671
+ /*
672
+ ** The following routine is called if the stack overflows.
673
+ */
674
+ static void yyStackOverflow(yyParser *yypParser) {
675
+ OPMLARG_FETCH;
676
+ yypParser->yytos--;
677
+ #ifndef NDEBUG
678
+
679
+ if ( yyTraceFILE ) {
680
+ fprintf(yyTraceFILE, "%sStack Overflow!\n", yyTracePrompt);
681
+ }
682
+
683
+ #endif
684
+
685
+ while ( yypParser->yytos > yypParser->yystack ) {
686
+ yy_pop_parser_stack(yypParser);
687
+ }
688
+
689
+ /* Here code is inserted which will execute if the parser
690
+ ** stack every overflows */
691
+ /******** Begin %stack_overflow code ******************************************/
692
+ /******** End %stack_overflow code ********************************************/
693
+ OPMLARG_STORE; /* Suppress warning about unused %extra_argument var */
694
+ }
695
+
696
+ /*
697
+ ** Print tracing information for a SHIFT action
698
+ */
699
+ #ifndef NDEBUG
700
+ static void yyTraceShift(yyParser *yypParser, int yyNewState) {
701
+ if ( yyTraceFILE ) {
702
+ if ( yyNewState < YYNSTATE ) {
703
+ fprintf(yyTraceFILE, "%sShift '%s', go to state %d\n",
704
+ yyTracePrompt, yyTokenName[yypParser->yytos->major],
705
+ yyNewState);
706
+ } else {
707
+ fprintf(yyTraceFILE, "%sShift '%s'\n",
708
+ yyTracePrompt, yyTokenName[yypParser->yytos->major]);
709
+ }
710
+ }
711
+ }
712
+ #else
713
+ # define yyTraceShift(X,Y)
714
+ #endif
715
+
716
+ /*
717
+ ** Perform a shift action.
718
+ */
719
+ static void yy_shift(
720
+ yyParser *yypParser, /* The parser to be shifted */
721
+ int yyNewState, /* The new state to shift in */
722
+ int yyMajor, /* The major token to shift in */
723
+ OPMLTOKENTYPE yyMinor /* The minor token to shift in */
724
+ ) {
725
+ yyStackEntry *yytos;
726
+ yypParser->yytos++;
727
+ #ifdef YYTRACKMAXSTACKDEPTH
728
+
729
+ if ( (int)(yypParser->yytos - yypParser->yystack) > yypParser->yyhwm ) {
730
+ yypParser->yyhwm++;
731
+ assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );
732
+ }
733
+
734
+ #endif
735
+ #if YYSTACKDEPTH>0
736
+
737
+ if ( yypParser->yytos >= &yypParser->yystack[YYSTACKDEPTH] ) {
738
+ yyStackOverflow(yypParser);
739
+ return;
740
+ }
741
+
742
+ #else
743
+
744
+ if ( yypParser->yytos >= &yypParser->yystack[yypParser->yystksz] ) {
745
+ if ( yyGrowStack(yypParser) ) {
746
+ yyStackOverflow(yypParser);
747
+ return;
748
+ }
749
+ }
750
+
751
+ #endif
752
+
753
+ if ( yyNewState > YY_MAX_SHIFT ) {
754
+ yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
755
+ }
756
+
757
+ yytos = yypParser->yytos;
758
+ yytos->stateno = (YYACTIONTYPE)yyNewState;
759
+ yytos->major = (YYCODETYPE)yyMajor;
760
+ yytos->minor.yy0 = yyMinor;
761
+ yyTraceShift(yypParser, yyNewState);
762
+ }
763
+
764
+ /* The following table contains information about every rule that
765
+ ** is used during the reduce.
766
+ */
767
+ static const struct {
768
+ YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
769
+ unsigned char nrhs; /* Number of right-hand side symbols in the rule */
770
+ } yyRuleInfo[] = {
771
+ { 17, 1 },
772
+ { 18, 2 },
773
+ { 18, 3 },
774
+ { 19, 4 },
775
+ { 19, 3 },
776
+ { 20, 3 },
777
+ { 20, 2 },
778
+ { 22, 2 },
779
+ { 21, 3 },
780
+ { 21, 2 },
781
+ { 23, 2 },
782
+ { 23, 1 },
783
+ { 24, 2 },
784
+ { 24, 2 },
785
+ { 24, 3 },
786
+ { 24, 3 },
787
+ { 24, 1 },
788
+ };
789
+
790
+ static void yy_accept(yyParser*); /* Forward Declaration */
791
+
792
+ /*
793
+ ** Perform a reduce action and the shift that must immediately
794
+ ** follow the reduce.
795
+ */
796
+ static void yy_reduce(
797
+ yyParser *yypParser, /* The parser */
798
+ unsigned int yyruleno /* Number of the rule by which to reduce */
799
+ ) {
800
+ int yygoto; /* The next state */
801
+ int yyact; /* The next action */
802
+ yyStackEntry *yymsp; /* The top of the parser's stack */
803
+ int yysize; /* Amount to pop the stack */
804
+ OPMLARG_FETCH;
805
+ yymsp = yypParser->yytos;
806
+ #ifndef NDEBUG
807
+
808
+ if ( yyTraceFILE && yyruleno < (int)(sizeof(yyRuleName) / sizeof(yyRuleName[0])) ) {
809
+ yysize = yyRuleInfo[yyruleno].nrhs;
810
+ fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
811
+ yyRuleName[yyruleno], yymsp[-yysize].stateno);
812
+ }
813
+
814
+ #endif /* NDEBUG */
815
+
816
+ /* Check that the stack is large enough to grow by a single entry
817
+ ** if the RHS of the rule is empty. This ensures that there is room
818
+ ** enough on the stack to push the LHS value */
819
+ if ( yyRuleInfo[yyruleno].nrhs == 0 ) {
820
+ #ifdef YYTRACKMAXSTACKDEPTH
821
+
822
+ if ( (int)(yypParser->yytos - yypParser->yystack) > yypParser->yyhwm ) {
823
+ yypParser->yyhwm++;
824
+ assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
825
+ }
826
+
827
+ #endif
828
+ #if YYSTACKDEPTH>0
829
+
830
+ if ( yypParser->yytos >= &yypParser->yystack[YYSTACKDEPTH - 1] ) {
831
+ yyStackOverflow(yypParser);
832
+ return;
833
+ }
834
+
835
+ #else
836
+
837
+ if ( yypParser->yytos >= &yypParser->yystack[yypParser->yystksz - 1] ) {
838
+ if ( yyGrowStack(yypParser) ) {
839
+ yyStackOverflow(yypParser);
840
+ return;
841
+ }
842
+
843
+ yymsp = yypParser->yytos;
844
+ }
845
+
846
+ #endif
847
+ }
848
+
849
+ switch ( yyruleno ) {
850
+ /* Beginning here are the reduction cases. A typical example
851
+ ** follows:
852
+ ** case 0:
853
+ ** #line <lineno> <grammarfile>
854
+ ** { ... } // User supplied code
855
+ ** #line <lineno> <thisfile>
856
+ ** break;
857
+ */
858
+ /********** Begin reduce actions **********************************************/
859
+ case 0: { /* doc ::= doc_xml */
860
+ engine->root = yymsp[0].minor.yy0;
861
+ }
862
+ break;
863
+
864
+ default:
865
+ /* (1) doc_xml ::= OPML_XML doc_opml */
866
+ yytestcase(yyruleno == 1);
867
+ /* (2) doc_xml ::= OPML_XML doc_opml OPML_WSNL */ yytestcase(yyruleno == 2);
868
+ /* (3) doc_opml ::= OPML_OPML_OPEN opml_header opml_body OPML_OPML_CLOSE */ yytestcase(yyruleno == 3);
869
+ /* (4) doc_opml ::= OPML_OPML_OPEN opml_body OPML_OPML_CLOSE */ yytestcase(yyruleno == 4);
870
+ /* (5) opml_header ::= OPML_HEAD_OPEN opml_title OPML_HEAD_CLOSE */ yytestcase(yyruleno == 5);
871
+ /* (6) opml_header ::= OPML_HEAD_OPEN OPML_HEAD_CLOSE */ yytestcase(yyruleno == 6);
872
+ /* (7) opml_title ::= OPML_TITLE_OPEN OPML_TITLE_CLOSE */ yytestcase(yyruleno == 7);
873
+ /* (8) opml_body ::= OPML_BODY_OPEN opml_outlines OPML_BODY_CLOSE */ yytestcase(yyruleno == 8);
874
+ /* (9) opml_body ::= OPML_BODY_OPEN OPML_BODY_CLOSE */ yytestcase(yyruleno == 9);
875
+ /* (10) opml_outlines ::= opml_outlines opml_outline */ yytestcase(yyruleno == 10);
876
+ /* (11) opml_outlines ::= opml_outline (OPTIMIZED OUT) */ assert(yyruleno != 11);
877
+ /* (12) opml_outline ::= OPML_OUTLINE_OPEN OPML_OUTLINE_CLOSE */ yytestcase(yyruleno == 12);
878
+ /* (13) opml_outline ::= OPML_OUTLINE_PREAMBLE OPML_OUTLINE_CLOSE */ yytestcase(yyruleno == 13);
879
+ /* (14) opml_outline ::= OPML_OUTLINE_OPEN opml_outlines OPML_OUTLINE_CLOSE */ yytestcase(yyruleno == 14);
880
+ /* (15) opml_outline ::= OPML_OUTLINE_METADATA opml_outlines OPML_OUTLINE_CLOSE */ yytestcase(yyruleno == 15);
881
+ /* (16) opml_outline ::= OPML_OUTLINE_SELF_CLOSE */ yytestcase(yyruleno == 16);
882
+ break;
883
+ /********** End reduce actions ************************************************/
884
+ };
885
+
886
+ assert( yyruleno < sizeof(yyRuleInfo) / sizeof(yyRuleInfo[0]) );
887
+
888
+ yygoto = yyRuleInfo[yyruleno].lhs;
889
+
890
+ yysize = yyRuleInfo[yyruleno].nrhs;
891
+
892
+ yyact = yy_find_reduce_action(yymsp[-yysize].stateno, (YYCODETYPE)yygoto);
893
+
894
+ if ( yyact <= YY_MAX_SHIFTREDUCE ) {
895
+ if ( yyact > YY_MAX_SHIFT ) {
896
+ yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
897
+ }
898
+
899
+ yymsp -= yysize - 1;
900
+ yypParser->yytos = yymsp;
901
+ yymsp->stateno = (YYACTIONTYPE)yyact;
902
+ yymsp->major = (YYCODETYPE)yygoto;
903
+ yyTraceShift(yypParser, yyact);
904
+ } else {
905
+ assert( yyact == YY_ACCEPT_ACTION );
906
+ yypParser->yytos -= yysize;
907
+ yy_accept(yypParser);
908
+ }
909
+ }
910
+
911
+ /*
912
+ ** The following code executes when the parse fails
913
+ */
914
+ #ifndef YYNOERRORRECOVERY
915
+ static void yy_parse_failed(
916
+ yyParser *yypParser /* The parser */
917
+ ) {
918
+ OPMLARG_FETCH;
919
+ #ifndef NDEBUG
920
+
921
+ if ( yyTraceFILE ) {
922
+ fprintf(yyTraceFILE, "%sFail!\n", yyTracePrompt);
923
+ }
924
+
925
+ #endif
926
+
927
+ while ( yypParser->yytos > yypParser->yystack ) {
928
+ yy_pop_parser_stack(yypParser);
929
+ }
930
+
931
+ /* Here code is inserted which will be executed whenever the
932
+ ** parser fails */
933
+ /************ Begin %parse_failure code ***************************************/
934
+
935
+ fprintf(stderr, "Parser failed to successfully parse.\n");
936
+ /************ End %parse_failure code *****************************************/
937
+ OPMLARG_STORE; /* Suppress warning about unused %extra_argument variable */
938
+ }
939
+ #endif /* YYNOERRORRECOVERY */
940
+
941
+ /*
942
+ ** The following code executes when a syntax error first occurs.
943
+ */
944
+ static void yy_syntax_error(
945
+ yyParser *yypParser, /* The parser */
946
+ int yymajor, /* The major type of the error token */
947
+ OPMLTOKENTYPE yyminor /* The minor type of the error token */
948
+ ) {
949
+ OPMLARG_FETCH;
950
+ #define TOKEN yyminor
951
+ /************ Begin %syntax_error code ****************************************/
952
+
953
+ fprintf(stderr, "Parser syntax error.\n");
954
+ #ifndef NDEBUG
955
+ fprintf(stderr, "Parser syntax error.\n");
956
+ int n = sizeof(yyTokenName) / sizeof(yyTokenName[0]);
957
+
958
+ for (int i = 0; i < n; ++i) {
959
+ int a = yy_find_shift_action(yypParser, (YYCODETYPE)i);
960
+
961
+ if (a < YYNSTATE + YYNRULE) {
962
+ fprintf(stderr, "expected token: %s\n", yyTokenName[i]);
963
+ }
964
+ }
965
+
966
+ #endif
967
+ /************ End %syntax_error code ******************************************/
968
+ OPMLARG_STORE; /* Suppress warning about unused %extra_argument variable */
969
+ }
970
+
971
+ /*
972
+ ** The following is executed when the parser accepts
973
+ */
974
+ static void yy_accept(
975
+ yyParser *yypParser /* The parser */
976
+ ) {
977
+ OPMLARG_FETCH;
978
+ #ifndef NDEBUG
979
+
980
+ if ( yyTraceFILE ) {
981
+ fprintf(yyTraceFILE, "%sAccept!\n", yyTracePrompt);
982
+ }
983
+
984
+ #endif
985
+ #ifndef YYNOERRORRECOVERY
986
+ yypParser->yyerrcnt = -1;
987
+ #endif
988
+ assert( yypParser->yytos == yypParser->yystack );
989
+ /* Here code is inserted which will be executed whenever the
990
+ ** parser accepts */
991
+ /*********** Begin %parse_accept code *****************************************/
992
+
993
+ // printf("parsing completed successfully!\n");
994
+ /*********** End %parse_accept code *******************************************/
995
+ OPMLARG_STORE; /* Suppress warning about unused %extra_argument variable */
996
+ }
997
+
998
+ /* The main parser program.
999
+ ** The first argument is a pointer to a structure obtained from
1000
+ ** "OPMLAlloc" which describes the current state of the parser.
1001
+ ** The second argument is the major token number. The third is
1002
+ ** the minor token. The fourth optional argument is whatever the
1003
+ ** user wants (and specified in the grammar) and is available for
1004
+ ** use by the action routines.
1005
+ **
1006
+ ** Inputs:
1007
+ ** <ul>
1008
+ ** <li> A pointer to the parser (an opaque structure.)
1009
+ ** <li> The major token number.
1010
+ ** <li> The minor token number.
1011
+ ** <li> An option argument of a grammar-specified type.
1012
+ ** </ul>
1013
+ **
1014
+ ** Outputs:
1015
+ ** None.
1016
+ */
1017
+ void OPML(
1018
+ void *yyp, /* The parser */
1019
+ int yymajor, /* The major token code number */
1020
+ OPMLTOKENTYPE yyminor /* The value for the token */
1021
+ OPMLARG_PDECL /* Optional %extra_argument parameter */
1022
+ ) {
1023
+ YYMINORTYPE yyminorunion;
1024
+ unsigned int yyact; /* The parser action. */
1025
+ #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
1026
+ int yyendofinput; /* True if we are at the end of input */
1027
+ #endif
1028
+ #ifdef YYERRORSYMBOL
1029
+ int yyerrorhit = 0; /* True if yymajor has invoked an error */
1030
+ #endif
1031
+ yyParser *yypParser; /* The parser */
1032
+
1033
+ yypParser = (yyParser*)yyp;
1034
+ assert( yypParser->yytos != 0 );
1035
+ #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
1036
+ yyendofinput = (yymajor == 0);
1037
+ #endif
1038
+ OPMLARG_STORE;
1039
+
1040
+ #ifndef NDEBUG
1041
+
1042
+ if ( yyTraceFILE ) {
1043
+ fprintf(yyTraceFILE, "%sInput '%s'\n", yyTracePrompt, yyTokenName[yymajor]);
1044
+ }
1045
+
1046
+ #endif
1047
+
1048
+ do {
1049
+ yyact = yy_find_shift_action(yypParser, (YYCODETYPE)yymajor);
1050
+
1051
+ if ( yyact <= YY_MAX_SHIFTREDUCE ) {
1052
+ yy_shift(yypParser, yyact, yymajor, yyminor);
1053
+ #ifndef YYNOERRORRECOVERY
1054
+ yypParser->yyerrcnt--;
1055
+ #endif
1056
+ yymajor = YYNOCODE;
1057
+ } else if ( yyact <= YY_MAX_REDUCE ) {
1058
+ yy_reduce(yypParser, yyact - YY_MIN_REDUCE);
1059
+ } else {
1060
+ assert( yyact == YY_ERROR_ACTION );
1061
+ yyminorunion.yy0 = yyminor;
1062
+ #ifdef YYERRORSYMBOL
1063
+ int yymx;
1064
+ #endif
1065
+ #ifndef NDEBUG
1066
+
1067
+ if ( yyTraceFILE ) {
1068
+ fprintf(yyTraceFILE, "%sSyntax Error!\n", yyTracePrompt);
1069
+ }
1070
+
1071
+ #endif
1072
+ #ifdef YYERRORSYMBOL
1073
+
1074
+ /* A syntax error has occurred.
1075
+ ** The response to an error depends upon whether or not the
1076
+ ** grammar defines an error token "ERROR".
1077
+ **
1078
+ ** This is what we do if the grammar does define ERROR:
1079
+ **
1080
+ ** * Call the %syntax_error function.
1081
+ **
1082
+ ** * Begin popping the stack until we enter a state where
1083
+ ** it is legal to shift the error symbol, then shift
1084
+ ** the error symbol.
1085
+ **
1086
+ ** * Set the error count to three.
1087
+ **
1088
+ ** * Begin accepting and shifting new tokens. No new error
1089
+ ** processing will occur until three tokens have been
1090
+ ** shifted successfully.
1091
+ **
1092
+ */
1093
+ if ( yypParser->yyerrcnt < 0 ) {
1094
+ yy_syntax_error(yypParser, yymajor, yyminor);
1095
+ }
1096
+
1097
+ yymx = yypParser->yytos->major;
1098
+
1099
+ if ( yymx == YYERRORSYMBOL || yyerrorhit ) {
1100
+ #ifndef NDEBUG
1101
+
1102
+ if ( yyTraceFILE ) {
1103
+ fprintf(yyTraceFILE, "%sDiscard input token %s\n",
1104
+ yyTracePrompt, yyTokenName[yymajor]);
1105
+ }
1106
+
1107
+ #endif
1108
+ yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
1109
+ yymajor = YYNOCODE;
1110
+ } else {
1111
+ while ( yypParser->yytos >= yypParser->yystack
1112
+ && yymx != YYERRORSYMBOL
1113
+ && (yyact = yy_find_reduce_action(
1114
+ yypParser->yytos->stateno,
1115
+ YYERRORSYMBOL)) >= YY_MIN_REDUCE
1116
+ ) {
1117
+ yy_pop_parser_stack(yypParser);
1118
+ }
1119
+
1120
+ if ( yypParser->yytos < yypParser->yystack || yymajor == 0 ) {
1121
+ yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
1122
+ yy_parse_failed(yypParser);
1123
+ #ifndef YYNOERRORRECOVERY
1124
+ yypParser->yyerrcnt = -1;
1125
+ #endif
1126
+ yymajor = YYNOCODE;
1127
+ } else if ( yymx != YYERRORSYMBOL ) {
1128
+ yy_shift(yypParser, yyact, YYERRORSYMBOL, yyminor);
1129
+ }
1130
+ }
1131
+
1132
+ yypParser->yyerrcnt = 3;
1133
+ yyerrorhit = 1;
1134
+ #elif defined(YYNOERRORRECOVERY)
1135
+ /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
1136
+ ** do any kind of error recovery. Instead, simply invoke the syntax
1137
+ ** error routine and continue going as if nothing had happened.
1138
+ **
1139
+ ** Applications can set this macro (for example inside %include) if
1140
+ ** they intend to abandon the parse upon the first syntax error seen.
1141
+ */
1142
+ yy_syntax_error(yypParser, yymajor, yyminor);
1143
+ yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
1144
+ yymajor = YYNOCODE;
1145
+
1146
+ #else /* YYERRORSYMBOL is not defined */
1147
+
1148
+ /* This is what we do if the grammar does not define ERROR:
1149
+ **
1150
+ ** * Report an error message, and throw away the input token.
1151
+ **
1152
+ ** * If the input token is $, then fail the parse.
1153
+ **
1154
+ ** As before, subsequent error messages are suppressed until
1155
+ ** three input tokens have been successfully shifted.
1156
+ */
1157
+ if ( yypParser->yyerrcnt <= 0 ) {
1158
+ yy_syntax_error(yypParser, yymajor, yyminor);
1159
+ }
1160
+
1161
+ yypParser->yyerrcnt = 3;
1162
+ yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
1163
+
1164
+ if ( yyendofinput ) {
1165
+ yy_parse_failed(yypParser);
1166
+ #ifndef YYNOERRORRECOVERY
1167
+ yypParser->yyerrcnt = -1;
1168
+ #endif
1169
+ }
1170
+
1171
+ yymajor = YYNOCODE;
1172
+ #endif
1173
+ }
1174
+ } while ( yymajor != YYNOCODE && yypParser->yytos > yypParser->yystack );
1175
+
1176
+ #ifndef NDEBUG
1177
+
1178
+ if ( yyTraceFILE ) {
1179
+ yyStackEntry *i;
1180
+ char cDiv = '[';
1181
+ fprintf(yyTraceFILE, "%sReturn. Stack=", yyTracePrompt);
1182
+
1183
+ for (i = &yypParser->yystack[1]; i <= yypParser->yytos; i++) {
1184
+ fprintf(yyTraceFILE, "%c%s", cDiv, yyTokenName[i->major]);
1185
+ cDiv = ' ';
1186
+ }
1187
+
1188
+ fprintf(yyTraceFILE, "]\n");
1189
+ }
1190
+
1191
+ #endif
1192
+ return;
1193
+ }