racc 1.5.0 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +2 -4
- data/Rakefile +2 -0
- data/bin/racc +34 -17
- data/ext/racc/cparse/cparse.c +19 -17
- data/lib/racc/compat.rb +2 -3
- data/lib/racc/debugflags.rb +2 -3
- data/lib/racc/grammar.rb +18 -16
- data/lib/racc/grammarfileparser.rb +3 -4
- data/lib/racc/info.rb +1 -1
- data/lib/racc/iset.rb +2 -3
- data/lib/racc/logfilegenerator.rb +2 -3
- data/lib/racc/parser-text.rb +4 -4
- data/lib/racc/parser.rb +4 -4
- data/lib/racc/parserfilegenerator.rb +0 -1
- data/lib/racc/sourcetext.rb +2 -3
- data/lib/racc/statetransitiontable.rb +3 -4
- data/test/helper.rb +3 -3
- data/test/regress/cadenza +95 -95
- data/test/regress/cast +465 -462
- data/test/regress/csspool +196 -200
- data/test/regress/edtf +223 -223
- data/test/regress/huia +144 -144
- data/test/regress/journey +1 -1
- data/test/regress/liquor +109 -109
- data/test/regress/machete +24 -24
- data/test/regress/mediacloth +227 -227
- data/test/regress/mof +93 -93
- data/test/regress/namae +35 -35
- data/test/regress/nasl +310 -310
- data/test/regress/nokogiri-css +62 -62
- data/test/regress/opal +1762 -1760
- data/test/regress/php_serialization +18 -18
- data/test/regress/riml +576 -590
- data/test/regress/ruby18 +1135 -1142
- data/test/regress/ruby22 +1793 -1789
- data/test/regress/tp_plus +215 -215
- data/test/regress/twowaysql +21 -21
- data/test/test_racc_command.rb +17 -0
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edf5dcefea26cb0246401ee59480890de48d5d84885423b882f39ae4394e56fc
|
4
|
+
data.tar.gz: 0b0c54b36dbc6be20469e57cd7538c94ff6b6f060383d6946f578e3baab3a03b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fecf83ab9be1bd80075e10cd966f85eb11a5a5f3b9786481e13b74401e528cf807a35b55a82408b0c638f8d320e298ec199b0599b80b3ca780a2684df04335b0
|
7
|
+
data.tar.gz: 2a6029118b2edcf9164957b1d9a7ac14292c5694bf49bb0e7c156bead403a6302920fced609b79772a6d0a4979cce5aacffd11b3125fcfc621f5b2dd6cfd54c8
|
data/README.rdoc
CHANGED
@@ -16,8 +16,6 @@
|
|
16
16
|
== Requirement
|
17
17
|
|
18
18
|
* Ruby 1.8.x or later.
|
19
|
-
(*) make and C compiler.
|
20
|
-
|
21
19
|
|
22
20
|
== Installation
|
23
21
|
|
@@ -36,9 +34,9 @@
|
|
36
34
|
|
37
35
|
You can install Racc into your favorite directory by giving
|
38
36
|
options to setup.rb. e.g.
|
39
|
-
|
37
|
+
|
40
38
|
$ ruby setup.rb config --prefix=/usr
|
41
|
-
|
39
|
+
|
42
40
|
For details, try "ruby setup.rb --help".
|
43
41
|
|
44
42
|
|
data/Rakefile
CHANGED
data/bin/racc
CHANGED
@@ -51,7 +51,7 @@ def main
|
|
51
51
|
logfilename = path
|
52
52
|
}
|
53
53
|
parser.on('-e', '--executable [RUBYPATH]', 'Makes executable parser.') {|path|
|
54
|
-
|
54
|
+
make_executable = true
|
55
55
|
rubypath = (path == 'ruby' ? nil : path)
|
56
56
|
}
|
57
57
|
parser.on('-E', '--embedded', "Embeds Racc runtime in output.") {
|
@@ -71,10 +71,6 @@ def main
|
|
71
71
|
'Uses CLASSNAME instead of Racc::Parser.') {|name|
|
72
72
|
superclass = name
|
73
73
|
}
|
74
|
-
parser.on('--runtime=FEATURE',
|
75
|
-
"Uses FEATURE instead of 'racc/parser'") {|feat|
|
76
|
-
runtime = feature
|
77
|
-
}
|
78
74
|
parser.on('-C', '--check-only', 'Checks syntax and quit immediately.') {|fl|
|
79
75
|
check_only = fl
|
80
76
|
}
|
@@ -88,20 +84,20 @@ def main
|
|
88
84
|
debug_flags = Racc::DebugFlags.parse_option_string(flags)
|
89
85
|
}
|
90
86
|
#parser.on('--no-extensions', 'Run Racc without any Ruby extension.') {
|
91
|
-
# Racc.const_set :
|
87
|
+
# Racc.const_set :Racc_No_Extensions, true
|
92
88
|
#}
|
93
89
|
parser.on('--version', 'Prints version and quit.') {
|
94
90
|
puts "racc version #{Racc::Version}"
|
95
91
|
exit 0
|
96
92
|
}
|
97
93
|
parser.on('--runtime-version', 'Prints runtime version and quit.') {
|
98
|
-
printf "racc runtime version %s
|
94
|
+
printf "racc runtime version %s; %s\n",
|
99
95
|
Racc::Parser::Racc_Runtime_Version,
|
100
96
|
if Racc::Parser.racc_runtime_type == 'ruby'
|
101
|
-
sprintf('ruby core version %s
|
97
|
+
sprintf('ruby core version %s',
|
102
98
|
Racc::Parser::Racc_Runtime_Core_Version_R)
|
103
99
|
else
|
104
|
-
sprintf('c core version %s
|
100
|
+
sprintf('c core version %s',
|
105
101
|
Racc::Parser::Racc_Runtime_Core_Version_C)
|
106
102
|
end
|
107
103
|
exit 0
|
@@ -184,8 +180,12 @@ def main
|
|
184
180
|
log_useless states.grammar
|
185
181
|
log_conflict states
|
186
182
|
else
|
187
|
-
report_useless states.grammar
|
188
|
-
report_conflict states
|
183
|
+
has_useless = report_useless states.grammar
|
184
|
+
has_conflicts = report_conflict states
|
185
|
+
if has_useless || has_conflicts
|
186
|
+
preamble = make_logfile ? 'C' : 'Turn on logging with "-v" and c'
|
187
|
+
$stderr.puts %Q{#{preamble}heck ".output" file for details}
|
188
|
+
end
|
189
189
|
end
|
190
190
|
|
191
191
|
profiler.report
|
@@ -201,13 +201,29 @@ def make_filename(path, suffix)
|
|
201
201
|
path.sub(/(?:\..*?)?\z/, suffix)
|
202
202
|
end
|
203
203
|
|
204
|
+
LIST_LIMIT = 10
|
205
|
+
def report_list(enum, label)
|
206
|
+
c = enum.count
|
207
|
+
if c > 0
|
208
|
+
$stderr.puts "#{c} #{label}:"
|
209
|
+
enum.first(LIST_LIMIT).each do |item|
|
210
|
+
$stderr.puts " #{yield item}"
|
211
|
+
end
|
212
|
+
$stderr.puts " ..." if c > LIST_LIMIT
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
# @return [Boolean] if anything was reported
|
204
217
|
def report_conflict(states)
|
205
218
|
if states.should_report_srconflict?
|
219
|
+
reported = true
|
206
220
|
$stderr.puts "#{states.n_srconflicts} shift/reduce conflicts"
|
207
221
|
end
|
208
222
|
if states.rrconflict_exist?
|
223
|
+
reported = true
|
209
224
|
$stderr.puts "#{states.n_rrconflicts} reduce/reduce conflicts"
|
210
225
|
end
|
226
|
+
reported
|
211
227
|
end
|
212
228
|
|
213
229
|
def log_conflict(states)
|
@@ -222,16 +238,17 @@ def log_conflict(states)
|
|
222
238
|
}
|
223
239
|
end
|
224
240
|
|
241
|
+
# @return [Boolean] if anything was reported
|
225
242
|
def report_useless(grammar)
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
$stderr.puts "#{grammar.n_useless_rules} useless rules"
|
231
|
-
end
|
243
|
+
reported = report_list(grammar.each_useless_nonterminal, 'useless nonterminals', &:to_s)
|
244
|
+
|
245
|
+
reported ||= report_list(grammar.each_useless_rule, 'useless rules') { |r| "##{r.ident} (#{r.target})" }
|
246
|
+
|
232
247
|
if grammar.start.useless?
|
233
248
|
$stderr.puts 'fatal: start symbol does not derive any sentence'
|
249
|
+
reported = true
|
234
250
|
end
|
251
|
+
reported
|
235
252
|
end
|
236
253
|
|
237
254
|
def log_useless(grammar)
|
data/ext/racc/cparse/cparse.c
CHANGED
@@ -605,7 +605,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
|
|
605
605
|
user_yyerror:
|
606
606
|
if (v->errstatus == 3) {
|
607
607
|
if (v->t == vFINAL_TOKEN) {
|
608
|
-
v->retval =
|
608
|
+
v->retval = Qnil;
|
609
609
|
v->fin = CP_FIN_EOT;
|
610
610
|
return;
|
611
611
|
}
|
@@ -819,14 +819,16 @@ reduce0(RB_BLOCK_CALL_FUNC_ARGLIST(_, data))
|
|
819
819
|
void
|
820
820
|
Init_cparse(void)
|
821
821
|
{
|
822
|
-
#
|
823
|
-
|
822
|
+
#if HAVE_RB_EXT_RACTOR_SAFE
|
823
|
+
rb_ext_ractor_safe(true);
|
824
|
+
#endif
|
825
|
+
|
824
826
|
VALUE Racc, Parser;
|
825
|
-
ID id_racc =
|
827
|
+
ID id_racc = rb_intern_const("Racc");
|
826
828
|
|
827
829
|
if (rb_const_defined(rb_cObject, id_racc)) {
|
828
830
|
Racc = rb_const_get(rb_cObject, id_racc);
|
829
|
-
Parser = rb_const_get_at(Racc,
|
831
|
+
Parser = rb_const_get_at(Racc, rb_intern_const("Parser"));
|
830
832
|
}
|
831
833
|
else {
|
832
834
|
Racc = rb_define_module("Racc");
|
@@ -846,16 +848,16 @@ Init_cparse(void)
|
|
846
848
|
|
847
849
|
RaccBug = rb_eRuntimeError;
|
848
850
|
|
849
|
-
id_yydebug =
|
850
|
-
id_nexttoken =
|
851
|
-
id_onerror =
|
852
|
-
id_noreduce =
|
853
|
-
id_errstatus =
|
854
|
-
|
855
|
-
id_d_shift =
|
856
|
-
id_d_reduce =
|
857
|
-
id_d_accept =
|
858
|
-
id_d_read_token =
|
859
|
-
id_d_next_state =
|
860
|
-
id_d_e_pop =
|
851
|
+
id_yydebug = rb_intern_const("@yydebug");
|
852
|
+
id_nexttoken = rb_intern_const("next_token");
|
853
|
+
id_onerror = rb_intern_const("on_error");
|
854
|
+
id_noreduce = rb_intern_const("_reduce_none");
|
855
|
+
id_errstatus = rb_intern_const("@racc_error_status");
|
856
|
+
|
857
|
+
id_d_shift = rb_intern_const("racc_shift");
|
858
|
+
id_d_reduce = rb_intern_const("racc_reduce");
|
859
|
+
id_d_accept = rb_intern_const("racc_accept");
|
860
|
+
id_d_read_token = rb_intern_const("racc_read_token");
|
861
|
+
id_d_next_state = rb_intern_const("racc_next_state");
|
862
|
+
id_d_e_pop = rb_intern_const("racc_e_pop");
|
861
863
|
}
|
data/lib/racc/compat.rb
CHANGED
@@ -5,9 +5,8 @@
|
|
5
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
6
6
|
#
|
7
7
|
# This program is free software.
|
8
|
-
# You can distribute/modify this program under the terms of
|
9
|
-
# the
|
10
|
-
# 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".
|
11
10
|
#
|
12
11
|
#++
|
13
12
|
|
data/lib/racc/debugflags.rb
CHANGED
@@ -5,9 +5,8 @@
|
|
5
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
6
6
|
#
|
7
7
|
# This program is free software.
|
8
|
-
# You can distribute/modify this program under the terms of
|
9
|
-
# the
|
10
|
-
# 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".
|
11
10
|
#
|
12
11
|
#++
|
13
12
|
|
data/lib/racc/grammar.rb
CHANGED
@@ -86,14 +86,15 @@ module Racc
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def n_useless_nonterminals
|
89
|
-
@n_useless_nonterminals ||=
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
97
98
|
end
|
98
99
|
|
99
100
|
def useless_rule_exist?
|
@@ -101,14 +102,15 @@ module Racc
|
|
101
102
|
end
|
102
103
|
|
103
104
|
def n_useless_rules
|
104
|
-
@n_useless_rules ||=
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
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
|
112
114
|
end
|
113
115
|
|
114
116
|
def nfa
|
@@ -5,9 +5,8 @@
|
|
5
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
6
6
|
#
|
7
7
|
# This program is free software.
|
8
|
-
# You can distribute/modify this program under the terms of
|
9
|
-
# the
|
10
|
-
# 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".
|
11
10
|
#
|
12
11
|
#++
|
13
12
|
|
@@ -288,7 +287,7 @@ module Racc
|
|
288
287
|
end
|
289
288
|
|
290
289
|
def add_user_code(label, src)
|
291
|
-
@result.params.
|
290
|
+
@result.params.public_send(USER_CODE_LABELS[label]).push src
|
292
291
|
end
|
293
292
|
|
294
293
|
end
|
data/lib/racc/info.rb
CHANGED
data/lib/racc/iset.rb
CHANGED
@@ -5,9 +5,8 @@
|
|
5
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
6
6
|
#
|
7
7
|
# This program is free software.
|
8
|
-
# You can distribute/modify this program under the terms of
|
9
|
-
# the
|
10
|
-
# 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".
|
11
10
|
#
|
12
11
|
#++
|
13
12
|
|
@@ -5,9 +5,8 @@
|
|
5
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
6
6
|
#
|
7
7
|
# This program is free software.
|
8
|
-
# You can distribute/modify this program under the terms of
|
9
|
-
# the
|
10
|
-
# 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".
|
11
10
|
#
|
12
11
|
#++
|
13
12
|
|
data/lib/racc/parser-text.rb
CHANGED
@@ -181,8 +181,8 @@ 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
|
@@ -202,7 +202,7 @@ module Racc
|
|
202
202
|
unless new.respond_to?(:_racc_do_parse_c, true)
|
203
203
|
raise LoadError, 'old cparse.so'
|
204
204
|
end
|
205
|
-
if
|
205
|
+
if Racc_No_Extensions
|
206
206
|
raise LoadError, 'selecting ruby version of racc runtime core'
|
207
207
|
end
|
208
208
|
|
@@ -326,7 +326,7 @@ module Racc
|
|
326
326
|
# It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
|
327
327
|
class_eval %{
|
328
328
|
def yyparse(recv, mid)
|
329
|
-
#{Racc_YY_Parse_Method}(recv, mid, _racc_setup(),
|
329
|
+
#{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
|
330
330
|
end
|
331
331
|
}
|
332
332
|
|
data/lib/racc/parser.rb
CHANGED
@@ -179,8 +179,8 @@ 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
|
@@ -200,7 +200,7 @@ module Racc
|
|
200
200
|
unless new.respond_to?(:_racc_do_parse_c, true)
|
201
201
|
raise LoadError, 'old cparse.so'
|
202
202
|
end
|
203
|
-
if
|
203
|
+
if Racc_No_Extensions
|
204
204
|
raise LoadError, 'selecting ruby version of racc runtime core'
|
205
205
|
end
|
206
206
|
|
@@ -324,7 +324,7 @@ module Racc
|
|
324
324
|
# It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
|
325
325
|
class_eval %{
|
326
326
|
def yyparse(recv, mid)
|
327
|
-
#{Racc_YY_Parse_Method}(recv, mid, _racc_setup(),
|
327
|
+
#{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
|
328
328
|
end
|
329
329
|
}
|
330
330
|
|
data/lib/racc/sourcetext.rb
CHANGED
@@ -5,9 +5,8 @@
|
|
5
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
6
6
|
#
|
7
7
|
# This program is free software.
|
8
|
-
# You can distribute/modify this program under the terms of
|
9
|
-
# the
|
10
|
-
# 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".
|
11
10
|
#
|
12
11
|
#++
|
13
12
|
|
@@ -5,9 +5,8 @@
|
|
5
5
|
# Copyright (c) 1999-2006 Minero Aoki
|
6
6
|
#
|
7
7
|
# This program is free software.
|
8
|
-
# You can distribute/modify this program under the terms of
|
9
|
-
# the
|
10
|
-
# 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".
|
11
10
|
#
|
12
11
|
#++
|
13
12
|
|
@@ -231,7 +230,7 @@ module Racc
|
|
231
230
|
map = '-' * 10240
|
232
231
|
|
233
232
|
# sort long to short
|
234
|
-
entries.
|
233
|
+
entries.sort_by!.with_index {|a,i| [-a[0].size, i] }
|
235
234
|
|
236
235
|
entries.each do |arr, chkval, expr, min, ptri|
|
237
236
|
if upper + arr.size > map.size
|
data/test/helper.rb
CHANGED
@@ -86,11 +86,11 @@ module Racc
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def assert_output_unchanged(asset)
|
89
|
-
# racc generates the difference results in GitHub Actions
|
90
|
-
omit unless RUBY_PLATFORM =~ /darwin/
|
91
|
-
|
92
89
|
file = File.basename(asset, '.y')
|
93
90
|
|
91
|
+
# Code to re-generate the expectation files
|
92
|
+
# File.write("#{REGRESS_DIR}/#{file}", File.read("#{@TAB_DIR}/#{file}"))
|
93
|
+
|
94
94
|
expected = File.read("#{REGRESS_DIR}/#{file}")
|
95
95
|
actual = File.read("#{@TAB_DIR}/#{file}")
|
96
96
|
result = (strip_version(expected) == strip_version(actual))
|