hpricot 0.6.164 → 0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  #!/usr/bin/env ruby
2
3
 
3
4
  require 'test/unit'
@@ -17,9 +18,9 @@ class TestBuilder < Test::Unit::TestCase
17
18
  end
18
19
 
19
20
  def test_latin1_entities
20
- doc = Hpricot() { b "\200\225" }
21
+ doc = Hpricot() { b "ۥ" }
21
22
  assert_equal "<b>&#8364;&#8226;</b>", doc.to_html
22
- assert_equal "\342\202\254\342\200\242", doc.at("text()").to_s
23
+ assert_equal "ۥ", doc.at("text()").to_s
23
24
  end
24
25
 
25
26
  def test_escaping_attrs
@@ -29,8 +30,7 @@ class TestBuilder < Test::Unit::TestCase
29
30
  end
30
31
 
31
32
  def test_korean_utf8_entities
32
- # a = '한글'
33
- a = "\xed\x95\x9c\xea\xb8\x80"
33
+ a = '한글'
34
34
  doc = Hpricot() { b a }
35
35
  assert_equal "<b>&#54620;&#44544;</b>", doc.to_html
36
36
  end
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  #!/usr/bin/env ruby
2
3
 
3
4
  require 'test/unit'
@@ -14,13 +15,13 @@ class TestParser < Test::Unit::TestCase
14
15
 
15
16
  # Test creating a new element
16
17
  def test_new_element
17
- elem = Hpricot::Elem.new(Hpricot::STag.new('form'))
18
+ elem = Hpricot::Elem.new('form')
18
19
  assert_not_nil(elem)
19
20
  assert_not_nil(elem.attributes)
20
21
  end
21
22
 
22
23
  def test_scan_text
23
- assert_equal 'FOO', Hpricot.make("FOO").first.content
24
+ assert_equal 'FOO', Hpricot.make("FOO").children.first.content
24
25
  end
25
26
 
26
27
  def test_filter_by_attr
@@ -121,7 +122,7 @@ class TestParser < Test::Unit::TestCase
121
122
  assert_equal 60, @boingboing.search("h3").length
122
123
  assert_equal 59, @boingboing.search("h3[text()!='College kids reportedly taking more smart drugs']").length
123
124
  assert_equal 17, @boingboing.search("h3[text()$='s']").length
124
- assert_equal 129, @boingboing.search("p[text()]").length
125
+ assert_equal 116, @boingboing.search("p[text()]").length
125
126
  assert_equal 211, @boingboing.search("p").length
126
127
  end
127
128
 
@@ -161,10 +162,10 @@ class TestParser < Test::Unit::TestCase
161
162
  assert_equal 60, @boingboing.search("/*/body//p[@class='posted']").length
162
163
  assert_equal 18, @boingboing.search("//script").length
163
164
  divs = @boingboing.search("//script/../div")
164
- assert_equal 1, divs.length
165
+ assert_equal 2, divs.length
165
166
  imgs = @boingboing.search('//div/p/a/img')
166
- assert_equal 15, imgs.length
167
- assert_equal 17, @boingboing.search('//div').search('p/a/img').length
167
+ assert_equal 16, imgs.length
168
+ assert_equal 16, @boingboing.search('//div').search('p/a/img').length
168
169
  assert imgs.all? { |x| x.name == 'img' }
169
170
  end
170
171
 
@@ -172,10 +173,10 @@ class TestParser < Test::Unit::TestCase
172
173
  @boingboing = Hpricot.parse(TestFiles::BOINGBOING)
173
174
  assert_equal 2, @boingboing.search('//link[@rel="alternate"]').length
174
175
  p_imgs = @boingboing.search('//div/p[/a/img]')
175
- assert_equal 15, p_imgs.length
176
+ assert_equal 16, p_imgs.length
176
177
  assert p_imgs.all? { |x| x.name == 'p' }
177
178
  p_imgs = @boingboing.search('//div/p[a/img]')
178
- assert_equal 18, p_imgs.length
179
+ assert_equal 16, p_imgs.length
179
180
  assert p_imgs.all? { |x| x.name == 'p' }
180
181
  assert_equal 1, @boingboing.search('//input[@checked]').length
181
182
  end
@@ -218,7 +219,7 @@ class TestParser < Test::Unit::TestCase
218
219
  def test_many_paths
219
220
  @boingboing = Hpricot.parse(TestFiles::BOINGBOING)
220
221
  assert_equal 62, @boingboing.search('p.posted, link[@rel="alternate"]').length
221
- assert_equal 20, @boingboing.search('//div/p[a/img]|//link[@rel="alternate"]').length
222
+ assert_equal 18, @boingboing.search('//div/p[a/img]|//link[@rel="alternate"]').length
222
223
  end
223
224
 
224
225
  def test_stacked_search
@@ -306,10 +307,8 @@ class TestParser < Test::Unit::TestCase
306
307
  assert_equal "blah='blah'", doc.children[2].content
307
308
  end
308
309
 
309
- def test_buffer_error
310
- assert_raise Hpricot::ParseError, "ran out of buffer space on element <input>, starting on line 3." do
311
- Hpricot(%{<p>\n\n<input type="hidden" name="__VIEWSTATE" value="#{(("X" * 2000) + "\n") * 22}" />\n\n</p>})
312
- end
310
+ def test_no_buffer_error
311
+ Hpricot(%{<p>\n\n<input type="hidden" name="__VIEWSTATE" value="#{(("X" * 2000) + "\n") * 44}" />\n\n</p>})
313
312
  end
314
313
 
315
314
  def test_youtube_attr
@@ -383,4 +382,28 @@ class TestParser < Test::Unit::TestCase
383
382
  assert (doc/"//t:sam").size > 0 # at least this should probably work
384
383
  # assert (doc/"//sam").size > 0 # this would be nice
385
384
  end
