racc 1.6.2 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +3 -3
- data/README.ja.rdoc +2 -38
- data/README.rdoc +7 -26
- data/TODO +1 -1
- data/bin/racc +32 -32
- data/doc/en/grammar.en.rdoc +99 -107
- data/doc/en/grammar2.en.rdoc +1 -1
- data/doc/ja/command.ja.html +5 -0
- data/doc/ja/grammar.ja.rdoc +1 -1
- data/doc/ja/parser.ja.rdoc +1 -1
- data/ext/racc/cparse/cparse.c +26 -47
- data/ext/racc/cparse/extconf.rb +3 -4
- data/lib/racc/grammar.rb +77 -4
- data/lib/racc/grammarfileparser.rb +114 -8
- data/lib/racc/info.rb +2 -1
- data/lib/racc/parser-text.rb +17 -10
- data/lib/racc/parser.rb +9 -11
- data/lib/racc/parserfilegenerator.rb +7 -2
- data/lib/racc/state.rb +4 -0
- metadata +3 -6
- data/doc/en/NEWS.en.rdoc +0 -282
- data/doc/ja/NEWS.ja.rdoc +0 -307
- data/ext/racc/MANIFEST +0 -4
data/ext/racc/cparse/cparse.c
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
Important Constants
|
23
23
|
----------------------------------------------------------------------- */
|
24
24
|
|
25
|
-
#define RACC_VERSION
|
25
|
+
#define RACC_VERSION STRINGIZE(RACC_INFO_VERSION)
|
26
26
|
|
27
27
|
#define DEFAULT_TOKEN -1
|
28
28
|
#define ERROR_TOKEN 1
|
@@ -70,12 +70,8 @@ static ID id_d_e_pop;
|
|
70
70
|
# define LONG2NUM(i) INT2NUM(i)
|
71
71
|
#endif
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
#endif
|
76
|
-
|
77
|
-
static ID value_to_id _((VALUE v));
|
78
|
-
static inline long num_to_long _((VALUE n));
|
73
|
+
static ID value_to_id(VALUE v);
|
74
|
+
static inline long num_to_long(VALUE n);
|
79
75
|
|
80
76
|
static ID
|
81
77
|
value_to_id(VALUE v)
|
@@ -99,8 +95,8 @@ num_to_long(VALUE n)
|
|
99
95
|
Parser Stack Interfaces
|
100
96
|
----------------------------------------------------------------------- */
|
101
97
|
|
102
|
-
static VALUE get_stack_tail
|
103
|
-
static void cut_stack_tail
|
98
|
+
static VALUE get_stack_tail(VALUE stack, long len);
|
99
|
+
static void cut_stack_tail(VALUE stack, long len);
|
104
100
|
|
105
101
|
static VALUE
|
106
102
|
get_stack_tail(VALUE stack, long len)
|
@@ -189,27 +185,27 @@ struct cparse_params {
|
|
189
185
|
Parser Main Routines
|
190
186
|
----------------------------------------------------------------------- */
|
191
187
|
|
192
|
-
static VALUE racc_cparse
|
193
|
-
static VALUE racc_yyparse
|
194
|
-
|
195
|
-
|
196
|
-
static void call_lexer
|
197
|
-
static VALUE lexer_i
|
198
|
-
|
199
|
-
static VALUE assert_array
|
200
|
-
static long assert_integer
|
201
|
-
static VALUE assert_hash
|
202
|
-
static VALUE initialize_params
|
203
|
-
|
204
|
-
static void cparse_params_mark
|
205
|
-
static size_t cparse_params_memsize
|
206
|
-
|
207
|
-
static void parse_main
|
208
|
-
|
209
|
-
static void extract_user_token
|
210
|
-
|
211
|
-
static void shift
|
212
|
-
static int reduce
|
188
|
+
static VALUE racc_cparse(VALUE parser, VALUE arg, VALUE sysdebug);
|
189
|
+
static VALUE racc_yyparse(VALUE parser, VALUE lexer, VALUE lexmid,
|
190
|
+
VALUE arg, VALUE sysdebug);
|
191
|
+
|
192
|
+
static void call_lexer(struct cparse_params *v);
|
193
|
+
static VALUE lexer_i(RB_BLOCK_CALL_FUNC_ARGLIST(block_args, data));
|
194
|
+
|
195
|
+
static VALUE assert_array(VALUE a);
|
196
|
+
static long assert_integer(VALUE n);
|
197
|
+
static VALUE assert_hash(VALUE h);
|
198
|
+
static VALUE initialize_params(VALUE vparams, VALUE parser, VALUE arg,
|
199
|
+
VALUE lexer, VALUE lexmid);
|
200
|
+
static void cparse_params_mark(void *ptr);
|
201
|
+
static size_t cparse_params_memsize(const void *ptr);
|
202
|
+
|
203
|
+
static void parse_main(struct cparse_params *v,
|
204
|
+
VALUE tok, VALUE val, int resume);
|
205
|
+
static void extract_user_token(struct cparse_params *v,
|
206
|
+
VALUE block_args, VALUE *tok, VALUE *val);
|
207
|
+
static void shift(struct cparse_params* v, long act, VALUE tok, VALUE val);
|
208
|
+
static int reduce(struct cparse_params* v, long act);
|
213
209
|
static rb_block_call_func reduce0;
|
214
210
|
|
215
211
|
#ifdef DEBUG
|
@@ -278,28 +274,11 @@ racc_yyparse(VALUE parser, VALUE lexer, VALUE lexmid, VALUE arg, VALUE sysdebug)
|
|
278
274
|
return v->retval;
|
279
275
|
}
|
280
276
|
|
281
|
-
#ifdef HAVE_RB_BLOCK_CALL
|
282
277
|
static void
|
283
278
|
call_lexer(struct cparse_params *v)
|
284
279
|
{
|
285
280
|
rb_block_call(v->lexer, v->lexmid, 0, NULL, lexer_i, v->value_v);
|
286
281
|
}
|
287
|
-
#else
|
288
|
-
static VALUE
|
289
|
-
lexer_iter(VALUE data)
|
290
|
-
{
|
291
|
-
struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
|
292
|
-
|
293
|
-
rb_funcall(v->lexer, v->lexmid, 0);
|
294
|
-
return Qnil;
|
295
|
-
}
|
296
|
-
|
297
|
-
static void
|
298
|
-
call_lexer(struct cparse_params *v)
|
299
|
-
{
|
300
|
-
rb_iterate(lexer_iter, v->value_v, lexer_i, v->value_v);
|
301
|
-
}
|
302
|
-
#endif
|
303
282
|
|
304
283
|
static VALUE
|
305
284
|
lexer_i(RB_BLOCK_CALL_FUNC_ARGLIST(block_args, data))
|
data/ext/racc/cparse/extconf.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
#
|
3
3
|
|
4
4
|
require 'mkmf'
|
5
|
+
require_relative '../../../lib/racc/info'
|
5
6
|
|
6
|
-
|
7
|
-
have_func('rb_ary_subseq')
|
8
|
-
|
7
|
+
$defs << "-D""RACC_INFO_VERSION=#{Racc::VERSION}"
|
9
8
|
create_makefile 'racc/cparse'
|
data/lib/racc/grammar.rb
CHANGED
@@ -27,6 +27,7 @@ module Racc
|
|
27
27
|
@rules = [] # :: [Rule]
|
28
28
|
@start = nil
|
29
29
|
@n_expected_srconflicts = nil
|
30
|
+
@error_on_expect_mismatch = nil
|
30
31
|
@prec_table = []
|
31
32
|
@prec_table_closed = false
|
32
33
|
@closed = false
|
@@ -36,6 +37,7 @@ module Racc
|
|
36
37
|
attr_reader :start
|
37
38
|
attr_reader :symboltable
|
38
39
|
attr_accessor :n_expected_srconflicts
|
40
|
+
attr_accessor :error_on_expect_mismatch
|
39
41
|
|
40
42
|
def [](x)
|
41
43
|
@rules[x]
|
@@ -787,6 +789,81 @@ module Racc
|
|
787
789
|
end
|
788
790
|
|
789
791
|
|
792
|
+
class OptionMark
|
793
|
+
def initialize(lineno)
|
794
|
+
@lineno = lineno
|
795
|
+
end
|
796
|
+
|
797
|
+
def name
|
798
|
+
'?'
|
799
|
+
end
|
800
|
+
|
801
|
+
alias inspect name
|
802
|
+
|
803
|
+
attr_reader :lineno
|
804
|
+
end
|
805
|
+
|
806
|
+
|
807
|
+
class ManyMark
|
808
|
+
def initialize(lineno)
|
809
|
+
@lineno = lineno
|
810
|
+
end
|
811
|
+
|
812
|
+
def name
|
813
|
+
'*'
|
814
|
+
end
|
815
|
+
|
816
|
+
alias inspect name
|
817
|
+
|
818
|
+
attr_reader :lineno
|
819
|
+
end
|
820
|
+
|
821
|
+
|
822
|
+
class Many1Mark
|
823
|
+
def initialize(lineno)
|
824
|
+
@lineno = lineno
|
825
|
+
end
|
826
|
+
|
827
|
+
def name
|
828
|
+
'+'
|
829
|
+
end
|
830
|
+
|
831
|
+
alias inspect name
|
832
|
+
|
833
|
+
attr_reader :lineno
|
834
|
+
end
|
835
|
+
|
836
|
+
|
837
|
+
class GroupStartMark
|
838
|
+
def initialize(lineno)
|
839
|
+
@lineno = lineno
|
840
|
+
end
|
841
|
+
|
842
|
+
def name
|
843
|
+
'('
|
844
|
+
end
|
845
|
+
|
846
|
+
alias inspect name
|
847
|
+
|
848
|
+
attr_reader :lineno
|
849
|
+
end
|
850
|
+
|
851
|
+
|
852
|
+
class GroupEndMark
|
853
|
+
def initialize(lineno)
|
854
|
+
@lineno = lineno
|
855
|
+
end
|
856
|
+
|
857
|
+
def name
|
858
|
+
')'
|
859
|
+
end
|
860
|
+
|
861
|
+
alias inspect name
|
862
|
+
|
863
|
+
attr_reader :lineno
|
864
|
+
end
|
865
|
+
|
866
|
+
|
790
867
|
class Prec
|
791
868
|
def initialize(symbol, lineno)
|
792
869
|
@symbol = symbol
|
@@ -993,10 +1070,6 @@ module Racc
|
|
993
1070
|
@to_s = '$end'
|
994
1071
|
@serialized = 'false'
|
995
1072
|
@string = false
|
996
|
-
when ErrorSymbolValue
|
997
|
-
@to_s = 'error'
|
998
|
-
@serialized = 'Object.new'
|
999
|
-
@string = false
|
1000
1073
|
else
|
1001
1074
|
raise ArgumentError, "unknown symbol value: #{value.class}"
|
1002
1075
|
end
|
@@ -76,6 +76,9 @@ module Racc
|
|
76
76
|
raise CompileError, "`expect' seen twice"
|
77
77
|
end
|
78
78
|
@grammar.n_expected_srconflicts = num
|
79
|
+
}\
|
80
|
+
| seq(:ERROR_ON_EXPECT_MISMATCH) {|*|
|
81
|
+
@grammar.error_on_expect_mismatch = true
|
79
82
|
}
|
80
83
|
|
81
84
|
g.convdef = seq(:symbol, :STRING) {|sym, code|
|
@@ -133,6 +136,21 @@ module Racc
|
|
133
136
|
| seq("|") {|*|
|
134
137
|
OrMark.new(@scanner.lineno)
|
135
138
|
}\
|
139
|
+
| seq("?") {|*|
|
140
|
+
OptionMark.new(@scanner.lineno)
|
141
|
+
}\
|
142
|
+
| seq("*") {|*|
|
143
|
+
ManyMark.new(@scanner.lineno)
|
144
|
+
}\
|
145
|
+
| seq("+") {|*|
|
146
|
+
Many1Mark.new(@scanner.lineno)
|
147
|
+
}\
|
148
|
+
| seq("(") {|*|
|
149
|
+
GroupStartMark.new(@scanner.lineno)
|
150
|
+
}\
|
151
|
+
| seq(")") {|*|
|
152
|
+
GroupEndMark.new(@scanner.lineno)
|
153
|
+
}\
|
136
154
|
| seq("=", :symbol) {|_, sym|
|
137
155
|
Prec.new(sym, @scanner.lineno)
|
138
156
|
}\
|
@@ -210,27 +228,114 @@ module Racc
|
|
210
228
|
end
|
211
229
|
|
212
230
|
def add_rule_block(list)
|
213
|
-
sprec = nil
|
214
231
|
target = list.shift
|
215
232
|
case target
|
216
|
-
when OrMark, UserAction, Prec
|
233
|
+
when OrMark, OptionMark, ManyMark, Many1Mark, GroupStartMark, GroupEndMark, UserAction, Prec
|
217
234
|
raise CompileError, "#{target.lineno}: unexpected symbol #{target.name}"
|
218
235
|
end
|
236
|
+
enum = list.each.with_index
|
237
|
+
_, sym, idx = _add_rule_block(target, enum)
|
238
|
+
if idx
|
239
|
+
# sym is Racc::GroupEndMark
|
240
|
+
raise "#{sym.lineno}: unexpected symbol ')' at pos=#{idx}"
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def _add_rule_block(target, enum)
|
245
|
+
rules = [] # [ [seqs, sprec], .. ]
|
219
246
|
curr = []
|
220
|
-
|
221
|
-
|
247
|
+
sprec = nil
|
248
|
+
while (sym, idx = enum.next rescue nil)
|
249
|
+
case sym
|
222
250
|
when OrMark
|
223
|
-
|
251
|
+
rules << [curr, sprec]
|
224
252
|
curr = []
|
225
253
|
sprec = nil
|
254
|
+
when OptionMark
|
255
|
+
curr << _add_option_rule(curr.pop)
|
256
|
+
when ManyMark
|
257
|
+
curr << _add_many_rule(curr.pop)
|
258
|
+
when Many1Mark
|
259
|
+
curr << _add_many1_rule(curr.pop)
|
260
|
+
when GroupStartMark
|
261
|
+
curr << _add_group_rule(enum)
|
262
|
+
when GroupEndMark
|
263
|
+
rules << [curr, sprec]
|
264
|
+
return rules, sym, idx
|
226
265
|
when Prec
|
227
266
|
raise CompileError, "'=<prec>' used twice in one rule" if sprec
|
228
|
-
sprec =
|
267
|
+
sprec = sym.symbol
|
229
268
|
else
|
230
|
-
curr.push
|
269
|
+
curr.push sym
|
231
270
|
end
|
232
271
|
end
|
233
|
-
|
272
|
+
rules << [curr, sprec]
|
273
|
+
rules.each do |syms, sprec|
|
274
|
+
add_rule target, syms, sprec
|
275
|
+
end
|
276
|
+
nil
|
277
|
+
end
|
278
|
+
|
279
|
+
|
280
|
+
def _add_option_rule(prev)
|
281
|
+
@option_rule_registry ||= {}
|
282
|
+
target = @option_rule_registry[prev.to_s]
|
283
|
+
return target if target
|
284
|
+
target = _gen_target_name("option", prev)
|
285
|
+
@option_rule_registry[prev.to_s] = target
|
286
|
+
act = UserAction.empty
|
287
|
+
@grammar.add Rule.new(target, [], act)
|
288
|
+
@grammar.add Rule.new(target, [prev], act)
|
289
|
+
target
|
290
|
+
end
|
291
|
+
|
292
|
+
def _add_many_rule(prev)
|
293
|
+
@many_rule_registry ||= {}
|
294
|
+
target = @many_rule_registry[prev.to_s]
|
295
|
+
return target if target
|
296
|
+
target = _gen_target_name("many", prev)
|
297
|
+
@many_rule_registry[prev.to_s] = target
|
298
|
+
src = SourceText.new("result = val[1] ? val[1].unshift(val[0]) : val", __FILE__, __LINE__)
|
299
|
+
act = UserAction.source_text(src)
|
300
|
+
@grammar.add Rule.new(target, [], act)
|
301
|
+
@grammar.add Rule.new(target, [prev, target], act)
|
302
|
+
target
|
303
|
+
end
|
304
|
+
|
305
|
+
def _add_many1_rule(prev)
|
306
|
+
@many1_rule_registry ||= {}
|
307
|
+
target = @many1_rule_registry[prev.to_s]
|
308
|
+
return target if target
|
309
|
+
target = _gen_target_name("many1", prev)
|
310
|
+
@many1_rule_registry[prev.to_s] = target
|
311
|
+
src = SourceText.new("result = val[1] ? val[1].unshift(val[0]) : val", __FILE__, __LINE__)
|
312
|
+
act = UserAction.source_text(src)
|
313
|
+
@grammar.add Rule.new(target, [prev], act)
|
314
|
+
@grammar.add Rule.new(target, [prev, target], act)
|
315
|
+
target
|
316
|
+
end
|
317
|
+
|
318
|
+
def _add_group_rule(enum)
|
319
|
+
target = @grammar.intern("-temp-group", true)
|
320
|
+
rules, _ = _add_rule_block(target, enum)
|
321
|
+
target_name = rules.map{|syms, sprec| syms.join("-")}.join("|")
|
322
|
+
@group_rule_registry ||= {}
|
323
|
+
unless target = @group_rule_registry[target_name]
|
324
|
+
target = @grammar.intern("-group@#{target_name}", true)
|
325
|
+
@group_rule_registry[target_name] = target
|
326
|
+
src = SourceText.new("result = val", __FILE__, __LINE__)
|
327
|
+
act = UserAction.source_text(src)
|
328
|
+
rules.each do |syms, sprec|
|
329
|
+
rule = Rule.new(target, syms, act)
|
330
|
+
rule.specified_prec = sprec
|
331
|
+
@grammar.add rule
|
332
|
+
end
|
333
|
+
end
|
334
|
+
target
|
335
|
+
end
|
336
|
+
|
337
|
+
def _gen_target_name(type, sym)
|
338
|
+
@grammar.intern("-#{type}@#{sym.value}", true)
|
234
339
|
end
|
235
340
|
|
236
341
|
def add_rule(target, list, sprec)
|
@@ -391,6 +496,7 @@ module Racc
|
|
391
496
|
'options' => :OPTION,
|
392
497
|
'start' => :START,
|
393
498
|
'expect' => :EXPECT,
|
499
|
+
'error_on_expect_mismatch' => :ERROR_ON_EXPECT_MISMATCH,
|
394
500
|
'class' => :CLASS,
|
395
501
|
'rule' => :RULE,
|
396
502
|
'end' => :END
|
data/lib/racc/info.rb
CHANGED
data/lib/racc/parser-text.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Racc
|
2
2
|
PARSER_TEXT = <<'__end_of_file__'
|
3
|
-
# frozen_string_literal: false
|
4
3
|
#--
|
5
4
|
# Copyright (c) 1999-2006 Minero Aoki
|
6
5
|
#
|
@@ -12,12 +11,18 @@ module Racc
|
|
12
11
|
# without restriction.
|
13
12
|
#++
|
14
13
|
|
15
|
-
|
14
|
+
unless $".find {|p| p.end_with?('/racc/info.rb')}
|
15
|
+
$".push "#{__dir__}/racc/info.rb"
|
16
|
+
|
17
|
+
module Racc
|
18
|
+
VERSION = '1.8.0'
|
19
|
+
Version = VERSION
|
20
|
+
Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
|
21
|
+
end
|
16
22
|
|
17
|
-
unless defined?(NotImplementedError)
|
18
|
-
NotImplementedError = NotImplementError # :nodoc:
|
19
23
|
end
|
20
24
|
|
25
|
+
|
21
26
|
module Racc
|
22
27
|
class ParseError < StandardError; end
|
23
28
|
end
|
@@ -55,10 +60,12 @@ end
|
|
55
60
|
# [-v, --verbose]
|
56
61
|
# verbose mode. create +filename+.output file, like yacc's y.output file.
|
57
62
|
# [-g, --debug]
|
58
|
-
# add debug code to parser class. To display
|
63
|
+
# add debug code to parser class. To display debugging information,
|
59
64
|
# use this '-g' option and set @yydebug true in parser class.
|
60
65
|
# [-E, --embedded]
|
61
66
|
# Output parser which doesn't need runtime files (racc/parser.rb).
|
67
|
+
# [-F, --frozen]
|
68
|
+
# Output parser which declares frozen_string_literals: true
|
62
69
|
# [-C, --check-only]
|
63
70
|
# Check syntax of racc grammar file and quit.
|
64
71
|
# [-S, --output-status]
|
@@ -262,11 +269,11 @@ module Racc
|
|
262
269
|
# def next_token
|
263
270
|
# @q.shift
|
264
271
|
# end
|
265
|
-
class_eval
|
272
|
+
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
266
273
|
def do_parse
|
267
274
|
#{Racc_Main_Parsing_Routine}(_racc_setup(), false)
|
268
275
|
end
|
269
|
-
|
276
|
+
RUBY
|
270
277
|
|
271
278
|
# The method to fetch next token.
|
272
279
|
# If you use #do_parse method, you must implement #next_token.
|
@@ -324,11 +331,11 @@ module Racc
|
|
324
331
|
#
|
325
332
|
# RECEIVER#METHOD_ID is a method to get next token.
|
326
333
|
# It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
|
327
|
-
class_eval
|
334
|
+
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
328
335
|
def yyparse(recv, mid)
|
329
336
|
#{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
|
330
337
|
end
|
331
|
-
|
338
|
+
RUBY
|
332
339
|
|
333
340
|
def _racc_yyparse_rb(recv, mid, arg, c_debug)
|
334
341
|
action_table, action_check, action_default, action_pointer,
|
@@ -537,7 +544,7 @@ module Racc
|
|
537
544
|
#
|
538
545
|
# If this method returns, parsers enter "error recovering mode".
|
539
546
|
def on_error(t, val, vstack)
|
540
|
-
raise ParseError, sprintf("
|
547
|
+
raise ParseError, sprintf("parse error on value %s (%s)",
|
541
548
|
val.inspect, token_to_str(t) || '?')
|
542
549
|
end
|
543
550
|
|
data/lib/racc/parser.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
#--
|
3
3
|
# Copyright (c) 1999-2006 Minero Aoki
|
4
4
|
#
|
@@ -12,10 +12,6 @@
|
|
12
12
|
|
13
13
|
require 'racc/info'
|
14
14
|
|
15
|
-
unless defined?(NotImplementedError)
|
16
|
-
NotImplementedError = NotImplementError # :nodoc:
|
17
|
-
end
|
18
|
-
|
19
15
|
module Racc
|
20
16
|
class ParseError < StandardError; end
|
21
17
|
end
|
@@ -53,10 +49,12 @@ end
|
|
53
49
|
# [-v, --verbose]
|
54
50
|
# verbose mode. create +filename+.output file, like yacc's y.output file.
|
55
51
|
# [-g, --debug]
|
56
|
-
# add debug code to parser class. To display
|
52
|
+
# add debug code to parser class. To display debugging information,
|
57
53
|
# use this '-g' option and set @yydebug true in parser class.
|
58
54
|
# [-E, --embedded]
|
59
55
|
# Output parser which doesn't need runtime files (racc/parser.rb).
|
56
|
+
# [-F, --frozen]
|
57
|
+
# Output parser which declares frozen_string_literals: true
|
60
58
|
# [-C, --check-only]
|
61
59
|
# Check syntax of racc grammar file and quit.
|
62
60
|
# [-S, --output-status]
|
@@ -260,11 +258,11 @@ module Racc
|
|
260
258
|
# def next_token
|
261
259
|
# @q.shift
|
262
260
|
# end
|
263
|
-
class_eval
|
261
|
+
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
264
262
|
def do_parse
|
265
263
|
#{Racc_Main_Parsing_Routine}(_racc_setup(), false)
|
266
264
|
end
|
267
|
-
|
265
|
+
RUBY
|
268
266
|
|
269
267
|
# The method to fetch next token.
|
270
268
|
# If you use #do_parse method, you must implement #next_token.
|
@@ -322,11 +320,11 @@ module Racc
|
|
322
320
|
#
|
323
321
|
# RECEIVER#METHOD_ID is a method to get next token.
|
324
322
|
# It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
|
325
|
-
class_eval
|
323
|
+
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
326
324
|
def yyparse(recv, mid)
|
327
325
|
#{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
|
328
326
|
end
|
329
|
-
|
327
|
+
RUBY
|
330
328
|
|
331
329
|
def _racc_yyparse_rb(recv, mid, arg, c_debug)
|
332
330
|
action_table, action_check, action_default, action_pointer,
|
@@ -535,7 +533,7 @@ module Racc
|
|
535
533
|
#
|
536
534
|
# If this method returns, parsers enter "error recovering mode".
|
537
535
|
def on_error(t, val, vstack)
|
538
|
-
raise ParseError, sprintf("
|
536
|
+
raise ParseError, sprintf("parse error on value %s (%s)",
|
539
537
|
val.inspect, token_to_str(t) || '?')
|
540
538
|
end
|
541
539
|
|
@@ -45,6 +45,7 @@ module Racc
|
|
45
45
|
bool_attr :convert_line
|
46
46
|
bool_attr :convert_line_all
|
47
47
|
bool_attr :embed_runtime
|
48
|
+
bool_attr :frozen_strings
|
48
49
|
bool_attr :make_executable
|
49
50
|
attr_accessor :interpreter
|
50
51
|
|
@@ -64,6 +65,7 @@ module Racc
|
|
64
65
|
self.convert_line = true
|
65
66
|
self.convert_line_all = false
|
66
67
|
self.embed_runtime = false
|
68
|
+
self.frozen_strings = false
|
67
69
|
self.make_executable = false
|
68
70
|
self.interpreter = nil
|
69
71
|
end
|
@@ -122,6 +124,7 @@ module Racc
|
|
122
124
|
end
|
123
125
|
|
124
126
|
def notice
|
127
|
+
line %q[# frozen_string_literal: true] if @params.frozen_strings?
|
125
128
|
line %q[#]
|
126
129
|
line %q[# DO NOT MODIFY!!!!]
|
127
130
|
line %Q[# This file is automatically generated by Racc #{Racc::Version}]
|
@@ -135,8 +138,8 @@ module Racc
|
|
135
138
|
|
136
139
|
def embed_library(src)
|
137
140
|
line %[###### #{src.filename} begin]
|
138
|
-
line %[unless $".
|
139
|
-
line %[$".push
|
141
|
+
line %[unless $".find {|p| p.end_with?('/#{src.filename}')}]
|
142
|
+
line %[$".push "\#{__dir__}/#{src.filename}"]
|
140
143
|
put src, @params.convert_line?
|
141
144
|
line %[end]
|
142
145
|
line %[###### #{src.filename} end]
|
@@ -310,8 +313,10 @@ module Racc
|
|
310
313
|
racc_reduce_n,
|
311
314
|
racc_use_result_var ]
|
312
315
|
End
|
316
|
+
line "Ractor.make_shareable(Racc_arg) if defined?(Ractor)"
|
313
317
|
line
|
314
318
|
string_list 'Racc_token_to_s_table', table.token_to_s_table
|
319
|
+
line "Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)"
|
315
320
|
line
|
316
321
|
line "Racc_debug_parser = #{table.debug_parser}"
|
317
322
|
line
|
data/lib/racc/state.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: racc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minero Aoki
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-05-20 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: |
|
15
15
|
Racc is a LALR(1) parser generator.
|
@@ -35,17 +35,14 @@ files:
|
|
35
35
|
- README.rdoc
|
36
36
|
- TODO
|
37
37
|
- bin/racc
|
38
|
-
- doc/en/NEWS.en.rdoc
|
39
38
|
- doc/en/grammar.en.rdoc
|
40
39
|
- doc/en/grammar2.en.rdoc
|
41
|
-
- doc/ja/NEWS.ja.rdoc
|
42
40
|
- doc/ja/command.ja.html
|
43
41
|
- doc/ja/debug.ja.rdoc
|
44
42
|
- doc/ja/grammar.ja.rdoc
|
45
43
|
- doc/ja/index.ja.html
|
46
44
|
- doc/ja/parser.ja.rdoc
|
47
45
|
- doc/ja/usage.ja.html
|
48
|
-
- ext/racc/MANIFEST
|
49
46
|
- ext/racc/cparse/cparse.c
|
50
47
|
- ext/racc/cparse/extconf.rb
|
51
48
|
- lib/racc.rb
|
@@ -86,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
83
|
- !ruby/object:Gem::Version
|
87
84
|
version: '0'
|
88
85
|
requirements: []
|
89
|
-
rubygems_version: 3.
|
86
|
+
rubygems_version: 3.5.0.dev
|
90
87
|
signing_key:
|
91
88
|
specification_version: 4
|
92
89
|
summary: Racc is a LALR(1) parser generator
|