racc 1.4.15 → 1.4.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/COPYING +22 -515
- data/Manifest.txt +3 -9
- data/README.ja.rdoc +3 -4
- data/README.rdoc +4 -4
- data/Rakefile +13 -55
- data/bin/racc +2 -4
- data/ext/racc/{cparse.c → cparse/cparse.c} +64 -31
- data/ext/racc/cparse/extconf.rb +8 -0
- data/lib/racc/exception.rb +3 -5
- data/lib/racc/grammar.rb +5 -7
- data/lib/racc/grammarfileparser.rb +4 -3
- data/lib/racc/info.rb +4 -6
- data/lib/racc/iset.rb +2 -2
- data/lib/racc/logfilegenerator.rb +2 -2
- data/lib/racc/parser-text.rb +14 -11
- data/lib/racc/parser.rb +14 -11
- data/lib/racc/parserfilegenerator.rb +5 -7
- data/lib/racc/state.rb +11 -13
- data/test/assets/intp.y +4 -4
- data/test/assets/mailp.y +27 -27
- data/test/assets/mof.y +12 -12
- data/test/assets/nullbug2.y +2 -2
- data/test/assets/recv.y +20 -20
- data/test/assets/syntax.y +1 -1
- data/test/assets/twowaysql.y +1 -1
- data/test/helper.rb +46 -35
- data/test/regress/cadenza +60 -60
- data/test/regress/cast +8 -8
- data/test/regress/csspool +167 -167
- data/test/regress/edtf +115 -115
- data/test/regress/huia +75 -75
- data/test/regress/journey +12 -12
- data/test/regress/liquor +54 -54
- data/test/regress/machete +37 -37
- data/test/regress/mediacloth +83 -83
- data/test/regress/mof +60 -60
- data/test/regress/namae +29 -29
- data/test/regress/nasl +174 -174
- data/test/regress/nokogiri-css +59 -59
- data/test/regress/opal +352 -352
- data/test/regress/php_serialization +20 -20
- data/test/regress/riml +261 -261
- data/test/regress/ruby18 +353 -353
- data/test/regress/ruby22 +433 -433
- data/test/regress/tp_plus +125 -125
- data/test/regress/twowaysql +30 -30
- data/test/test_chk_y.rb +1 -0
- data/test/test_racc_command.rb +5 -24
- data/test/test_scan_y.rb +1 -0
- data/test/testscanner.rb +1 -1
- metadata +9 -76
- data/ext/racc/depend +0 -1
- data/ext/racc/extconf.rb +0 -7
- data/test/assets/bibtex.y +0 -141
- data/test/assets/rdblockparser.y +0 -576
- data/test/assets/rdinlineparser.y +0 -561
- data/test/regress/bibtex +0 -474
- data/test/regress/rdblockparser +0 -1061
- data/test/regress/rdinlineparser +0 -1243
data/lib/racc/exception.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
#
|
2
|
-
# $Id:
|
2
|
+
# $Id: ebb9798ad0b211e031670a12a1ab154678c1c8f3 $
|
3
3
|
#
|
4
4
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
5
|
#
|
6
6
|
# This program is free software.
|
7
|
-
# You can distribute/modify this program under the terms of
|
8
|
-
# the
|
9
|
-
# For details of the GNU LGPL, see the file "COPYING".
|
10
|
-
#
|
7
|
+
# You can distribute/modify this program under the same terms of ruby.
|
8
|
+
# see the file "COPYING".
|
11
9
|
|
12
10
|
module Racc
|
13
11
|
class Error < StandardError; end
|
data/lib/racc/grammar.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
#
|
2
|
-
# $Id:
|
2
|
+
# $Id: 3fcabd58bef02540bf78e8142469681cb9f975c2 $
|
3
3
|
#
|
4
4
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
5
|
#
|
6
6
|
# This program is free software.
|
7
|
-
# You can distribute/modify this program under the terms of
|
8
|
-
# the
|
9
|
-
# For details of the GNU LGPL, see the file "COPYING".
|
10
|
-
#
|
7
|
+
# You can distribute/modify this program under the same terms of ruby.
|
8
|
+
# see the file "COPYING".
|
11
9
|
|
12
10
|
require 'racc/compat'
|
13
11
|
require 'racc/iset'
|
@@ -571,7 +569,7 @@ module Racc
|
|
571
569
|
check_symbols_useless s
|
572
570
|
end until r.size == rs and s.size == ss
|
573
571
|
end
|
574
|
-
|
572
|
+
|
575
573
|
def check_rules_useless(rules)
|
576
574
|
rules.delete_if do |rule|
|
577
575
|
rule.useless = false
|
@@ -855,7 +853,7 @@ module Racc
|
|
855
853
|
end
|
856
854
|
|
857
855
|
private
|
858
|
-
|
856
|
+
|
859
857
|
def ptr_bug!
|
860
858
|
raise "racc: fatal: pointer not exist: self: #{to_s}"
|
861
859
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# $Id:
|
2
|
+
# $Id: 63bd084db2dce8a2c9760318faae6104717cead7 $
|
3
3
|
#
|
4
4
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
5
|
#
|
@@ -284,7 +284,7 @@ module Racc
|
|
284
284
|
end
|
285
285
|
label
|
286
286
|
end
|
287
|
-
|
287
|
+
|
288
288
|
def add_user_code(label, src)
|
289
289
|
@result.params.send(USER_CODE_LABELS[label]).push src
|
290
290
|
end
|
@@ -295,7 +295,7 @@ module Racc
|
|
295
295
|
class GrammarFileScanner
|
296
296
|
|
297
297
|
def initialize(str, filename = '-')
|
298
|
-
@lines = str.split(/\n|\r\n|\r/)
|
298
|
+
@lines = str.b.split(/\n|\r\n|\r/)
|
299
299
|
@filename = filename
|
300
300
|
@lineno = -1
|
301
301
|
@line_head = true
|
@@ -450,6 +450,7 @@ module Racc
|
|
450
450
|
nest -= 1
|
451
451
|
if nest == 0
|
452
452
|
@in_block = nil
|
453
|
+
buf.sub!(/[ \t\f]+\z/, '')
|
453
454
|
return buf
|
454
455
|
end
|
455
456
|
buf << (pre = ch)
|
data/lib/racc/info.rb
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
#
|
2
|
-
# $Id:
|
2
|
+
# $Id: 8ab2cb5341529fe5e35956bb1a1f42ec9b9c6f5a $
|
3
3
|
#
|
4
4
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
5
|
#
|
6
6
|
# This program is free software.
|
7
|
-
# You can distribute/modify this program under the terms of
|
8
|
-
# the
|
9
|
-
# For details of the GNU LGPL, see the file "COPYING".
|
10
|
-
#
|
7
|
+
# You can distribute/modify this program under the same terms of ruby.
|
8
|
+
# see the file "COPYING".
|
11
9
|
|
12
10
|
module Racc
|
13
|
-
VERSION = '1.4.
|
11
|
+
VERSION = '1.4.16'
|
14
12
|
Version = VERSION
|
15
13
|
Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
|
16
14
|
end
|
data/lib/racc/iset.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# $Id:
|
2
|
+
# $Id: 31aa4331c08dfd4609c06eb5f94b7ef38dc708e1 $
|
3
3
|
#
|
4
4
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
5
|
#
|
@@ -85,7 +85,7 @@ module Racc
|
|
85
85
|
def dup
|
86
86
|
ISet.new(@set.dup)
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
end # class ISet
|
90
90
|
|
91
91
|
end # module Racc
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# $Id:
|
2
|
+
# $Id: 5e9d0a01b5d56fd9cdc3d5cb078b1a3e1bbaf779 $
|
3
3
|
#
|
4
4
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
5
|
#
|
@@ -132,7 +132,7 @@ module Racc
|
|
132
132
|
def outact(f, t, act)
|
133
133
|
case act
|
134
134
|
when Shift
|
135
|
-
f.printf " %-12s shift, and go to state %d\n",
|
135
|
+
f.printf " %-12s shift, and go to state %d\n",
|
136
136
|
t.to_s, act.goto_id
|
137
137
|
when Reduce
|
138
138
|
f.printf " %-12s reduce using rule %d (%s)\n",
|
data/lib/racc/parser-text.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
module Racc
|
2
2
|
PARSER_TEXT = <<'__end_of_file__'
|
3
|
-
#
|
4
|
-
|
5
|
-
#
|
3
|
+
# frozen_string_literal: false
|
4
|
+
#--
|
6
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
7
6
|
#
|
8
7
|
# This program is free software.
|
@@ -11,7 +10,7 @@ module Racc
|
|
11
10
|
# As a special exception, when this code is copied by Racc
|
12
11
|
# into a Racc output file, you may use that output file
|
13
12
|
# without restriction.
|
14
|
-
|
13
|
+
#++
|
15
14
|
|
16
15
|
require 'racc/info'
|
17
16
|
|
@@ -45,7 +44,7 @@ end
|
|
45
44
|
# [--version] [--copyright] [--help] <var>grammarfile</var>
|
46
45
|
#
|
47
46
|
# [+filename+]
|
48
|
-
# Racc grammar file. Any
|
47
|
+
# Racc grammar file. Any extension is permitted.
|
49
48
|
# [-o+outfile+, --output-file=+outfile+]
|
50
49
|
# A filename for output. default is <+filename+>.tab.rb
|
51
50
|
# [-O+filename+, --log-file=+filename+]
|
@@ -61,7 +60,7 @@ end
|
|
61
60
|
# [-E, --embedded]
|
62
61
|
# Output parser which doesn't need runtime files (racc/parser.rb).
|
63
62
|
# [-C, --check-only]
|
64
|
-
# Check syntax of racc
|
63
|
+
# Check syntax of racc grammar file and quit.
|
65
64
|
# [-S, --output-status]
|
66
65
|
# Print messages time to time while compiling.
|
67
66
|
# [-l, --no-line-convert]
|
@@ -178,7 +177,7 @@ end
|
|
178
177
|
# This command creates myparser.rb which `includes' Racc runtime.
|
179
178
|
# Only you must do is to distribute your parser file (myparser.rb).
|
180
179
|
#
|
181
|
-
# Note: parser.rb is
|
180
|
+
# Note: parser.rb is ruby license, but your parser is not.
|
182
181
|
# Your own parser is completely yours.
|
183
182
|
module Racc
|
184
183
|
|
@@ -189,10 +188,10 @@ module Racc
|
|
189
188
|
class Parser
|
190
189
|
|
191
190
|
Racc_Runtime_Version = ::Racc::VERSION
|
192
|
-
Racc_Runtime_Revision = '$Id:
|
191
|
+
Racc_Runtime_Revision = '$Id: 7adc21ee7a5690f10b7ff399b8af4e2717b9d94c $'
|
193
192
|
|
194
193
|
Racc_Runtime_Core_Version_R = ::Racc::VERSION
|
195
|
-
Racc_Runtime_Core_Revision_R = '$Id:
|
194
|
+
Racc_Runtime_Core_Revision_R = '$Id: 7adc21ee7a5690f10b7ff399b8af4e2717b9d94c $'.split[1]
|
196
195
|
begin
|
197
196
|
if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
|
198
197
|
require 'racc/cparse-jruby.jar'
|
@@ -269,9 +268,11 @@ puts $!.backtrace
|
|
269
268
|
# def next_token
|
270
269
|
# @q.shift
|
271
270
|
# end
|
271
|
+
class_eval %{
|
272
272
|
def do_parse
|
273
|
-
|
273
|
+
#{Racc_Main_Parsing_Routine}(_racc_setup(), false)
|
274
274
|
end
|
275
|
+
}
|
275
276
|
|
276
277
|
# The method to fetch next token.
|
277
278
|
# If you use #do_parse method, you must implement #next_token.
|
@@ -329,9 +330,11 @@ puts $!.backtrace
|
|
329
330
|
#
|
330
331
|
# RECEIVER#METHOD_ID is a method to get next token.
|
331
332
|
# It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
|
333
|
+
class_eval %{
|
332
334
|
def yyparse(recv, mid)
|
333
|
-
|
335
|
+
#{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), true)
|
334
336
|
end
|
337
|
+
}
|
335
338
|
|
336
339
|
def _racc_yyparse_rb(recv, mid, arg, c_debug)
|
337
340
|
action_table, action_check, action_default, action_pointer,
|
data/lib/racc/parser.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
1
|
+
# frozen_string_literal: false
|
2
|
+
#--
|
4
3
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
4
|
#
|
6
5
|
# This program is free software.
|
@@ -9,7 +8,7 @@
|
|
9
8
|
# As a special exception, when this code is copied by Racc
|
10
9
|
# into a Racc output file, you may use that output file
|
11
10
|
# without restriction.
|
12
|
-
|
11
|
+
#++
|
13
12
|
|
14
13
|
require 'racc/info'
|
15
14
|
|
@@ -43,7 +42,7 @@ end
|
|
43
42
|
# [--version] [--copyright] [--help] <var>grammarfile</var>
|
44
43
|
#
|
45
44
|
# [+filename+]
|
46
|
-
# Racc grammar file. Any
|
45
|
+
# Racc grammar file. Any extension is permitted.
|
47
46
|
# [-o+outfile+, --output-file=+outfile+]
|
48
47
|
# A filename for output. default is <+filename+>.tab.rb
|
49
48
|
# [-O+filename+, --log-file=+filename+]
|
@@ -59,7 +58,7 @@ end
|
|
59
58
|
# [-E, --embedded]
|
60
59
|
# Output parser which doesn't need runtime files (racc/parser.rb).
|
61
60
|
# [-C, --check-only]
|
62
|
-
# Check syntax of racc
|
61
|
+
# Check syntax of racc grammar file and quit.
|
63
62
|
# [-S, --output-status]
|
64
63
|
# Print messages time to time while compiling.
|
65
64
|
# [-l, --no-line-convert]
|
@@ -176,7 +175,7 @@ end
|
|
176
175
|
# This command creates myparser.rb which `includes' Racc runtime.
|
177
176
|
# Only you must do is to distribute your parser file (myparser.rb).
|
178
177
|
#
|
179
|
-
# Note: parser.rb is
|
178
|
+
# Note: parser.rb is ruby license, but your parser is not.
|
180
179
|
# Your own parser is completely yours.
|
181
180
|
module Racc
|
182
181
|
|
@@ -187,10 +186,10 @@ module Racc
|
|
187
186
|
class Parser
|
188
187
|
|
189
188
|
Racc_Runtime_Version = ::Racc::VERSION
|
190
|
-
Racc_Runtime_Revision = '$Id:
|
189
|
+
Racc_Runtime_Revision = '$Id: e754525bd317344c4284fca6fdce0a425979ade1 $'
|
191
190
|
|
192
191
|
Racc_Runtime_Core_Version_R = ::Racc::VERSION
|
193
|
-
Racc_Runtime_Core_Revision_R = '$Id:
|
192
|
+
Racc_Runtime_Core_Revision_R = '$Id: e754525bd317344c4284fca6fdce0a425979ade1 $'.split[1]
|
194
193
|
begin
|
195
194
|
if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
|
196
195
|
require 'racc/cparse-jruby.jar'
|
@@ -267,9 +266,11 @@ puts $!.backtrace
|
|
267
266
|
# def next_token
|
268
267
|
# @q.shift
|
269
268
|
# end
|
269
|
+
class_eval %{
|
270
270
|
def do_parse
|
271
|
-
|
271
|
+
#{Racc_Main_Parsing_Routine}(_racc_setup(), false)
|
272
272
|
end
|
273
|
+
}
|
273
274
|
|
274
275
|
# The method to fetch next token.
|
275
276
|
# If you use #do_parse method, you must implement #next_token.
|
@@ -327,9 +328,11 @@ puts $!.backtrace
|
|
327
328
|
#
|
328
329
|
# RECEIVER#METHOD_ID is a method to get next token.
|
329
330
|
# It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
|
331
|
+
class_eval %{
|
330
332
|
def yyparse(recv, mid)
|
331
|
-
|
333
|
+
#{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), true)
|
332
334
|
end
|
335
|
+
}
|
333
336
|
|
334
337
|
def _racc_yyparse_rb(recv, mid, arg, c_debug)
|
335
338
|
action_table, action_check, action_default, action_pointer,
|
@@ -1,13 +1,11 @@
|
|
1
1
|
#
|
2
|
-
# $Id:
|
2
|
+
# $Id: fff07ebfd582f8dbc845e424908cb9f41f8bf42f $
|
3
3
|
#
|
4
4
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
5
|
#
|
6
6
|
# This program is free software.
|
7
|
-
# You can distribute/modify this program under the terms of
|
8
|
-
# the
|
9
|
-
# For details of the GNU LGPL, see the file "COPYING".
|
10
|
-
#
|
7
|
+
# You can distribute/modify this program under the same terms of ruby.
|
8
|
+
# see the file "COPYING".
|
11
9
|
|
12
10
|
require 'enumerator'
|
13
11
|
require 'racc/compat'
|
@@ -125,7 +123,7 @@ module Racc
|
|
125
123
|
line %q[#]
|
126
124
|
line %q[# DO NOT MODIFY!!!!]
|
127
125
|
line %Q[# This file is automatically generated by Racc #{Racc::Version}]
|
128
|
-
line %Q[# from Racc
|
126
|
+
line %Q[# from Racc grammar file "#{@params.filename}".]
|
129
127
|
line %q[#]
|
130
128
|
end
|
131
129
|
|
@@ -159,8 +157,8 @@ module Racc
|
|
159
157
|
cref_pop
|
160
158
|
indent; line "end \# class #{classid}"
|
161
159
|
mods.reverse_each do |mod|
|
162
|
-
indent; line "end \# module #{mod}"
|
163
160
|
cref_pop
|
161
|
+
indent; line "end \# module #{mod}"
|
164
162
|
end
|
165
163
|
end
|
166
164
|
|
data/lib/racc/state.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
#
|
2
|
-
# $Id:
|
2
|
+
# $Id: 6bd3136439c94cb8d928917f5e0de9c593181527 $
|
3
3
|
#
|
4
4
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
5
|
#
|
6
6
|
# This program is free software.
|
7
|
-
# You can distribute/modify this program under the terms of
|
8
|
-
# the
|
9
|
-
# For details of the GNU LGPL, see the file "COPYING".
|
10
|
-
#
|
7
|
+
# You can distribute/modify this program under the same terms of ruby.
|
8
|
+
# see the file "COPYING".
|
11
9
|
|
12
10
|
require 'racc/iset'
|
13
11
|
require 'racc/statetransitiontable'
|
@@ -170,7 +168,7 @@ module Racc
|
|
170
168
|
@states.push dest
|
171
169
|
|
172
170
|
@statecache[k] = dest
|
173
|
-
|
171
|
+
|
174
172
|
puts "core_to_state: create state ID #{dest.ident}" if @d_state
|
175
173
|
else
|
176
174
|
if @d_state
|
@@ -308,7 +306,7 @@ module Racc
|
|
308
306
|
|
309
307
|
la
|
310
308
|
end
|
311
|
-
|
309
|
+
|
312
310
|
def create_tmap(size)
|
313
311
|
Array.new(size, 0) # use Integer as bitmap
|
314
312
|
end
|
@@ -512,13 +510,13 @@ module Racc
|
|
512
510
|
end
|
513
511
|
end
|
514
512
|
end
|
515
|
-
|
513
|
+
|
516
514
|
ASSOC = {
|
517
515
|
:Left => :Reduce,
|
518
516
|
:Right => :Shift,
|
519
517
|
:Nonassoc => :Error
|
520
518
|
}
|
521
|
-
|
519
|
+
|
522
520
|
def do_resolve_sr(stok, rtok)
|
523
521
|
puts "resolve_sr: s/r conflict: rtok=#{rtok}, stok=#{stok}" if @d_prec
|
524
522
|
|
@@ -775,7 +773,7 @@ module Racc
|
|
775
773
|
attr_reader :symbol
|
776
774
|
attr_reader :from_state
|
777
775
|
attr_reader :to_state
|
778
|
-
|
776
|
+
|
779
777
|
def inspect
|
780
778
|
"(#{@from_state.ident}-#{@symbol}->#{@to_state.ident})"
|
781
779
|
end
|
@@ -938,11 +936,11 @@ module Racc
|
|
938
936
|
@shift = shift
|
939
937
|
@reduce = reduce
|
940
938
|
end
|
941
|
-
|
939
|
+
|
942
940
|
attr_reader :stateid
|
943
941
|
attr_reader :shift
|
944
942
|
attr_reader :reduce
|
945
|
-
|
943
|
+
|
946
944
|
def to_s
|
947
945
|
sprintf('state %d: S/R conflict rule %d reduce and shift %s',
|
948
946
|
@stateid, @reduce.ruleid, @shift.to_s)
|
@@ -961,7 +959,7 @@ module Racc
|
|
961
959
|
attr_reader :high_prec
|
962
960
|
attr_reader :low_prec
|
963
961
|
attr_reader :token
|
964
|
-
|
962
|
+
|
965
963
|
def to_s
|
966
964
|
sprintf('state %d: R/R conflict with rule %d and %d on %s',
|
967
965
|
@stateid, @high_prec.ident, @low_prec.ident, @token.to_s)
|
data/test/assets/intp.y
CHANGED
@@ -27,7 +27,7 @@ rule
|
|
27
27
|
result.push val[1]
|
28
28
|
}
|
29
29
|
| stmt_list EOL
|
30
|
-
|
30
|
+
|
31
31
|
stmt : expr
|
32
32
|
| assign
|
33
33
|
| IDENT realprim
|
@@ -38,7 +38,7 @@ rule
|
|
38
38
|
| if_stmt
|
39
39
|
| while_stmt
|
40
40
|
| defun
|
41
|
-
|
41
|
+
|
42
42
|
if_stmt : IF stmt THEN EOL stmt_list else_stmt END
|
43
43
|
{
|
44
44
|
result = IfNode.new( @fname, val[0][0],
|
@@ -261,7 +261,7 @@ module Intp
|
|
261
261
|
|
262
262
|
class Core
|
263
263
|
|
264
|
-
def initialize
|
264
|
+
def initialize
|
265
265
|
@ftab = {}
|
266
266
|
@obj = Object.new
|
267
267
|
@stack = []
|
@@ -318,7 +318,7 @@ module Intp
|
|
318
318
|
def lvar?(name)
|
319
319
|
@lvars.key? name
|
320
320
|
end
|
321
|
-
|
321
|
+
|
322
322
|
def [](key)
|
323
323
|
@lvars[key]
|
324
324
|
end
|