385
+
386
+ def test_uxs_ignores_non_entities
387
+ assert_equal 'abc', Hpricot.uxs('abc')
388
+ end
389
+
390
+ def test_uxs_handles_gt_lt_amp_quot
391
+ assert_equal '"&<>', Hpricot.uxs('&quot;&amp;&lt;&gt;')
392
+ end
393
+
394
+ def test_uxs_handles_numeric_values
395
+ if String.method_defined? :encoding
396
+ assert_equal "é", Hpricot.uxs('&#233;')
397
+ else
398
+ assert_equal "\303\251", Hpricot.uxs('&#233;')
399
+ end
400
+ end
401
+
402
+ def test_uxs_handles_entities
403
+ if String.method_defined? :encoding
404
+ assert_equal "é", Hpricot.uxs('&eacute;')
405
+ else
406
+ assert_equal "\303\251", Hpricot.uxs('&eacute;')
407
+ end
408
+ end
386
409
  end
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  #!/usr/bin/env ruby
2
3
 
3
4
  require 'test/unit'
@@ -9,7 +10,10 @@ class TestPreserved < Test::Unit::TestCase
9
10
  doc = Hpricot(str)
10
11
  yield doc if block_given?
11
12
  str2 = doc.to_original_html
12
- [*str].zip([*str2]).each do |s1, s2|
13
+ if RUBY_VERSION =~ /^1.9/
14
+ str2.force_encoding('UTF-8')
15
+ end
16
+ str.lines.zip(str2.lines).each do |s1, s2|
13
17
  assert_equal s1, s2
14
18
  end
15
19
  end
@@ -40,7 +44,7 @@ class TestPreserved < Test::Unit::TestCase
40
44
 
41
45
  def test_escaping_of_contents
42
46
  doc = Hpricot(TestFiles::BOINGBOING)
43
- assert_equal "Fukuda\342\200\231s Automatic Door opens around your body as you pass through it. The idea is to save energy and keep the room clean.", doc.at("img[@alt='200606131240']").next.to_s.strip
47
+ assert_equal "Fukuda’s Automatic Door opens around your body as you pass through it. The idea is to save energy and keep the room clean.", doc.at("img[@alt='200606131240']").next.to_s.strip
44
48
  end
45
49
 
46
50
  def test_files
metadata CHANGED
@@ -1,36 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
- required_ruby_version: !ruby/object:Gem::Requirement
3
- requirements:
4
- - - '>='
5
- - !ruby/object:Gem::Version
6
- version: "0"
7
- version:
8
- email: why@ruby-lang.org
2
+ name: hpricot
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.7"
5
+ platform: ruby
6
+ authors:
7
+ - why the lucky stiff
8
+ autorequire:
9
+ bindir: bin
9
10
  cert_chain: []
10
11
 
11
- summary: a swift, liberal HTML parser with a fantastic library
12
- post_install_message:
12
+ date: 2009-03-17 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: a swift, liberal HTML parser with a fantastic library
17
+ email: why@ruby-lang.org
18
+ executables: []
19
+
20
+ extensions:
21
+ - ext/hpricot_scan/extconf.rb
22
+ - ext/fast_xs/extconf.rb
13
23
  extra_rdoc_files:
14
24
  - README
15
25
  - CHANGELOG
16
26
  - COPYING
17
- homepage: http://code.whytheluckystiff.net/hpricot/
18
- signing_key:
19
- name: hpricot
20
- rdoc_options:
21
- - --quiet
22
- - --title
23
- - The Hpricot Reference
24
- - --main
25
- - README
26
- - --inline-source
27
- autorequire:
28
- rubyforge_project:
29
- executables: []
30
-
31
- description: a swift, liberal HTML parser with a fantastic library
32
- specification_version: 2
33
- default_executable:
34
27
  files:
35
28
  - CHANGELOG
36
29
  - COPYING
@@ -40,10 +33,6 @@ files:
40
33
  - test/test_preserved.rb
41
34
  - test/test_parser.rb
42
35
  - test/files
43
- - test/load_files.rb
44
- - test/test_builder.rb
45
- - test/test_xml.rb
46
- - test/test_alter.rb
47
36
  - test/files/cy0.html
48
37
  - test/files/pace_application.html
49
38
  - test/files/basic.xhtml
@@ -54,8 +43,12 @@ files:
54
43
  - test/files/immob.html
55
44
  - test/files/why.xml
56
45
  - test/files/uswebgen.html
46
+ - test/load_files.rb
47
+ - test/nokogiri-bench.rb
48
+ - test/test_builder.rb
49
+ - test/test_xml.rb
50
+ - test/test_alter.rb
57
51
  - lib/hpricot
58
- - lib/hpricot.rb
59
52
  - lib/hpricot/tags.rb
60
53
  - lib/hpricot/builder.rb
61
54
  - lib/hpricot/traverse.rb
@@ -67,44 +60,51 @@ files:
67
60
  - lib/hpricot/xchar.rb
68
61
  - lib/hpricot/htmlinfo.rb
69
62
  - lib/hpricot/parse.rb
63
+ - lib/hpricot.rb
70
64
  - extras/mingw-rbconfig.rb
71
65
  - ext/hpricot_scan/hpricot_scan.h
72
- - ext/hpricot_scan/hpricot_gram.h
73
66
  - ext/hpricot_scan/HpricotScanService.java
74
67
  - ext/fast_xs/FastXsService.java
75
68
  - ext/hpricot_scan/hpricot_scan.c
76
- - ext/hpricot_scan/hpricot_gram.c
69
+ - ext/hpricot_scan/hpricot_css.c
77
70
  - ext/fast_xs/fast_xs.c
78
71
  - ext/hpricot_scan/test.rb
79
72
  - ext/hpricot_scan/extconf.rb
80
73
  - ext/fast_xs/extconf.rb
81
74
  - ext/hpricot_scan/hpricot_scan.rl
82
75
  - ext/hpricot_scan/hpricot_scan.java.rl
76
+ - ext/hpricot_scan/hpricot_css.rl
83
77
  - ext/hpricot_scan/hpricot_common.rl
