racc 1.4.16 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.ja.rdoc +0 -1
- data/README.rdoc +8 -11
- data/bin/racc +37 -23
- data/{rdoc → doc}/en/NEWS.en.rdoc +0 -0
- data/{rdoc → doc}/en/grammar.en.rdoc +27 -31
- data/doc/en/grammar2.en.rdoc +219 -0
- data/{rdoc → doc}/ja/NEWS.ja.rdoc +0 -0
- data/{rdoc → doc}/ja/command.ja.html +1 -1
- data/{rdoc → doc}/ja/debug.ja.rdoc +0 -0
- data/{rdoc → doc}/ja/grammar.ja.rdoc +0 -0
- data/{rdoc → doc}/ja/index.ja.html +0 -0
- data/{rdoc → doc}/ja/parser.ja.rdoc +0 -0
- data/{rdoc → doc}/ja/usage.ja.html +0 -0
- data/ext/racc/cparse/cparse.c +19 -17
- data/ext/racc/cparse/extconf.rb +2 -1
- data/lib/racc/compat.rb +5 -4
- data/lib/racc/debugflags.rb +5 -4
- data/lib/racc/exception.rb +4 -1
- data/lib/racc/grammar.rb +22 -17
- data/lib/racc/grammarfileparser.rb +7 -6
- data/lib/racc/info.rb +5 -2
- data/lib/racc/iset.rb +5 -4
- data/lib/racc/logfilegenerator.rb +5 -4
- data/lib/racc/parser-text.rb +10 -16
- data/lib/racc/parser.rb +10 -16
- data/lib/racc/parserfilegenerator.rb +5 -47
- data/lib/racc/sourcetext.rb +5 -4
- data/lib/racc/state.rb +4 -1
- data/lib/racc/statetransitiontable.rb +9 -14
- metadata +22 -140
- data/DEPENDS +0 -4
- data/Manifest.txt +0 -146
- data/Rakefile +0 -58
- data/bin/racc2y +0 -195
- data/bin/y2racc +0 -339
- data/ext/racc/com/headius/racc/Cparse.java +0 -849
- data/fastcache/extconf.rb +0 -2
- data/fastcache/fastcache.c +0 -185
- data/lib/racc/pre-setup +0 -13
- data/misc/dist.sh +0 -31
- data/sample/array.y +0 -67
- data/sample/array2.y +0 -59
- data/sample/calc-ja.y +0 -66
- data/sample/calc.y +0 -65
- data/sample/conflict.y +0 -15
- data/sample/hash.y +0 -60
- data/sample/lalr.y +0 -17
- data/sample/lists.y +0 -57
- data/sample/syntax.y +0 -46
- data/sample/yyerr.y +0 -46
- data/setup.rb +0 -1587
- data/tasks/doc.rb +0 -12
- data/tasks/email.rb +0 -55
- data/test/assets/cadenza.y +0 -170
- data/test/assets/cast.y +0 -926
- data/test/assets/chk.y +0 -126
- data/test/assets/conf.y +0 -16
- data/test/assets/csspool.y +0 -729
- data/test/assets/digraph.y +0 -29
- data/test/assets/echk.y +0 -118
- data/test/assets/edtf.y +0 -583
- data/test/assets/err.y +0 -60
- data/test/assets/error_recovery.y +0 -35
- data/test/assets/expect.y +0 -7
- data/test/assets/firstline.y +0 -4
- data/test/assets/huia.y +0 -318
- data/test/assets/ichk.y +0 -102
- data/test/assets/intp.y +0 -546
- data/test/assets/journey.y +0 -47
- data/test/assets/liquor.y +0 -313
- data/test/assets/machete.y +0 -423
- data/test/assets/macruby.y +0 -2197
- data/test/assets/mailp.y +0 -437
- data/test/assets/mediacloth.y +0 -599
- data/test/assets/mof.y +0 -649
- data/test/assets/namae.y +0 -302
- data/test/assets/nasl.y +0 -626
- data/test/assets/newsyn.y +0 -25
- data/test/assets/noend.y +0 -4
- data/test/assets/nokogiri-css.y +0 -255
- data/test/assets/nonass.y +0 -41
- data/test/assets/normal.y +0 -27
- data/test/assets/norule.y +0 -4
- data/test/assets/nullbug1.y +0 -25
- data/test/assets/nullbug2.y +0 -15
- data/test/assets/opal.y +0 -1807
- data/test/assets/opt.y +0 -123
- data/test/assets/percent.y +0 -35
- data/test/assets/php_serialization.y +0 -98
- data/test/assets/recv.y +0 -97
- data/test/assets/riml.y +0 -665
- data/test/assets/rrconf.y +0 -14
- data/test/assets/ruby18.y +0 -1943
- data/test/assets/ruby19.y +0 -2174
- data/test/assets/ruby20.y +0 -2350
- data/test/assets/ruby21.y +0 -2359
- data/test/assets/ruby22.y +0 -2381
- data/test/assets/scan.y +0 -72
- data/test/assets/syntax.y +0 -50
- data/test/assets/tp_plus.y +0 -622
- data/test/assets/twowaysql.y +0 -278
- data/test/assets/unterm.y +0 -5
- data/test/assets/useless.y +0 -12
- data/test/assets/yyerr.y +0 -46
- data/test/bench.y +0 -36
- data/test/helper.rb +0 -115
- data/test/infini.y +0 -8
- data/test/regress/cadenza +0 -796
- data/test/regress/cast +0 -3425
- data/test/regress/csspool +0 -2318
- data/test/regress/edtf +0 -1794
- data/test/regress/huia +0 -1392
- data/test/regress/journey +0 -222
- data/test/regress/liquor +0 -885
- data/test/regress/machete +0 -833
- data/test/regress/mediacloth +0 -1463
- data/test/regress/mof +0 -1368
- data/test/regress/namae +0 -634
- data/test/regress/nasl +0 -2058
- data/test/regress/nokogiri-css +0 -836
- data/test/regress/opal +0 -6429
- data/test/regress/php_serialization +0 -336
- data/test/regress/riml +0 -3297
- data/test/regress/ruby18 +0 -6351
- data/test/regress/ruby22 +0 -7456
- data/test/regress/tp_plus +0 -1933
- data/test/regress/twowaysql +0 -556
- data/test/scandata/brace +0 -7
- data/test/scandata/gvar +0 -1
- data/test/scandata/normal +0 -4
- data/test/scandata/percent +0 -18
- data/test/scandata/slash +0 -10
- data/test/src.intp +0 -34
- data/test/start.y +0 -20
- data/test/test_chk_y.rb +0 -52
- data/test/test_grammar_file_parser.rb +0 -15
- data/test/test_racc_command.rb +0 -322
- data/test/test_scan_y.rb +0 -52
- data/test/testscanner.rb +0 -51
- data/web/racc.en.rhtml +0 -42
- data/web/racc.ja.rhtml +0 -51
data/lib/racc/debugflags.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
+
#--
|
2
|
+
#
|
1
3
|
#
|
2
|
-
# $Id: 74ff4369ce53c7f45cfc2644ce907785104ebf6e $
|
3
4
|
#
|
4
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
6
|
#
|
6
7
|
# This program is free software.
|
7
|
-
# You can distribute/modify this program under the terms of
|
8
|
-
# the
|
9
|
-
# For details of LGPL, see the file "COPYING".
|
8
|
+
# You can distribute/modify this program under the same terms of ruby.
|
9
|
+
# see the file "COPYING".
|
10
10
|
#
|
11
|
+
#++
|
11
12
|
|
12
13
|
module Racc
|
13
14
|
|
data/lib/racc/exception.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
#--
|
2
|
+
#
|
1
3
|
#
|
2
|
-
# $Id: ebb9798ad0b211e031670a12a1ab154678c1c8f3 $
|
3
4
|
#
|
4
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
6
|
#
|
6
7
|
# This program is free software.
|
7
8
|
# You can distribute/modify this program under the same terms of ruby.
|
8
9
|
# see the file "COPYING".
|
10
|
+
#
|
11
|
+
#++
|
9
12
|
|
10
13
|
module Racc
|
11
14
|
class Error < StandardError; end
|
data/lib/racc/grammar.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
#--
|
2
|
+
#
|
1
3
|
#
|
2
|
-
# $Id: 3fcabd58bef02540bf78e8142469681cb9f975c2 $
|
3
4
|
#
|
4
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
6
|
#
|
6
7
|
# This program is free software.
|
7
8
|
# You can distribute/modify this program under the same terms of ruby.
|
8
9
|
# see the file "COPYING".
|
10
|
+
#
|
11
|
+
#++
|
9
12
|
|
10
13
|
require 'racc/compat'
|
11
14
|
require 'racc/iset'
|
@@ -83,14 +86,15 @@ module Racc
|
|
83
86
|
end
|
84
87
|
|
85
88
|
def n_useless_nonterminals
|
86
|
-
@n_useless_nonterminals ||=
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
89
|
+
@n_useless_nonterminals ||= each_useless_nonterminal.count
|
90
|
+
end
|
91
|
+
|
92
|
+
def each_useless_nonterminal
|
93
|
+
return to_enum __method__ unless block_given?
|
94
|
+
|
95
|
+
@symboltable.each_nonterminal do |sym|
|
96
|
+
yield sym if sym.useless?
|
97
|
+
end
|
94
98
|
end
|
95
99
|
|
96
100
|
def useless_rule_exist?
|
@@ -98,14 +102,15 @@ module Racc
|
|
98
102
|
end
|
99
103
|
|
100
104
|
def n_useless_rules
|
101
|
-
@n_useless_rules ||=
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
@n_useless_rules ||= each_useless_rule.count
|
106
|
+
end
|
107
|
+
|
108
|
+
def each_useless_rule
|
109
|
+
return to_enum __method__ unless block_given?
|
110
|
+
|
111
|
+
each do |r|
|
112
|
+
yield r if r.useless?
|
113
|
+
end
|
109
114
|
end
|
110
115
|
|
111
116
|
def nfa
|
@@ -1,13 +1,14 @@
|
|
1
|
+
#--
|
2
|
+
#
|
1
3
|
#
|
2
|
-
# $Id: 63bd084db2dce8a2c9760318faae6104717cead7 $
|
3
4
|
#
|
4
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
6
|
#
|
6
7
|
# 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".
|
8
|
+
# You can distribute/modify this program under the same terms of ruby.
|
9
|
+
# see the file "COPYING".
|
10
10
|
#
|
11
|
+
#++
|
11
12
|
|
12
13
|
require 'racc'
|
13
14
|
require 'racc/compat'
|
@@ -286,7 +287,7 @@ module Racc
|
|
286
287
|
end
|
287
288
|
|
288
289
|
def add_user_code(label, src)
|
289
|
-
@result.params.
|
290
|
+
@result.params.public_send(USER_CODE_LABELS[label]).push src
|
290
291
|
end
|
291
292
|
|
292
293
|
end
|
@@ -427,7 +428,7 @@ module Racc
|
|
427
428
|
$raccs_print_type = false
|
428
429
|
|
429
430
|
def scan_action
|
430
|
-
buf =
|
431
|
+
buf = String.new
|
431
432
|
nest = 1
|
432
433
|
pre = nil
|
433
434
|
@in_block = 'action'
|
data/lib/racc/info.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
|
+
#--
|
2
|
+
#
|
1
3
|
#
|
2
|
-
# $Id: 8ab2cb5341529fe5e35956bb1a1f42ec9b9c6f5a $
|
3
4
|
#
|
4
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
6
|
#
|
6
7
|
# This program is free software.
|
7
8
|
# You can distribute/modify this program under the same terms of ruby.
|
8
9
|
# see the file "COPYING".
|
10
|
+
#
|
11
|
+
#++
|
9
12
|
|
10
13
|
module Racc
|
11
|
-
VERSION = '1.
|
14
|
+
VERSION = '1.6.0'
|
12
15
|
Version = VERSION
|
13
16
|
Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
|
14
17
|
end
|
data/lib/racc/iset.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
+
#--
|
2
|
+
#
|
1
3
|
#
|
2
|
-
# $Id: 31aa4331c08dfd4609c06eb5f94b7ef38dc708e1 $
|
3
4
|
#
|
4
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
6
|
#
|
6
7
|
# 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".
|
8
|
+
# You can distribute/modify this program under the same terms of ruby.
|
9
|
+
# see the file "COPYING".
|
10
10
|
#
|
11
|
+
#++
|
11
12
|
|
12
13
|
module Racc
|
13
14
|
|
@@ -1,13 +1,14 @@
|
|
1
|
+
#--
|
2
|
+
#
|
1
3
|
#
|
2
|
-
# $Id: 5e9d0a01b5d56fd9cdc3d5cb078b1a3e1bbaf779 $
|
3
4
|
#
|
4
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
6
|
#
|
6
7
|
# 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".
|
8
|
+
# You can distribute/modify this program under the same terms of ruby.
|
9
|
+
# see the file "COPYING".
|
10
10
|
#
|
11
|
+
#++
|
11
12
|
|
12
13
|
module Racc
|
13
14
|
|
data/lib/racc/parser-text.rb
CHANGED
@@ -31,7 +31,7 @@ end
|
|
31
31
|
# == Command-line Reference
|
32
32
|
#
|
33
33
|
# racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
|
34
|
-
# [-e<var>rubypath</var>] [--
|
34
|
+
# [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
|
35
35
|
# [-v] [--verbose]
|
36
36
|
# [-O<var>filename</var>] [--log-file=<var>filename</var>]
|
37
37
|
# [-g] [--debug]
|
@@ -43,7 +43,7 @@ end
|
|
43
43
|
# [-S] [--output-status]
|
44
44
|
# [--version] [--copyright] [--help] <var>grammarfile</var>
|
45
45
|
#
|
46
|
-
# [+
|
46
|
+
# [+grammarfile+]
|
47
47
|
# Racc grammar file. Any extension is permitted.
|
48
48
|
# [-o+outfile+, --output-file=+outfile+]
|
49
49
|
# A filename for output. default is <+filename+>.tab.rb
|
@@ -181,45 +181,39 @@ end
|
|
181
181
|
# Your own parser is completely yours.
|
182
182
|
module Racc
|
183
183
|
|
184
|
-
unless defined?(
|
185
|
-
|
184
|
+
unless defined?(Racc_No_Extensions)
|
185
|
+
Racc_No_Extensions = false # :nodoc:
|
186
186
|
end
|
187
187
|
|
188
188
|
class Parser
|
189
189
|
|
190
190
|
Racc_Runtime_Version = ::Racc::VERSION
|
191
|
-
Racc_Runtime_Revision = '$Id: 7adc21ee7a5690f10b7ff399b8af4e2717b9d94c $'
|
192
|
-
|
193
191
|
Racc_Runtime_Core_Version_R = ::Racc::VERSION
|
194
|
-
|
192
|
+
|
195
193
|
begin
|
196
194
|
if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
|
195
|
+
require 'jruby'
|
197
196
|
require 'racc/cparse-jruby.jar'
|
198
197
|
com.headius.racc.Cparse.new.load(JRuby.runtime, false)
|
199
198
|
else
|
200
199
|
require 'racc/cparse'
|
201
200
|
end
|
202
|
-
|
203
|
-
Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
|
201
|
+
|
204
202
|
unless new.respond_to?(:_racc_do_parse_c, true)
|
205
203
|
raise LoadError, 'old cparse.so'
|
206
204
|
end
|
207
|
-
if
|
205
|
+
if Racc_No_Extensions
|
208
206
|
raise LoadError, 'selecting ruby version of racc runtime core'
|
209
207
|
end
|
210
208
|
|
211
209
|
Racc_Main_Parsing_Routine = :_racc_do_parse_c # :nodoc:
|
212
210
|
Racc_YY_Parse_Method = :_racc_yyparse_c # :nodoc:
|
213
211
|
Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C # :nodoc:
|
214
|
-
Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_C # :nodoc:
|
215
212
|
Racc_Runtime_Type = 'c' # :nodoc:
|
216
213
|
rescue LoadError
|
217
|
-
puts $!
|
218
|
-
puts $!.backtrace
|
219
214
|
Racc_Main_Parsing_Routine = :_racc_do_parse_rb
|
220
215
|
Racc_YY_Parse_Method = :_racc_yyparse_rb
|
221
216
|
Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
|
222
|
-
Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_R
|
223
217
|
Racc_Runtime_Type = 'ruby'
|
224
218
|
end
|
225
219
|
|
@@ -332,7 +326,7 @@ puts $!.backtrace
|
|
332
326
|
# It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
|
333
327
|
class_eval %{
|
334
328
|
def yyparse(recv, mid)
|
335
|
-
#{Racc_YY_Parse_Method}(recv, mid, _racc_setup(),
|
329
|
+
#{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
|
336
330
|
end
|
337
331
|
}
|
338
332
|
|
@@ -554,7 +548,7 @@ puts $!.backtrace
|
|
554
548
|
end
|
555
549
|
|
556
550
|
# Exit parser.
|
557
|
-
# Return value is Symbol_Value_Stack[0]
|
551
|
+
# Return value is +Symbol_Value_Stack[0]+.
|
558
552
|
def yyaccept
|
559
553
|
throw :racc_jump, 2
|
560
554
|
end
|
data/lib/racc/parser.rb
CHANGED
@@ -29,7 +29,7 @@ end
|
|
29
29
|
# == Command-line Reference
|
30
30
|
#
|
31
31
|
# racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
|
32
|
-
# [-e<var>rubypath</var>] [--
|
32
|
+
# [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
|
33
33
|
# [-v] [--verbose]
|
34
34
|
# [-O<var>filename</var>] [--log-file=<var>filename</var>]
|
35
35
|
# [-g] [--debug]
|
@@ -41,7 +41,7 @@ end
|
|
41
41
|
# [-S] [--output-status]
|
42
42
|
# [--version] [--copyright] [--help] <var>grammarfile</var>
|
43
43
|
#
|
44
|
-
# [+
|
44
|
+
# [+grammarfile+]
|
45
45
|
# Racc grammar file. Any extension is permitted.
|
46
46
|
# [-o+outfile+, --output-file=+outfile+]
|
47
47
|
# A filename for output. default is <+filename+>.tab.rb
|
@@ -179,45 +179,39 @@ end
|
|
179
179
|
# Your own parser is completely yours.
|
180
180
|
module Racc
|
181
181
|
|
182
|
-
unless defined?(
|
183
|
-
|
182
|
+
unless defined?(Racc_No_Extensions)
|
183
|
+
Racc_No_Extensions = false # :nodoc:
|
184
184
|
end
|
185
185
|
|
186
186
|
class Parser
|
187
187
|
|
188
188
|
Racc_Runtime_Version = ::Racc::VERSION
|
189
|
-
Racc_Runtime_Revision = '$Id: e754525bd317344c4284fca6fdce0a425979ade1 $'
|
190
|
-
|
191
189
|
Racc_Runtime_Core_Version_R = ::Racc::VERSION
|
192
|
-
|
190
|
+
|
193
191
|
begin
|
194
192
|
if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
|
193
|
+
require 'jruby'
|
195
194
|
require 'racc/cparse-jruby.jar'
|
196
195
|
com.headius.racc.Cparse.new.load(JRuby.runtime, false)
|
197
196
|
else
|
198
197
|
require 'racc/cparse'
|
199
198
|
end
|
200
|
-
|
201
|
-
Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
|
199
|
+
|
202
200
|
unless new.respond_to?(:_racc_do_parse_c, true)
|
203
201
|
raise LoadError, 'old cparse.so'
|
204
202
|
end
|
205
|
-
if
|
203
|
+
if Racc_No_Extensions
|
206
204
|
raise LoadError, 'selecting ruby version of racc runtime core'
|
207
205
|
end
|
208
206
|
|
209
207
|
Racc_Main_Parsing_Routine = :_racc_do_parse_c # :nodoc:
|
210
208
|
Racc_YY_Parse_Method = :_racc_yyparse_c # :nodoc:
|
211
209
|
Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C # :nodoc:
|
212
|
-
Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_C # :nodoc:
|
213
210
|
Racc_Runtime_Type = 'c' # :nodoc:
|
214
211
|
rescue LoadError
|
215
|
-
puts $!
|
216
|
-
puts $!.backtrace
|
217
212
|
Racc_Main_Parsing_Routine = :_racc_do_parse_rb
|
218
213
|
Racc_YY_Parse_Method = :_racc_yyparse_rb
|
219
214
|
Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
|
220
|
-
Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_R
|
221
215
|
Racc_Runtime_Type = 'ruby'
|
222
216
|
end
|
223
217
|
|
@@ -330,7 +324,7 @@ puts $!.backtrace
|
|
330
324
|
# It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
|
331
325
|
class_eval %{
|
332
326
|
def yyparse(recv, mid)
|
333
|
-
#{Racc_YY_Parse_Method}(recv, mid, _racc_setup(),
|
327
|
+
#{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
|
334
328
|
end
|
335
329
|
}
|
336
330
|
|
@@ -552,7 +546,7 @@ puts $!.backtrace
|
|
552
546
|
end
|
553
547
|
|
554
548
|
# Exit parser.
|
555
|
-
# Return value is Symbol_Value_Stack[0]
|
549
|
+
# Return value is +Symbol_Value_Stack[0]+.
|
556
550
|
def yyaccept
|
557
551
|
throw :racc_jump, 2
|
558
552
|
end
|
@@ -1,13 +1,15 @@
|
|
1
|
+
#--
|
2
|
+
#
|
1
3
|
#
|
2
|
-
# $Id: fff07ebfd582f8dbc845e424908cb9f41f8bf42f $
|
3
4
|
#
|
4
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
6
|
#
|
6
7
|
# This program is free software.
|
7
8
|
# You can distribute/modify this program under the same terms of ruby.
|
8
9
|
# see the file "COPYING".
|
10
|
+
#
|
11
|
+
#++
|
9
12
|
|
10
|
-
require 'enumerator'
|
11
13
|
require 'racc/compat'
|
12
14
|
require 'racc/sourcetext'
|
13
15
|
require 'racc/parser-text'
|
@@ -235,7 +237,7 @@ module Racc
|
|
235
237
|
end
|
236
238
|
|
237
239
|
def unique_separator(id)
|
238
|
-
sep = "...end #{id}/module_eval..."
|
240
|
+
sep = String.new "...end #{id}/module_eval..."
|
239
241
|
while @used_separator.key?(sep)
|
240
242
|
sep.concat sprintf('%02x', rand(255))
|
241
243
|
end
|
@@ -318,50 +320,6 @@ module Racc
|
|
318
320
|
end
|
319
321
|
|
320
322
|
def integer_list(name, table)
|
321
|
-
if table.size > 2000
|
322
|
-
serialize_integer_list_compressed name, table
|
323
|
-
else
|
324
|
-
serialize_integer_list_std name, table
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
|
-
def serialize_integer_list_compressed(name, table)
|
329
|
-
# TODO: this can be made a LOT more clean with a simple split/map
|
330
|
-
sep = "\n"
|
331
|
-
nsep = ",\n"
|
332
|
-
buf = ''
|
333
|
-
com = ''
|
334
|
-
ncom = ','
|
335
|
-
co = com
|
336
|
-
@f.print 'clist = ['
|
337
|
-
table.each do |i|
|
338
|
-
buf << co << i.to_s; co = ncom
|
339
|
-
if buf.size > 66
|
340
|
-
@f.print sep; sep = nsep
|
341
|
-
@f.print "'", buf, "'"
|
342
|
-
buf = ''
|
343
|
-
co = com
|
344
|
-
end
|
345
|
-
end
|
346
|
-
unless buf.empty?
|
347
|
-
@f.print sep
|
348
|
-
@f.print "'", buf, "'"
|
349
|
-
end
|
350
|
-
line ' ]'
|
351
|
-
|
352
|
-
@f.print(<<-End)
|
353
|
-
#{name} = arr = ::Array.new(#{table.size}, nil)
|
354
|
-
idx = 0
|
355
|
-
clist.each do |str|
|
356
|
-
str.split(',', -1).each do |i|
|
357
|
-
arr[idx] = i.to_i unless i.empty?
|
358
|
-
idx += 1
|
359
|
-
end
|
360
|
-
end
|
361
|
-
End
|
362
|
-
end
|
363
|
-
|
364
|
-
def serialize_integer_list_std(name, table)
|
365
323
|
sep = ''
|
366
324
|
line "#{name} = ["
|
367
325
|
table.each_slice(10) do |ns|
|
data/lib/racc/sourcetext.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
+
#--
|
2
|
+
#
|
1
3
|
#
|
2
|
-
# $Id: 3b2d89d9ada2f5fcb043837dcc5c9631856d5b70 $
|
3
4
|
#
|
4
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
6
|
#
|
6
7
|
# This program is free software.
|
7
|
-
# You can distribute/modify this program under the terms of
|
8
|
-
# the
|
9
|
-
# For details of LGPL, see the file "COPYING".
|
8
|
+
# You can distribute/modify this program under the same terms of ruby.
|
9
|
+
# see the file "COPYING".
|
10
10
|
#
|
11
|
+
#++
|
11
12
|
|
12
13
|
module Racc
|
13
14
|
|
data/lib/racc/state.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
#--
|
2
|
+
#
|
1
3
|
#
|
2
|
-
# $Id: 6bd3136439c94cb8d928917f5e0de9c593181527 $
|
3
4
|
#
|
4
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
6
|
#
|
6
7
|
# This program is free software.
|
7
8
|
# You can distribute/modify this program under the same terms of ruby.
|
8
9
|
# see the file "COPYING".
|
10
|
+
#
|
11
|
+
#++
|
9
12
|
|
10
13
|
require 'racc/iset'
|
11
14
|
require 'racc/statetransitiontable'
|
@@ -1,22 +1,17 @@
|
|
1
|
+
#--
|
2
|
+
#
|
1
3
|
#
|
2
|
-
# $Id: 4c5f4311663b6d03050953d64d6a0e7905ff2216 $
|
3
4
|
#
|
4
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
5
6
|
#
|
6
7
|
# This program is free software.
|
7
|
-
# You can distribute/modify this program under the terms of
|
8
|
-
# the
|
9
|
-
# For details of LGPL, see the file "COPYING".
|
8
|
+
# You can distribute/modify this program under the same terms of ruby.
|
9
|
+
# see the file "COPYING".
|
10
10
|
#
|
11
|
+
#++
|
11
12
|
|
12
13
|
require 'racc/parser'
|
13
14
|
|
14
|
-
unless Object.method_defined?(:funcall)
|
15
|
-
class Object
|
16
|
-
alias funcall __send__
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
15
|
module Racc
|
21
16
|
|
22
17
|
StateTransitionTable = Struct.new(:action_table,
|
@@ -196,7 +191,7 @@ module Racc
|
|
196
191
|
def mkmapexp(arr)
|
197
192
|
i = ii = 0
|
198
193
|
as = arr.size
|
199
|
-
map =
|
194
|
+
map = String.new
|
200
195
|
maxdup = RE_DUP_MAX
|
201
196
|
curr = nil
|
202
197
|
while i < as
|
@@ -229,7 +224,7 @@ module Racc
|
|
229
224
|
map = '-' * 10240
|
230
225
|
|
231
226
|
# sort long to short
|
232
|
-
entries.
|
227
|
+
entries.sort_by!.with_index {|a,i| [-a[0].size, i] }
|
233
228
|
|
234
229
|
entries.each do |arr, chkval, expr, min, ptri|
|
235
230
|
if upper + arr.size > map.size
|
@@ -299,9 +294,9 @@ module Racc
|
|
299
294
|
c.module_eval "def _reduce_none(vals, vstack) vals[0] end"
|
300
295
|
@grammar.each do |rule|
|
301
296
|
if rule.action.empty?
|
302
|
-
c.
|
297
|
+
c.alias_method("_reduce_#{rule.ident}", :_reduce_none)
|
303
298
|
else
|
304
|
-
c.
|
299
|
+
c.define_method("_racc_action_#{rule.ident}", &rule.action.proc)
|
305
300
|
c.module_eval(<<-End, __FILE__, __LINE__ + 1)
|
306
301
|
def _reduce_#{rule.ident}(vals, vstack)
|
307
302
|
_racc_action_#{rule.ident}(*vals)
|