78
+ has_rdoc: true
79
+ homepage: http://code.whytheluckystiff.net/hpricot/
80
+ post_install_message:
81
+ rdoc_options:
82
+ - --quiet
83
+ - --title
84
+ - The Hpricot Reference
85
+ - --main
86
+ - README
87
+ - --inline-source
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
84
96
  required_rubygems_version: !ruby/object:Gem::Requirement
85
97
  requirements:
86
- - - '>='
98
+ - - ">="
87
99
  - !ruby/object:Gem::Version
88
100
  version: "0"
89
101
  version:
90
- extensions:
91
- - ext/hpricot_scan/extconf.rb
92
- - ext/fast_xs/extconf.rb
93
- rubygems_version: 1.2.0
94
102
  requirements: []
95
103
 
96
- authors:
97
- - why the lucky stiff
98
- date: 2008-10-30 07:00:00 +00:00
99
- platform: ruby
104
+ rubyforge_project: hobix
105
+ rubygems_version: 1.3.1
106
+ signing_key:
107
+ specification_version: 2
108
+ summary: a swift, liberal HTML parser with a fantastic library
100
109
  test_files: []
101
110
 
102
- version: !ruby/object:Gem::Version
103
- version: 0.6.164
104
- require_paths:
105
- - lib/universal-java1.6
106
- - lib
107
- dependencies: []
108
-
109
- bindir: bin
110
- has_rdoc: true
@@ -1,882 +0,0 @@
1
- /* Driver template for the LEMON parser generator.
2
- ** The author disclaims copyright to this source code.
3
- */
4
- /* First off, code is include which follows the "include" declaration
5
- ** in the input file. */
6
- #include <stdio.h>
7
- #line 7 "hpricot_gram.y"
8
- #include <ruby.h>
9
- #line 11 "hpricot_gram.c"
10
- /* Next is all token values, in a form suitable for use by makeheaders.
11
- ** This section will be null unless lemon is run with the -m switch.
12
- */
13
- /*
14
- ** These constants (all generated automatically by the parser generator)
15
- ** specify the various kinds of tokens (terminals) that the parser
16
- ** understands.
17
- **
18
- ** Each symbol here is a terminal symbol in the grammar.
19
- */
20
- /* Make sure the INTERFACE macro is defined.
21
- */
22
- #ifndef INTERFACE
23
- # define INTERFACE 1
24
- #endif
25
- /* The next thing included is series of defines which control
26
- ** various aspects of the generated parser.
27
- ** YYCODETYPE is the data type used for storing terminal
28
- ** and nonterminal numbers. "unsigned char" is
29
- ** used if there are fewer than 250 terminals
30
- ** and nonterminals. "int" is used otherwise.
31
- ** YYNOCODE is a number of type YYCODETYPE which corresponds
32
- ** to no legal terminal or nonterminal number. This
33
- ** number is used to fill in empty slots of the hash
34
- ** table.
35
- ** YYFALLBACK If defined, this indicates that one or more tokens
36
- ** have fall-back values which should be used if the
37
- ** original value of the token will not parse.
38
- ** YYACTIONTYPE is the data type used for storing terminal
39
- ** and nonterminal numbers. "unsigned char" is
40
- ** used if there are fewer than 250 rules and
41
- ** states combined. "int" is used otherwise.
42
- ** ParseTOKENTYPE is the data type used for minor tokens given
43
- ** directly to the parser from the tokenizer.
44
- ** YYMINORTYPE is the data type used for all minor tokens.
45
- ** This is typically a union of many types, one of
46
- ** which is ParseTOKENTYPE. The entry in the union
47
- ** for base tokens is called "yy0".
48
- ** YYSTACKDEPTH is the maximum depth of the parser's stack. If
49
- ** zero the stack is dynamically sized using realloc()
50
- ** ParseARG_SDECL A static variable declaration for the %extra_argument
51
- ** ParseARG_PDECL A parameter declaration for the %extra_argument
52
- ** ParseARG_STORE Code to store %extra_argument into yypParser
53
- ** ParseARG_FETCH Code to extract %extra_argument from yypParser
54
- ** YYNSTATE the combined number of states.
55
- ** YYNRULE the number of rules in the grammar
56
- ** YYERRORSYMBOL is the code number of the error symbol. If not
57
- ** defined, then do no error processing.
58
- */
59
- #define YYCODETYPE unsigned char
60
- #define YYNOCODE 16
61
- #define YYACTIONTYPE unsigned char
62
- #define ParseTOKENTYPE VALUE *
63
- typedef union {
64
- ParseTOKENTYPE yy0;
65
- int yy31;
66
- } YYMINORTYPE;
67
- #ifndef YYSTACKDEPTH
68
- #define YYSTACKDEPTH 100
69
- #endif
70
- #define ParseARG_SDECL VALUE doc ;
71
- #define ParseARG_PDECL , VALUE doc
72
- #define ParseARG_FETCH VALUE doc = yypParser->doc
73
- #define ParseARG_STORE yypParser->doc = doc
74
- #define YYNSTATE 17
75
- #define YYNRULE 14
76
- #define YYERRORSYMBOL 10
77
- #define YYERRSYMDT yy31
78
- #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
79
- #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
80
- #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
81
-
82
- /* Next are that tables used to determine what action to take based on the
83
- ** current state and lookahead token. These tables are used to implement
84
- ** functions that take a state number and lookahead value and return an
85
- ** action integer.
86
- **
87
- ** Suppose the action integer is N. Then the action is determined as
88
- ** follows
89
- **
90
- ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead
91
- ** token onto the stack and goto state N.
92
- **
93
- ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE.
94
- **
95
- ** N == YYNSTATE+YYNRULE A syntax error has occurred.
96
- **
97
- ** N == YYNSTATE+YYNRULE+1 The parser accepts its input.
98
- **
99
- ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused
100
- ** slots in the yy_action[] table.
101
- **
102
- ** The action table is constructed as a single large table named yy_action[].
103
- ** Given state S and lookahead X, the action is computed as
104
- **
105
- ** yy_action[ yy_shift_ofst[S] + X ]
106
- **
107
- ** If the index value yy_shift_ofst[S]+X is out of range or if the value
108
- ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]
109
- ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
110
- ** and that yy_default[S] should be used instead.
111
- **
112
- ** The formula above is for computing the action when the lookahead is
113
- ** a terminal symbol. If the lookahead is a non-terminal (as occurs after
114
- ** a reduce action) then the yy_reduce_ofst[] array is used in place of
115
- ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
116
- ** YY_SHIFT_USE_DFLT.
117
- **
118
- ** The following are the tables generated in this section:
119
- **
120
- ** yy_action[] A single table containing all actions.
121
- ** yy_lookahead[] A table containing the lookahead for each entry in
122
- ** yy_action. Used to detect hash collisions.
123
- ** yy_shift_ofst[] For each state, the offset into yy_action for
124
- ** shifting terminals.
125
- ** yy_reduce_ofst[] For each state, the offset into yy_action for
126
- ** shifting non-terminals after a reduce.
127
- ** yy_default[] Default action for each state.
128
- */
129
- static const YYACTIONTYPE yy_action[] = {
130
- /* 0 */ 1, 8, 9, 10, 11, 12, 13, 14, 15, 2,
131
- /* 10 */ 8, 9, 10, 11, 12, 13, 14, 15, 8, 9,
132
- /* 20 */ 10, 11, 12, 13, 14, 15, 32, 6, 5, 16,
133
- /* 30 */ 3, 16, 4, 16, 7,
134
- };
135
- static const YYCODETYPE yy_lookahead[] = {
136
- /* 0 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 1,
137
- /* 10 */ 2, 3, 4, 5, 6, 7, 8, 9, 2, 3,
138
- /* 20 */ 4, 5, 6, 7, 8, 9, 11, 12, 13, 14,
139
- /* 30 */ 13, 14, 13, 14, 14,
140
- };
141
- #define YY_SHIFT_USE_DFLT (-2)
142
- #define YY_SHIFT_MAX 5
143
- static const signed char yy_shift_ofst[] = {
144
- /* 0 */ -1, 16, 16, 8, 8, 8,
145
- };
146
- #define YY_REDUCE_USE_DFLT (-1)
147
- #define YY_REDUCE_MAX 5
148
- static const signed char yy_reduce_ofst[] = {
149
- /* 0 */ 15, 17, 19, 20, 20, 20,
150
- };
151
- static const YYACTIONTYPE yy_default[] = {
152
- /* 0 */ 31, 31, 31, 18, 20, 19, 17, 21, 23, 24,
153
- /* 10 */ 25, 26, 27, 28, 29, 30, 22,
154
- };
155
- #define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
156
-
157
- /* The next table maps tokens into fallback tokens. If a construct
158
- ** like the following:
159
- **
160
- ** %fallback ID X Y Z.
161
- **
162
- ** appears in the grammer, then ID becomes a fallback token for X, Y,
163
- ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser
164
- ** but it does not parse, the type of the token is changed to ID and
165
- ** the parse is retried before an error is thrown.
166
- */
167
- #ifdef YYFALLBACK
168
- static const YYCODETYPE yyFallback[] = {
169
- };
170
- #endif /* YYFALLBACK */
171
-
172
- /* The following structure represents a single element of the
173
- ** parser's stack. Information stored includes:
174
- **
175
- ** + The state number for the parser at this level of the stack.
176
- **
177
- ** + The value of the token stored at this level of the stack.
178
- ** (In other words, the "major" token.)
179
- **
180
- ** + The semantic value stored at this level of the stack. This is
181
- ** the information used by the action routines in the grammar.
182
- ** It is sometimes called the "minor" token.
183
- */
184
- struct yyStackEntry {
185
- int stateno; /* The state-number */
186
- int major; /* The major token value. This is the code
187
- ** number for the token at this stack level */
188
- YYMINORTYPE minor; /* The user-supplied minor token value. This
189
- ** is the value of the token */
190
- };
191
- typedef struct yyStackEntry yyStackEntry;
192
-
193
- /* The state of the parser is completely contained in an instance of
194
- ** the following structure */
195
- struct yyParser {
196
- int yyidx; /* Index of top element in stack */
197
- int yyerrcnt; /* Shifts left before out of the error */
198
- ParseARG_SDECL /* A place to hold %extra_argument */
199
- #if YYSTACKDEPTH<=0
200
- int yystksz; /* Current side of the stack */
201
- yyStackEntry *yystack; /* The parser's stack */
202
- #else
203
- yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
204
- #endif
205
- };
206
- typedef struct yyParser yyParser;
207
-
208
- #ifndef NDEBUG
209
- #include <stdio.h>
210
- static FILE *yyTraceFILE = 0;
211
- static char *yyTracePrompt = 0;
212
- #endif /* NDEBUG */
213
-
214
- #ifndef NDEBUG
215
- /*
216
- ** Turn parser tracing on by giving a stream to which to write the trace
217
- ** and a prompt to preface each trace message. Tracing is turned off
218
- ** by making either argument NULL
219
- **
220
- ** Inputs:
221
- ** <ul>
222
- ** <li> A FILE* to which trace output should be written.
223
- ** If NULL, then tracing is turned off.
224
- ** <li> A prefix string written at the beginning of every
225
- ** line of trace output. If NULL, then tracing is
226
- ** turned off.
227
- ** </ul>
228
- **
229
- ** Outputs:
230
- ** None.
231
- */
232
- void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
233
- yyTraceFILE = TraceFILE;
234
- yyTracePrompt = zTracePrompt;
235
- if( yyTraceFILE==0 ) yyTracePrompt = 0;
236
- else if( yyTracePrompt==0 ) yyTraceFILE = 0;
237
- }
238
- #endif /* NDEBUG */
239
-
240
- #ifndef NDEBUG
241
- /* For tracing shifts, the names of all terminals and nonterminals
242
- ** are required. The following table supplies these names */
243
- static const char *const yyTokenName[] = {
244
- "$", "STAG", "DOCTYPE", "XMLDECL",
245
- "PROCINS", "TEXT", "EMPTYTAG", "COMMENT",
246
- "CDATA", "ETAG", "error", "doc",
247
- "html", "fragments", "fragment",
248
- };
249
- #endif /* NDEBUG */
250
-
251
- #ifndef NDEBUG
252
- /* For tracing reduce actions, the names of all rules are required.
253
- */
254
- static const char *const yyRuleName[] = {
255
- /* 0 */ "doc ::= html",
256
- /* 1 */ "html ::= STAG fragments",
257
- /* 2 */ "html ::= fragments",
258
- /* 3 */ "fragments ::= fragments STAG fragments",
259
- /* 4 */ "fragments ::= fragments fragment",
260
- /* 5 */ "fragments ::= fragment",
261
- /* 6 */ "fragment ::= DOCTYPE",
262
- /* 7 */ "fragment ::= XMLDECL",
263
- /* 8 */ "fragment ::= PROCINS",
264
- /* 9 */ "fragment ::= TEXT",
265
- /* 10 */ "fragment ::= EMPTYTAG",
266
- /* 11 */ "fragment ::= COMMENT",
267
- /* 12 */ "fragment ::= CDATA",
268
- /* 13 */ "fragment ::= ETAG",
269
- };
270
- #endif /* NDEBUG */
271
-
272
-
273
- #if YYSTACKDEPTH<=0
274
- /*
275
- ** Try to increase the size of the parser stack.
276
- */
277
- static void yyGrowStack(yyParser *p){
278
- int newSize;
279
- yyStackEntry *pNew;
280
-
281
- newSize = p->yystksz*2 + 100;
282
- pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
283
- if( pNew ){
284
- p->yystack = pNew;
285
- p->yystksz = newSize;
286
- #ifndef NDEBUG
287
- if( yyTraceFILE ){
288
- fprintf(yyTraceFILE,"%sStack grows to %d entries!\n",
289
- yyTracePrompt, p->yystksz);
290
- }
291
- #endif
292
- }
293
- }
294
- #endif
295
-
296
- /*
297
- ** This function allocates a new parser.
298
- ** The only argument is a pointer to a function which works like
299
- ** malloc.
300
- **
301
- ** Inputs:
302
- ** A pointer to the function used to allocate memory.
303
- **
304
- ** Outputs:
305
- ** A pointer to a parser. This pointer is used in subsequent calls
306
- ** to Parse and ParseFree.
307
- */
308
- void *ParseAlloc(void *(*mallocProc)(size_t)){
309
- yyParser *pParser;
310
- pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );
311
- if( pParser ){
312
- pParser->yyidx = -1;
313
- #if YYSTACKDEPTH<=0
314
- yyGrowStack(pParser);
315
- #endif
316
- }
317
- return pParser;
318
- }
319
-
320
- /* The following function deletes the value associated with a
321
- ** symbol. The symbol can be either a terminal or nonterminal.
322
- ** "yymajor" is the symbol code, and "yypminor" is a pointer to
323
- ** the value.
324
- */
325
- static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){
326
- switch( yymajor ){
327
- /* Here is inserted the actions which take place when a
328
- ** terminal or non-terminal is destroyed. This can happen
329
- ** when the symbol is popped from the stack during a
330
- ** reduce or during error processing or when a parser is
331
- ** being destroyed before it is finished parsing.
332
- **
333
- ** Note: during a reduce, the only symbols destroyed are those
334
- ** which appear on the RHS of the rule, but which are not used
335
- ** inside the C code.
336
- */
337
- default: break; /* If no destructor action specified: do nothing */
338
- }
339
- }
340
-
341
- /*
342
- ** Pop the parser's stack once.
343
- **
344
- ** If there is a destructor routine associated with the token which
345
- ** is popped from the stack, then call it.
346
- **
347
- ** Return the major token number for the symbol popped.
348
- */
349
- static int yy_pop_parser_stack(yyParser *pParser){
350
- YYCODETYPE yymajor;
351
- yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
352
-
353
- if( pParser->yyidx<0 ) return 0;
354
- #ifndef NDEBUG
355
- if( yyTraceFILE && pParser->yyidx>=0 ){
356
- fprintf(yyTraceFILE,"%sPopping %s\n",
357
- yyTracePrompt,
358
- yyTokenName[yytos->major]);
359
- }
360
- #endif
361
- yymajor = yytos->major;
362
- yy_destructor( yymajor, &yytos->minor);
363
- pParser->yyidx--;
364
- return yymajor;
365
- }
366
-
367
- /*
368
- ** Deallocate and destroy a parser. Destructors are all called for
369
- ** all stack elements before shutting the parser down.
370
- **
371
- ** Inputs:
372
- ** <ul>
373
- ** <li> A pointer to the parser. This should be a pointer
374
- ** obtained from ParseAlloc.
375
- ** <li> A pointer to a function used to reclaim memory obtained
376
- ** from malloc.
377
- ** </ul>
378
- */
379
- void ParseFree(
380
- void *p, /* The parser to be deleted */
381
- void (*freeProc)(void*) /* Function used to reclaim memory */
382
- ){
383
- yyParser *pParser = (yyParser*)p;
384
- if( pParser==0 ) return;
385
- while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);
386
- #if YYSTACKDEPTH<=0
387
- free(pParser->yystack);
388
- #endif
389
- (*freeProc)((void*)pParser);
390
- }
391
-
392
- /*
393
- ** Find the appropriate action for a parser given the terminal
394
- ** look-ahead token iLookAhead.
395
- **
396
- ** If the look-ahead token is YYNOCODE, then check to see if the action is
397
- ** independent of the look-ahead. If it is, return the action, otherwise
398
- ** return YY_NO_ACTION.
399
- */
400
- static int yy_find_shift_action(
401
- yyParser *pParser, /* The parser */
402
- YYCODETYPE iLookAhead /* The look-ahead token */
403
- ){
404
- int i;
405
- int stateno = pParser->yystack[pParser->yyidx].stateno;
406
-
407
- if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){
408
- return yy_default[stateno];
409
- }
410
- if( iLookAhead==YYNOCODE ){
411
- return YY_NO_ACTION;
412
- }
413
- i += iLookAhead;
414
- if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
415
- if( iLookAhead>0 ){
416
- #ifdef YYFALLBACK
417
- int iFallback; /* Fallback token */
418
- if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
419
- && (iFallback = yyFallback[iLookAhead])!=0 ){
420
- #ifndef NDEBUG
421
- if( yyTraceFILE ){
422
- fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
423
- yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
424
- }
425
- #endif
426
- return yy_find_shift_action(pParser, iFallback);
427
- }
428
- #endif
429
- #ifdef YYWILDCARD
430
- {
431
- int j = i - iLookAhead + YYWILDCARD;
432
- if( j>=0 && j<YY_SZ_ACTTAB && yy_lookahead[j]==YYWILDCARD ){
433
- #ifndef NDEBUG
434
- if( yyTraceFILE ){
435
- fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
436
- yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);
437
- }
438
- #endif /* NDEBUG */
439
- return yy_action[j];
440
- }
441
- }
442
- #endif /* YYWILDCARD */
443
- }
444
- return yy_default[stateno];
445
- }else{
446
- return yy_action[i];
447
- }
448
- }
449
-
450
- /*
451
- ** Find the appropriate action for a parser given the non-terminal
452
- ** look-ahead token iLookAhead.
453
- **
454
- ** If the look-ahead token is YYNOCODE, then check to see if the action is
455
- ** independent of the look-ahead. If it is, return the action, otherwise
456
- ** return YY_NO_ACTION.
457
- */
458
- static int yy_find_reduce_action(
459
- int stateno, /* Current state number */
460
- YYCODETYPE iLookAhead /* The look-ahead token */
461
- ){
462
- int i;
463
- /* int stateno = pParser->yystack[pParser->yyidx].stateno; */
464
-
465
- if( stateno>YY_REDUCE_MAX ||
466
- (i = yy_reduce_ofst[stateno])==YY_REDUCE_USE_DFLT ){
467
- return yy_default[stateno];
468
- }
469
- if( iLookAhead==YYNOCODE ){
470
- return YY_NO_ACTION;
471
- }
472
- i += iLookAhead;
473
- if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){
474
- return yy_default[stateno];
475
- }else{
476
- return yy_action[i];
477
- }
478
- }
479
-
480
- /*
481
- ** The following routine is called if the stack overflows.
482
- */
483
- static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
484
- ParseARG_FETCH;
485
- yypParser->yyidx--;
486
- #ifndef NDEBUG
487
- if( yyTraceFILE ){
488
- fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
489
- }
490
- #endif
491
- while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
492
- /* Here code is inserted which will execute if the parser
493
- ** stack every overflows */
494
- ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
495
- }
496
-
497
- /*
498
- ** Perform a shift action.
499
- */
500
- static void yy_shift(
501
- yyParser *yypParser, /* The parser to be shifted */
502
- int yyNewState, /* The new state to shift in */
503
- int yyMajor, /* The major token to shift in */
504
- YYMINORTYPE *yypMinor /* Pointer ot the minor token to shift in */
505
- ){
506
- yyStackEntry *yytos;
507
- yypParser->yyidx++;
508
- #if YYSTACKDEPTH>0
509
- if( yypParser->yyidx>=YYSTACKDEPTH ){
510
- yyStackOverflow(yypParser, yypMinor);
511
- return;
512
- }
513
- #else
514
- if( yypParser->yyidx>=yypParser->yystksz ){
515
- yyGrowStack(yypParser);
516
- if( yypParser->yyidx>=yypParser->yystksz ){
517
- yyStackOverflow(yypParser, yypMinor);
518
- return;
519
- }
520
- }
521
- #endif
522
- yytos = &yypParser->yystack[yypParser->yyidx];
523
- yytos->stateno = yyNewState;
524
- yytos->major = yyMajor;
525
- yytos->minor = *yypMinor;
526
- #ifndef NDEBUG
527
- if( yyTraceFILE && yypParser->yyidx>0 ){
528
- int i;
529
- fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState);
530
- fprintf(yyTraceFILE,"%sStack:",yyTracePrompt);
531
- for(i=1; i<=yypParser->yyidx; i++)
532
- fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]);
533
- fprintf(yyTraceFILE,"\n");
534
- }
535
- #endif
536
- }
537
-
538
- /* The following table contains information about every rule that
539
- ** is used during the reduce.
540
- */
541
- static const struct {
542
- YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
543
- unsigned char nrhs; /* Number of right-hand side symbols in the rule */
544
- } yyRuleInfo[] = {
545
- { 11, 1 },
546
- { 12, 2 },
547
- { 12, 1 },
548
- { 13, 3 },
549
- { 13, 2 },
550
- { 13, 1 },
551
- { 14, 1 },
552
- { 14, 1 },
553
- { 14, 1 },
554
- { 14, 1 },
555
- { 14, 1 },
556
- { 14, 1 },
557
- { 14, 1 },
558
- { 14, 1 },
559
- };
560
-
561
- static void yy_accept(yyParser*); /* Forward Declaration */
562
-
563
- /*
564
- ** Perform a reduce action and the shift that must immediately
565
- ** follow the reduce.
566
- */
567
- static void yy_reduce(
568
- yyParser *yypParser, /* The parser */
569
- int yyruleno /* Number of the rule by which to reduce */
570
- ){
571
- int yygoto; /* The next state */
572
- int yyact; /* The next action */
573
- YYMINORTYPE yygotominor; /* The LHS of the rule reduced */
574
- yyStackEntry *yymsp; /* The top of the parser's stack */
575
- int yysize; /* Amount to pop the stack */
576
- ParseARG_FETCH;
577
- yymsp = &yypParser->yystack[yypParser->yyidx];
578
- #ifndef NDEBUG
579
- if( yyTraceFILE && yyruleno>=0
580
- && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
581
- fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
582
- yyRuleName[yyruleno]);
583
- }
584
- #endif /* NDEBUG */
585
-
586
- /* Silence complaints from purify about yygotominor being uninitialized
587
- ** in some cases when it is copied into the stack after the following
588
- ** switch. yygotominor is uninitialized when a rule reduces that does
589
- ** not set the value of its left-hand side nonterminal. Leaving the
590
- ** value of the nonterminal uninitialized is utterly harmless as long
591
- ** as the value is never used. So really the only thing this code
592
- ** accomplishes is to quieten purify.
593
- **
594
- ** 2007-01-16: The wireshark project (www.wireshark.org) reports that
595
- ** without this code, their parser segfaults. I'm not sure what there
596
- ** parser is doing to make this happen. This is the second bug report
597
- ** from wireshark this week. Clearly they are stressing Lemon in ways
598
- ** that it has not been previously stressed... (SQLite ticket #2172)
599
- */
600
- memset(&yygotominor, 0, sizeof(yygotominor));
601
-
602
-
603
- switch( yyruleno ){
604
- /* Beginning here are the reduction cases. A typical example
605
- ** follows:
606
- ** case 0:
607
- ** #line <lineno> <grammarfile>
608
- ** { ... } // User supplied code
609
- ** #line <lineno> <thisfile>
610
- ** break;
611
- */
612
- case 0:
613
- #line 13 "hpricot_gram.y"
614
- {
615
- }
616
- #line 618 "hpricot_gram.c"
617
- break;
618
- case 1:
619
- #line 15 "hpricot_gram.y"
620
- { yygotominor.yy0 = yymsp[-1].minor.yy0; rb_p(yymsp[-1].minor.yy0[0]); }
621
- #line 623 "hpricot_gram.c"
622
- break;
623
- case 2:
624
- case 5:
625
- case 6:
626
- case 7:
627
- case 8:
628
- case 9:
629
- case 10:
630
- case 11:
631
- case 12:
632
- case 13:
633
- #line 16 "hpricot_gram.y"
634
- { yygotominor.yy0 = yymsp[0].minor.yy0; }
635
- #line 637 "hpricot_gram.c"
636
- break;
637
- case 3:
638
- #line 18 "hpricot_gram.y"
639
- { yygotominor.yy0 = yymsp[-2].minor.yy0; rb_p(yymsp[-1].minor.yy0[0]); }
640
- #line 642 "hpricot_gram.c"
641
- break;
642
- case 4:
643
- #line 19 "hpricot_gram.y"
644
- { yygotominor.yy0 = yymsp[-1].minor.yy0; }
645
- #line 647 "hpricot_gram.c"
646
- break;
647
- };
648
- yygoto = yyRuleInfo[yyruleno].lhs;
649
- yysize = yyRuleInfo[yyruleno].nrhs;
650
- yypParser->yyidx -= yysize;
651
- yyact = yy_find_reduce_action(yymsp[-yysize].stateno,yygoto);
652
- if( yyact < YYNSTATE ){
653
- #ifdef NDEBUG
654
- /* If we are not debugging and the reduce action popped at least
655
- ** one element off the stack, then we can push the new element back
656
- ** onto the stack here, and skip the stack overflow test in yy_shift().
657
- ** That gives a significant speed improvement. */
658
- if( yysize ){
659
- yypParser->yyidx++;
660
- yymsp -= yysize-1;
661
- yymsp->stateno = yyact;
662
- yymsp->major = yygoto;
663
- yymsp->minor = yygotominor;
664
- }else
665
- #endif
666
- {
667
- yy_shift(yypParser,yyact,yygoto,&yygotominor);
668
- }
669
- }else if( yyact == YYNSTATE + YYNRULE + 1 ){
670
- yy_accept(yypParser);
671
- }
672
- }
673
-
674
- /*
675
- ** The following code executes when the parse fails
676
- */
677
- static void yy_parse_failed(
678
- yyParser *yypParser /* The parser */
679
- ){
680
- ParseARG_FETCH;
681
- #ifndef NDEBUG
682
- if( yyTraceFILE ){
683
- fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
684
- }
685
- #endif
686
- while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
687
- /* Here code is inserted which will be executed whenever the
688
- ** parser fails */
689
- ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
690
- }
691
-
692
- /*
693
- ** The following code executes when a syntax error first occurs.
694
- */
695
- static void yy_syntax_error(
696
- yyParser *yypParser, /* The parser */
697
- int yymajor, /* The major type of the error token */
698
- YYMINORTYPE yyminor /* The minor type of the error token */
699
- ){
700
- ParseARG_FETCH;
701
- #define TOKEN (yyminor.yy0)
702
- ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
703
- }
704
-
705
- /*
706
- ** The following is executed when the parser accepts
707
- */
708
- static void yy_accept(
709
- yyParser *yypParser /* The parser */
710
- ){
711
- ParseARG_FETCH;
712
- #ifndef NDEBUG
713
- if( yyTraceFILE ){
714
- fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
715
- }
716
- #endif
717
- while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
718
- /* Here code is inserted which will be executed whenever the
719
- ** parser accepts */
720
- #line 11 "hpricot_gram.y"
721
- printf("parsing complete!\n");
722
- #line 725 "hpricot_gram.c"
723
- ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
724
- }
725
-
726
- /* The main parser program.
727
- ** The first argument is a pointer to a structure obtained from
728
- ** "ParseAlloc" which describes the current state of the parser.
729
- ** The second argument is the major token number. The third is
730
- ** the minor token. The fourth optional argument is whatever the
731
- ** user wants (and specified in the grammar) and is available for
732
- ** use by the action routines.
733
- **
734
- ** Inputs:
735
- ** <ul>
736
- ** <li> A pointer to the parser (an opaque structure.)
737
- ** <li> The major token number.
738
- ** <li> The minor token number.
739
- ** <li> An option argument of a grammar-specified type.
740
- ** </ul>
741
- **
742
- ** Outputs:
743
- ** None.
744
- */
745
- void Parse(
746
- void *yyp, /* The parser */
747
- int yymajor, /* The major token code number */
748
- ParseTOKENTYPE yyminor /* The value for the token */
749
- ParseARG_PDECL /* Optional %extra_argument parameter */
750
- ){
751
- YYMINORTYPE yyminorunion;
752
- int yyact; /* The parser action. */
753
- int yyendofinput; /* True if we are at the end of input */
754
- int yyerrorhit = 0; /* True if yymajor has invoked an error */
755
- yyParser *yypParser; /* The parser */
756
-
757
- /* (re)initialize the parser, if necessary */
758
- yypParser = (yyParser*)yyp;
759
- if( yypParser->yyidx<0 ){
760
- #if YYSTACKDEPTH<=0
761
- if( yypParser->yystksz <=0 ){
762
- memset(&yyminorunion, 0, sizeof(yyminorunion));
763
- yyStackOverflow(yypParser, &yyminorunion);
764
- return;
765
- }
766
- #endif
767
- yypParser->yyidx = 0;
768
- yypParser->yyerrcnt = -1;
769
- yypParser->yystack[0].stateno = 0;
770
- yypParser->yystack[0].major = 0;
771
- }
772
- yyminorunion.yy0 = yyminor;
773
- yyendofinput = (yymajor==0);
774
- ParseARG_STORE;
775
-
776
- #ifndef NDEBUG
777
- if( yyTraceFILE ){
778
- fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
779
- }
780
- #endif
781
-
782
- do{
783
- yyact = yy_find_shift_action(yypParser,yymajor);
784
- if( yyact<YYNSTATE ){
785
- yy_shift(yypParser,yyact,yymajor,&yyminorunion);
786
- yypParser->yyerrcnt--;
787
- if( yyendofinput && yypParser->yyidx>=0 ){
788
- yymajor = 0;
789
- }else{
790
- yymajor = YYNOCODE;
791
- }
792
- }else if( yyact < YYNSTATE + YYNRULE ){
793
- yy_reduce(yypParser,yyact-YYNSTATE);
794
- }else if( yyact == YY_ERROR_ACTION ){
795
- int yymx;
796
- #ifndef NDEBUG
797
- if( yyTraceFILE ){
798
- fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
799
- }
800
- #endif
801
- #ifdef YYERRORSYMBOL
802
- /* A syntax error has occurred.
803
- ** The response to an error depends upon whether or not the
804
- ** grammar defines an error token "ERROR".
805
- **
806
- ** This is what we do if the grammar does define ERROR:
807
- **
808
- ** * Call the %syntax_error function.
809
- **
810
- ** * Begin popping the stack until we enter a state where
811
- ** it is legal to shift the error symbol, then shift
812
- ** the error symbol.
813
- **
814
- ** * Set the error count to three.
815
- **
816
- ** * Begin accepting and shifting new tokens. No new error
817
- ** processing will occur until three tokens have been
818
- ** shifted successfully.
819
- **
820
- */
821
- if( yypParser->yyerrcnt<0 ){
822
- yy_syntax_error(yypParser,yymajor,yyminorunion);
823
- }
824
- yymx = yypParser->yystack[yypParser->yyidx].major;
825
- if( yymx==YYERRORSYMBOL || yyerrorhit ){
826
- #ifndef NDEBUG
827
- if( yyTraceFILE ){
828
- fprintf(yyTraceFILE,"%sDiscard input token %s\n",
829
- yyTracePrompt,yyTokenName[yymajor]);
830
- }
831
- #endif
832
- yy_destructor(yymajor,&yyminorunion);
833
- yymajor = YYNOCODE;
834
- }else{
835
- while(
836
- yypParser->yyidx >= 0 &&
837
- yymx != YYERRORSYMBOL &&
838
- (yyact = yy_find_reduce_action(
839
- yypParser->yystack[yypParser->yyidx].stateno,
840
- YYERRORSYMBOL)) >= YYNSTATE
841
- ){
842
- yy_pop_parser_stack(yypParser);
843
- }
844
- if( yypParser->yyidx < 0 || yymajor==0 ){
845
- yy_destructor(yymajor,&yyminorunion);
846
- yy_parse_failed(yypParser);
847
- yymajor = YYNOCODE;
848
- }else if( yymx!=YYERRORSYMBOL ){
849
- YYMINORTYPE u2;
850
- u2.YYERRSYMDT = 0;
851
- yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
852
- }
853
- }
854
- yypParser->yyerrcnt = 3;
855
- yyerrorhit = 1;
856
- #else /* YYERRORSYMBOL is not defined */
857
- /* This is what we do if the grammar does not define ERROR:
858
- **
859
- ** * Report an error message, and throw away the input token.
860
- **
861
- ** * If the input token is $, then fail the parse.
862
- **
863
- ** As before, subsequent error messages are suppressed until
864
- ** three input tokens have been successfully shifted.
865
- */
866
- if( yypParser->yyerrcnt<=0 ){
867
- yy_syntax_error(yypParser,yymajor,yyminorunion);
868
- }
869
- yypParser->yyerrcnt = 3;
870
- yy_destructor(yymajor,&yyminorunion);
871
- if( yyendofinput ){
872
- yy_parse_failed(yypParser);
873
- }
874
- yymajor = YYNOCODE;
875
- #endif
876
- }else{
877
- yy_accept(yypParser);
878
- yymajor = YYNOCODE;
879
- }
880
- }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
881
- return;
882
- }