lrama 0.5.5 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
data/lib/lrama/parser.rb CHANGED
@@ -1,293 +1,1797 @@
1
- require "lrama/report/duration"
2
- require "lrama/parser/token_scanner"
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by Racc 1.7.1
4
+ # from Racc grammar file "".
5
+ #
6
+
7
+ ###### racc/parser.rb begin
8
+ unless $".find {|p| p.end_with?('/racc/parser.rb')}
9
+ $".push "#{__dir__}/racc/parser.rb"
10
+ self.class.module_eval(<<'...end racc/parser.rb/module_eval...', 'racc/parser.rb', 1)
11
+ # frozen_string_literal: false
12
+ #--
13
+ # Copyright (c) 1999-2006 Minero Aoki
14
+ #
15
+ # This program is free software.
16
+ # You can distribute/modify this program under the same terms of ruby.
17
+ #
18
+ # As a special exception, when this code is copied by Racc
19
+ # into a Racc output file, you may use that output file
20
+ # without restriction.
21
+ #++
22
+
23
+ unless $".find {|p| p.end_with?('/racc/info.rb')}
24
+ $".push "#{__dir__}/racc/info.rb"
25
+ #--
26
+ #
27
+ #
28
+ #
29
+ # Copyright (c) 1999-2006 Minero Aoki
30
+ #
31
+ # This program is free software.
32
+ # You can distribute/modify this program under the same terms of ruby.
33
+ # see the file "COPYING".
34
+ #
35
+ #++
36
+
37
+ module Racc
38
+ VERSION = '1.7.1'
39
+ Version = VERSION
40
+ Copyright = 'Copyright (c) 1999-2006 Minero Aoki'
41
+ end
42
+
43
+ end
44
+
45
+
46
+ unless defined?(NotImplementedError)
47
+ NotImplementedError = NotImplementError # :nodoc:
48
+ end
49
+
50
+ module Racc
51
+ class ParseError < StandardError; end
52
+ end
53
+ unless defined?(::ParseError)
54
+ ParseError = Racc::ParseError # :nodoc:
55
+ end
56
+
57
+ # Racc is a LALR(1) parser generator.
58
+ # It is written in Ruby itself, and generates Ruby programs.
59
+ #
60
+ # == Command-line Reference
61
+ #
62
+ # racc [-o<var>filename</var>] [--output-file=<var>filename</var>]
63
+ # [-e<var>rubypath</var>] [--executable=<var>rubypath</var>]
64
+ # [-v] [--verbose]
65
+ # [-O<var>filename</var>] [--log-file=<var>filename</var>]
66
+ # [-g] [--debug]
67
+ # [-E] [--embedded]
68
+ # [-l] [--no-line-convert]
69
+ # [-c] [--line-convert-all]
70
+ # [-a] [--no-omit-actions]
71
+ # [-C] [--check-only]
72
+ # [-S] [--output-status]
73
+ # [--version] [--copyright] [--help] <var>grammarfile</var>
74
+ #
75
+ # [+grammarfile+]
76
+ # Racc grammar file. Any extension is permitted.
77
+ # [-o+outfile+, --output-file=+outfile+]
78
+ # A filename for output. default is <+filename+>.tab.rb
79
+ # [-O+filename+, --log-file=+filename+]
80
+ # Place logging output in file +filename+.
81
+ # Default log file name is <+filename+>.output.
82
+ # [-e+rubypath+, --executable=+rubypath+]
83
+ # output executable file(mode 755). where +path+ is the Ruby interpreter.
84
+ # [-v, --verbose]
85
+ # verbose mode. create +filename+.output file, like yacc's y.output file.
86
+ # [-g, --debug]
87
+ # add debug code to parser class. To display debuggin information,
88
+ # use this '-g' option and set @yydebug true in parser class.
89
+ # [-E, --embedded]
90
+ # Output parser which doesn't need runtime files (racc/parser.rb).
91
+ # [-C, --check-only]
92
+ # Check syntax of racc grammar file and quit.
93
+ # [-S, --output-status]
94
+ # Print messages time to time while compiling.
95
+ # [-l, --no-line-convert]
96
+ # turns off line number converting.
97
+ # [-c, --line-convert-all]
98
+ # Convert line number of actions, inner, header and footer.
99
+ # [-a, --no-omit-actions]
100
+ # Call all actions, even if an action is empty.
101
+ # [--version]
102
+ # print Racc version and quit.
103
+ # [--copyright]
104
+ # Print copyright and quit.
105
+ # [--help]
106
+ # Print usage and quit.
107
+ #
108
+ # == Generating Parser Using Racc
109
+ #
110
+ # To compile Racc grammar file, simply type:
111
+ #
112
+ # $ racc parse.y
113
+ #
114
+ # This creates Ruby script file "parse.tab.y". The -o option can change the output filename.
115
+ #
116
+ # == Writing A Racc Grammar File
117
+ #
118
+ # If you want your own parser, you have to write a grammar file.
119
+ # A grammar file contains the name of your parser class, grammar for the parser,
120
+ # user code, and anything else.
121
+ # When writing a grammar file, yacc's knowledge is helpful.
122
+ # If you have not used yacc before, Racc is not too difficult.
123
+ #
124
+ # Here's an example Racc grammar file.
125
+ #
126
+ # class Calcparser
127
+ # rule
128
+ # target: exp { print val[0] }
129
+ #
130
+ # exp: exp '+' exp
131
+ # | exp '*' exp
132
+ # | '(' exp ')'
133
+ # | NUMBER
134
+ # end
135
+ #
136
+ # Racc grammar files resemble yacc files.
137
+ # But (of course), this is Ruby code.
138
+ # yacc's $$ is the 'result', $0, $1... is
139
+ # an array called 'val', and $-1, $-2... is an array called '_values'.
140
+ #
141
+ # See the {Grammar File Reference}[rdoc-ref:lib/racc/rdoc/grammar.en.rdoc] for
142
+ # more information on grammar files.
143
+ #
144
+ # == Parser
145
+ #
146
+ # Then you must prepare the parse entry method. There are two types of
147
+ # parse methods in Racc, Racc::Parser#do_parse and Racc::Parser#yyparse
148
+ #
149
+ # Racc::Parser#do_parse is simple.
150
+ #
151
+ # It's yyparse() of yacc, and Racc::Parser#next_token is yylex().
152
+ # This method must returns an array like [TOKENSYMBOL, ITS_VALUE].
153
+ # EOF is [false, false].
154
+ # (TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default.
155
+ # If you want to change this, see the grammar reference.
156
+ #
157
+ # Racc::Parser#yyparse is little complicated, but useful.
158
+ # It does not use Racc::Parser#next_token, instead it gets tokens from any iterator.
159
+ #
160
+ # For example, <code>yyparse(obj, :scan)</code> causes
161
+ # calling +obj#scan+, and you can return tokens by yielding them from +obj#scan+.
162
+ #
163
+ # == Debugging
164
+ #
165
+ # When debugging, "-v" or/and the "-g" option is helpful.
166
+ #
167
+ # "-v" creates verbose log file (.output).
168
+ # "-g" creates a "Verbose Parser".
169
+ # Verbose Parser prints the internal status when parsing.
170
+ # But it's _not_ automatic.
171
+ # You must use -g option and set +@yydebug+ to +true+ in order to get output.
172
+ # -g option only creates the verbose parser.
173
+ #
174
+ # === Racc reported syntax error.
175
+ #
176
+ # Isn't there too many "end"?
177
+ # grammar of racc file is changed in v0.10.
178
+ #
179
+ # Racc does not use '%' mark, while yacc uses huge number of '%' marks..
180
+ #
181
+ # === Racc reported "XXXX conflicts".
182
+ #
183
+ # Try "racc -v xxxx.y".
184
+ # It causes producing racc's internal log file, xxxx.output.
185
+ #
186
+ # === Generated parsers does not work correctly
187
+ #
188
+ # Try "racc -g xxxx.y".
189
+ # This command let racc generate "debugging parser".
190
+ # Then set @yydebug=true in your parser.
191
+ # It produces a working log of your parser.
192
+ #
193
+ # == Re-distributing Racc runtime
194
+ #
195
+ # A parser, which is created by Racc, requires the Racc runtime module;
196
+ # racc/parser.rb.
197
+ #
198
+ # Ruby 1.8.x comes with Racc runtime module,
199
+ # you need NOT distribute Racc runtime files.
200
+ #
201
+ # If you want to include the Racc runtime module with your parser.
202
+ # This can be done by using '-E' option:
203
+ #
204
+ # $ racc -E -omyparser.rb myparser.y
205
+ #
206
+ # This command creates myparser.rb which `includes' Racc runtime.
207
+ # Only you must do is to distribute your parser file (myparser.rb).
208
+ #
209
+ # Note: parser.rb is ruby license, but your parser is not.
210
+ # Your own parser is completely yours.
211
+ module Racc
212
+
213
+ unless defined?(Racc_No_Extensions)
214
+ Racc_No_Extensions = false # :nodoc:
215
+ end
3
216
 
4
- module Lrama
5
- # Parser for parse.y, generates a grammar
6
217
  class Parser
7
- include Lrama::Report::Duration
8
218
 
9
- T = Lrama::Lexer::Token
219
+ Racc_Runtime_Version = ::Racc::VERSION
220
+ Racc_Runtime_Core_Version_R = ::Racc::VERSION
221
+
222
+ begin
223
+ if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
224
+ require 'jruby'
225
+ require 'racc/cparse-jruby.jar'
226
+ com.headius.racc.Cparse.new.load(JRuby.runtime, false)
227
+ else
228
+ require 'racc/cparse'
229
+ end
230
+
231
+ unless new.respond_to?(:_racc_do_parse_c, true)
232
+ raise LoadError, 'old cparse.so'
233
+ end
234
+ if Racc_No_Extensions
235
+ raise LoadError, 'selecting ruby version of racc runtime core'
236
+ end
237
+
238
+ Racc_Main_Parsing_Routine = :_racc_do_parse_c # :nodoc:
239
+ Racc_YY_Parse_Method = :_racc_yyparse_c # :nodoc:
240
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C # :nodoc:
241
+ Racc_Runtime_Type = 'c' # :nodoc:
242
+ rescue LoadError
243
+ Racc_Main_Parsing_Routine = :_racc_do_parse_rb
244
+ Racc_YY_Parse_Method = :_racc_yyparse_rb
245
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
246
+ Racc_Runtime_Type = 'ruby'
247
+ end
10
248
 
11
- def initialize(text)
12
- @text = text
249
+ def Parser.racc_runtime_type # :nodoc:
250
+ Racc_Runtime_Type
13
251
  end
14
252
 
15
- def parse
16
- report_duration(:parse) do
17
- lexer = Lexer.new(@text)
18
- grammar = Grammar.new
19
- process_prologue(grammar, lexer)
20
- parse_bison_declarations(TokenScanner.new(lexer.bison_declarations_tokens), grammar)
21
- parse_grammar_rules(TokenScanner.new(lexer.grammar_rules_tokens), grammar)
22
- process_epilogue(grammar, lexer)
23
- grammar.prepare
24
- grammar.compute_nullable
25
- grammar.compute_first_set
26
- grammar.validate!
27
-
28
- grammar
253
+ def _racc_setup
254
+ @yydebug = false unless self.class::Racc_debug_parser
255
+ @yydebug = false unless defined?(@yydebug)
256
+ if @yydebug
257
+ @racc_debug_out = $stderr unless defined?(@racc_debug_out)
258
+ @racc_debug_out ||= $stderr
29
259
  end
260
+ arg = self.class::Racc_arg
261
+ arg[13] = true if arg.size < 14
262
+ arg
30
263
  end
31
264
 
32
- private
265
+ def _racc_init_sysvars
266
+ @racc_state = [0]
267
+ @racc_tstack = []
268
+ @racc_vstack = []
33
269
 
34
- def process_prologue(grammar, lexer)
35
- grammar.prologue_first_lineno = lexer.prologue.first[1] if lexer.prologue.first
36
- grammar.prologue = lexer.prologue.map(&:first).join
270
+ @racc_t = nil
271
+ @racc_val = nil
272
+
273
+ @racc_read_next = true
274
+
275
+ @racc_user_yyerror = false
276
+ @racc_error_status = 0
277
+ end
278
+
279
+ # The entry point of the parser. This method is used with #next_token.
280
+ # If Racc wants to get token (and its value), calls next_token.
281
+ #
282
+ # Example:
283
+ # def parse
284
+ # @q = [[1,1],
285
+ # [2,2],
286
+ # [3,3],
287
+ # [false, '$']]
288
+ # do_parse
289
+ # end
290
+ #
291
+ # def next_token
292
+ # @q.shift
293
+ # end
294
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
295
+ def do_parse
296
+ #{Racc_Main_Parsing_Routine}(_racc_setup(), false)
37
297
  end
298
+ RUBY
38
299
 
39
- def process_epilogue(grammar, lexer)
40
- grammar.epilogue_first_lineno = lexer.epilogue.first[1] if lexer.epilogue.first
41
- grammar.epilogue = lexer.epilogue.map(&:first).join
300
+ # The method to fetch next token.
301
+ # If you use #do_parse method, you must implement #next_token.
302
+ #
303
+ # The format of return value is [TOKEN_SYMBOL, VALUE].
304
+ # +token-symbol+ is represented by Ruby's symbol by default, e.g. :IDENT
305
+ # for 'IDENT'. ";" (String) for ';'.
306
+ #
307
+ # The final symbol (End of file) must be false.
308
+ def next_token
309
+ raise NotImplementedError, "#{self.class}\#next_token is not defined"
42
310
  end
43
311
 
44
- def parse_bison_declarations(ts, grammar)
45
- precedence_number = 0
46
-
47
- while !ts.eots? do
48
- case ts.current_type
49
- when T::P_expect
50
- ts.next
51
- grammar.expect = ts.consume!(T::Number).s_value
52
- when T::P_define
53
- ts.next
54
- # Ignore
55
- ts.consume_multi(T::Ident)
56
- when T::P_printer
57
- lineno = ts.current_token.line
58
- ts.next
59
- code = ts.consume!(T::User_code)
60
- code = grammar.build_code(:printer, code)
61
- ident_or_tags = ts.consume_multi(T::Ident, T::Tag)
62
- grammar.add_printer(ident_or_tags: ident_or_tags, code: code, lineno: lineno)
63
- when T::P_error_token
64
- lineno = ts.current_token.line
65
- ts.next
66
- code = ts.consume!(T::User_code)
67
- code = grammar.build_code(:printer, code)
68
- ident_or_tags = ts.consume_multi(T::Ident, T::Tag)
69
- grammar.add_error_token(ident_or_tags: ident_or_tags, code: code, lineno: lineno)
70
- when T::P_lex_param
71
- ts.next
72
- code = ts.consume!(T::User_code)
73
- code = grammar.build_code(:lex_param, code)
74
- grammar.lex_param = code.token_code.s_value
75
- when T::P_parse_param
76
- ts.next
77
- code = ts.consume!(T::User_code)
78
- code = grammar.build_code(:parse_param, code)
79
- grammar.parse_param = code.token_code.s_value
80
- when T::P_initial_action
81
- ts.next
82
- code = ts.consume!(T::User_code)
83
- code = grammar.build_code(:initial_action, code)
84
- ts.consume(T::Semicolon)
85
- grammar.initial_action = code
86
- when T::P_union
87
- lineno = ts.current_token.line
88
- ts.next
89
- code = ts.consume!(T::User_code)
90
- code = grammar.build_code(:union, code)
91
- ts.consume(T::Semicolon)
92
- grammar.set_union(code, lineno)
93
- when T::P_token
94
- # %token tag? (ident number? string?)+
95
- #
96
- # * ident can be char, e.g. '\\', '\t', '\13'
97
- # * number is a token_id for term
98
- #
99
- # These are valid token declaration (from CRuby parse.y)
100
- #
101
- # %token END_OF_INPUT 0 "end-of-input"
102
- # %token <id> '\\' "backslash"
103
- # %token tSP "escaped space"
104
- # %token tUPLUS 132 "unary+"
105
- # %token tCOLON3 ":: at EXPR_BEG"
106
- # %token tSTRING_DBEG tSTRING_DVAR tLAMBEG tLABEL_END
107
- #
108
- #
109
- # See: https://www.gnu.org/software/bison/manual/html_node/Symbol-Decls.html
110
- ts.next
111
- opt_tag = ts.consume(T::Tag)
112
-
113
- while (id = ts.consume(T::Ident, T::Char)) do
114
- opt_number = ts.consume(T::Number)
115
- opt_string = ts.consume(T::String)
116
- # Can replace 0 (EOF)
117
- grammar.add_term(
118
- id: id,
119
- alias_name: opt_string && opt_string.s_value,
120
- token_id: opt_number && opt_number.s_value,
121
- tag: opt_tag,
122
- replace: true,
123
- )
312
+ def _racc_do_parse_rb(arg, in_debug)
313
+ action_table, action_check, action_default, action_pointer,
314
+ _, _, _, _,
315
+ _, _, token_table, * = arg
316
+
317
+ _racc_init_sysvars
318
+ tok = act = i = nil
319
+
320
+ catch(:racc_end_parse) {
321
+ while true
322
+ if i = action_pointer[@racc_state[-1]]
323
+ if @racc_read_next
324
+ if @racc_t != 0 # not EOF
325
+ tok, @racc_val = next_token()
326
+ unless tok # EOF
327
+ @racc_t = 0
328
+ else
329
+ @racc_t = (token_table[tok] or 1) # error token
330
+ end
331
+ racc_read_token(@racc_t, tok, @racc_val) if @yydebug
332
+ @racc_read_next = false
333
+ end
334
+ end
335
+ i += @racc_t
336
+ unless i >= 0 and
337
+ act = action_table[i] and
338
+ action_check[i] == @racc_state[-1]
339
+ act = action_default[@racc_state[-1]]
340
+ end
341
+ else
342
+ act = action_default[@racc_state[-1]]
124
343
  end
125
- when T::P_type
126
- # %type tag? (ident|char|string)+
127
- #
128
- # See: https://www.gnu.org/software/bison/manual/html_node/Symbol-Decls.html
129
- ts.next
130
- opt_tag = ts.consume(T::Tag)
131
-
132
- while (id = ts.consume(T::Ident, T::Char, T::String)) do
133
- grammar.add_type(
134
- id: id,
135
- tag: opt_tag
136
- )
344
+ while act = _racc_evalact(act, arg)
345
+ ;
137
346
  end
138
- when T::P_nonassoc
139
- # %nonassoc (ident|char|string)+
140
- ts.next
141
- while (id = ts.consume(T::Ident, T::Char, T::String)) do
142
- sym = grammar.add_term(id: id)
143
- grammar.add_nonassoc(sym, precedence_number)
347
+ end
348
+ }
349
+ end
350
+
351
+ # Another entry point for the parser.
352
+ # If you use this method, you must implement RECEIVER#METHOD_ID method.
353
+ #
354
+ # RECEIVER#METHOD_ID is a method to get next token.
355
+ # It must 'yield' the token, which format is [TOKEN-SYMBOL, VALUE].
356
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
357
+ def yyparse(recv, mid)
358
+ #{Racc_YY_Parse_Method}(recv, mid, _racc_setup(), false)
359
+ end
360
+ RUBY
361
+
362
+ def _racc_yyparse_rb(recv, mid, arg, c_debug)
363
+ action_table, action_check, action_default, action_pointer,
364
+ _, _, _, _,
365
+ _, _, token_table, * = arg
366
+
367
+ _racc_init_sysvars
368
+
369
+ catch(:racc_end_parse) {
370
+ until i = action_pointer[@racc_state[-1]]
371
+ while act = _racc_evalact(action_default[@racc_state[-1]], arg)
372
+ ;
144
373
  end
145
- precedence_number += 1
146
- when T::P_left
147
- # %left (ident|char|string)+
148
- ts.next
149
- while (id = ts.consume(T::Ident, T::Char, T::String)) do
150
- sym = grammar.add_term(id: id)
151
- grammar.add_left(sym, precedence_number)
374
+ end
375
+ recv.__send__(mid) do |tok, val|
376
+ unless tok
377
+ @racc_t = 0
378
+ else
379
+ @racc_t = (token_table[tok] or 1) # error token
152
380
  end
153
- precedence_number += 1
154
- when T::P_right
155
- # %right (ident|char|string)+
156
- ts.next
157
- while (id = ts.consume(T::Ident, T::Char, T::String)) do
158
- sym = grammar.add_term(id: id)
159
- grammar.add_right(sym, precedence_number)
381
+ @racc_val = val
382
+ @racc_read_next = false
383
+
384
+ i += @racc_t
385
+ unless i >= 0 and
386
+ act = action_table[i] and
387
+ action_check[i] == @racc_state[-1]
388
+ act = action_default[@racc_state[-1]]
160
389
  end
161
- precedence_number += 1
162
- when T::P_precedence
163
- # %precedence (ident|char|string)+
164
- ts.next
165
- while (id = ts.consume(T::Ident, T::Char, T::String)) do
166
- sym = grammar.add_term(id: id)
167
- grammar.add_precedence(sym, precedence_number)
390
+ while act = _racc_evalact(act, arg)
391
+ ;
392
+ end
393
+
394
+ while !(i = action_pointer[@racc_state[-1]]) ||
395
+ ! @racc_read_next ||
396
+ @racc_t == 0 # $
397
+ unless i and i += @racc_t and
398
+ i >= 0 and
399
+ act = action_table[i] and
400
+ action_check[i] == @racc_state[-1]
401
+ act = action_default[@racc_state[-1]]
402
+ end
403
+ while act = _racc_evalact(act, arg)
404
+ ;
405
+ end
168
406
  end
169
- precedence_number += 1
170
- when nil
171
- # end of input
172
- raise "Reach to end of input within declarations"
173
- else
174
- raise "Unexpected token: #{ts.current_token}"
175
407
  end
176
- end
408
+ }
177
409
  end
178
410
 
179
- def parse_grammar_rules(ts, grammar)
180
- while !ts.eots? do
181
- parse_grammar_rule(ts, grammar)
411
+ ###
412
+ ### common
413
+ ###
414
+
415
+ def _racc_evalact(act, arg)
416
+ action_table, action_check, _, action_pointer,
417
+ _, _, _, _,
418
+ _, _, _, shift_n,
419
+ reduce_n, * = arg
420
+ nerr = 0 # tmp
421
+
422
+ if act > 0 and act < shift_n
423
+ #
424
+ # shift
425
+ #
426
+ if @racc_error_status > 0
427
+ @racc_error_status -= 1 unless @racc_t <= 1 # error token or EOF
428
+ end
429
+ @racc_vstack.push @racc_val
430
+ @racc_state.push act
431
+ @racc_read_next = true
432
+ if @yydebug
433
+ @racc_tstack.push @racc_t
434
+ racc_shift @racc_t, @racc_tstack, @racc_vstack
435
+ end
436
+
437
+ elsif act < 0 and act > -reduce_n
438
+ #
439
+ # reduce
440
+ #
441
+ code = catch(:racc_jump) {
442
+ @racc_state.push _racc_do_reduce(arg, act)
443
+ false
444
+ }
445
+ if code
446
+ case code
447
+ when 1 # yyerror
448
+ @racc_user_yyerror = true # user_yyerror
449
+ return -reduce_n
450
+ when 2 # yyaccept
451
+ return shift_n
452
+ else
453
+ raise '[Racc Bug] unknown jump code'
454
+ end
455
+ end
456
+
457
+ elsif act == shift_n
458
+ #
459
+ # accept
460
+ #
461
+ racc_accept if @yydebug
462
+ throw :racc_end_parse, @racc_vstack[0]
463
+
464
+ elsif act == -reduce_n
465
+ #
466
+ # error
467
+ #
468
+ case @racc_error_status
469
+ when 0
470
+ unless arg[21] # user_yyerror
471
+ nerr += 1
472
+ on_error @racc_t, @racc_val, @racc_vstack
473
+ end
474
+ when 3
475
+ if @racc_t == 0 # is $
476
+ # We're at EOF, and another error occurred immediately after
477
+ # attempting auto-recovery
478
+ throw :racc_end_parse, nil
479
+ end
480
+ @racc_read_next = true
481
+ end
482
+ @racc_user_yyerror = false
483
+ @racc_error_status = 3
484
+ while true
485
+ if i = action_pointer[@racc_state[-1]]
486
+ i += 1 # error token
487
+ if i >= 0 and
488
+ (act = action_table[i]) and
489
+ action_check[i] == @racc_state[-1]
490
+ break
491
+ end
492
+ end
493
+ throw :racc_end_parse, nil if @racc_state.size <= 1
494
+ @racc_state.pop
495
+ @racc_vstack.pop
496
+ if @yydebug
497
+ @racc_tstack.pop
498
+ racc_e_pop @racc_state, @racc_tstack, @racc_vstack
499
+ end
500
+ end
501
+ return act
502
+
503
+ else
504
+ raise "[Racc Bug] unknown action #{act.inspect}"
182
505
  end
506
+
507
+ racc_next_state(@racc_state[-1], @racc_state) if @yydebug
508
+
509
+ nil
183
510
  end
184
511
 
185
- # TODO: Take care of %prec of rule.
186
- # If %prec exists, user code before %prec
187
- # is NOT an action. For example "{ code 3 }" is NOT an action.
188
- #
189
- # keyword_class { code 2 } tSTRING '!' keyword_end { code 3 } %prec "="
190
- def parse_grammar_rule(ts, grammar)
191
- # LHS
192
- lhs = ts.consume!(T::Ident_Colon) # class:
193
- lhs.type = T::Ident
194
- if named_ref = ts.consume(T::Named_Ref)
195
- lhs.alias = named_ref.s_value
512
+ def _racc_do_reduce(arg, act)
513
+ _, _, _, _,
514
+ goto_table, goto_check, goto_default, goto_pointer,
515
+ nt_base, reduce_table, _, _,
516
+ _, use_result, * = arg
517
+
518
+ state = @racc_state
519
+ vstack = @racc_vstack
520
+ tstack = @racc_tstack
521
+
522
+ i = act * -3
523
+ len = reduce_table[i]
524
+ reduce_to = reduce_table[i+1]
525
+ method_id = reduce_table[i+2]
526
+ void_array = []
527
+
528
+ tmp_t = tstack[-len, len] if @yydebug
529
+ tmp_v = vstack[-len, len]
530
+ tstack[-len, len] = void_array if @yydebug
531
+ vstack[-len, len] = void_array
532
+ state[-len, len] = void_array
533
+
534
+ # tstack must be updated AFTER method call
535
+ if use_result
536
+ vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
537
+ else
538
+ vstack.push __send__(method_id, tmp_v, vstack)
196
539
  end
540
+ tstack.push reduce_to
197
541
 
198
- rhs = parse_grammar_rule_rhs(ts, grammar, lhs)
199
-
200
- grammar.add_rule(lhs: lhs, rhs: rhs, lineno: rhs.first ? rhs.first.line : lhs.line)
201
-
202
- while true do
203
- case ts.current_type
204
- when T::Bar
205
- # |
206
- bar_lineno = ts.current_token.line
207
- ts.next
208
- rhs = parse_grammar_rule_rhs(ts, grammar, lhs)
209
- grammar.add_rule(lhs: lhs, rhs: rhs, lineno: rhs.first ? rhs.first.line : bar_lineno)
210
- when T::Semicolon
211
- # ;
212
- ts.next
213
- break
214
- when T::Ident_Colon
215
- # Next lhs can be here because ";" is optional.
216
- # Do not consume next token.
217
- break
218
- when nil
219
- # end of input can be here when ";" is omitted
220
- break
221
- else
222
- raise "Unexpected token: #{ts.current_token}"
542
+ racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
543
+
544
+ k1 = reduce_to - nt_base
545
+ if i = goto_pointer[k1]
546
+ i += state[-1]
547
+ if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
548
+ return curstate
223
549
  end
224
550
  end
551
+ goto_default[k1]
225
552
  end
226
553
 
227
- def parse_grammar_rule_rhs(ts, grammar, lhs)
228
- a = []
229
- prec_seen = false
230
- code_after_prec = false
231
-
232
- while true do
233
- # TODO: String can be here
234
- case ts.current_type
235
- when T::Ident
236
- # keyword_class
237
-
238
- raise "Ident after %prec" if prec_seen
239
- a << ts.current_token
240
- ts.next
241
- when T::Char
242
- # '!'
243
-
244
- raise "Char after %prec" if prec_seen
245
- a << ts.current_token
246
- ts.next
247
- when T::P_prec
248
- # %prec tPLUS
249
- #
250
- # See: https://www.gnu.org/software/bison/manual/html_node/Contextual-Precedence.html
251
-
252
- ts.next
253
- prec_seen = true
254
- precedence_id = ts.consume!(T::Ident, T::String, T::Char)
255
- precedence_sym = grammar.find_symbol_by_id!(precedence_id)
256
- a << precedence_sym
257
- when T::User_code
258
- # { code } in the middle of rhs
259
-
260
- if prec_seen
261
- raise "Multiple User_code after %prec" if code_after_prec
262
- code_after_prec = true
263
- end
554
+ # This method is called when a parse error is found.
555
+ #
556
+ # ERROR_TOKEN_ID is an internal ID of token which caused error.
557
+ # You can get string representation of this ID by calling
558
+ # #token_to_str.
559
+ #
560
+ # ERROR_VALUE is a value of error token.
561
+ #
562
+ # value_stack is a stack of symbol values.
563
+ # DO NOT MODIFY this object.
564
+ #
565
+ # This method raises ParseError by default.
566
+ #
567
+ # If this method returns, parsers enter "error recovering mode".
568
+ def on_error(t, val, vstack)
569
+ raise ParseError, sprintf("\nparse error on value %s (%s)",
570
+ val.inspect, token_to_str(t) || '?')
571
+ end
264
572
 
265
- code = ts.current_token
266
- code.numberize_references(lhs, a)
267
- grammar.build_references(code)
268
- a << code
269
- ts.next
270
- when T::Named_Ref
271
- ts.previous_token.alias = ts.current_token.s_value
272
- ts.next
273
- when T::Bar
274
- # |
275
- break
276
- when T::Semicolon
277
- # ;
278
- break
279
- when T::Ident_Colon
280
- # Next lhs can be here because ";" is optional.
281
- break
282
- when nil
283
- # end of input can be here when ";" is omitted
284
- break
285
- else
286
- raise "Unexpected token: #{ts.current_token}"
287
- end
573
+ # Enter error recovering mode.
574
+ # This method does not call #on_error.
575
+ def yyerror
576
+ throw :racc_jump, 1
577
+ end
578
+
579
+ # Exit parser.
580
+ # Return value is +Symbol_Value_Stack[0]+.
581
+ def yyaccept
582
+ throw :racc_jump, 2
583
+ end
584
+
585
+ # Leave error recovering mode.
586
+ def yyerrok
587
+ @racc_error_status = 0
588
+ end
589
+
590
+ # For debugging output
591
+ def racc_read_token(t, tok, val)
592
+ @racc_debug_out.print 'read '
593
+ @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
594
+ @racc_debug_out.puts val.inspect
595
+ @racc_debug_out.puts
596
+ end
597
+
598
+ def racc_shift(tok, tstack, vstack)
599
+ @racc_debug_out.puts "shift #{racc_token2str tok}"
600
+ racc_print_stacks tstack, vstack
601
+ @racc_debug_out.puts
602
+ end
603
+
604
+ def racc_reduce(toks, sim, tstack, vstack)
605
+ out = @racc_debug_out
606
+ out.print 'reduce '
607
+ if toks.empty?
608
+ out.print ' <none>'
609
+ else
610
+ toks.each {|t| out.print ' ', racc_token2str(t) }
611
+ end
612
+ out.puts " --> #{racc_token2str(sim)}"
613
+ racc_print_stacks tstack, vstack
614
+ @racc_debug_out.puts
615
+ end
616
+
617
+ def racc_accept
618
+ @racc_debug_out.puts 'accept'
619
+ @racc_debug_out.puts
620
+ end
621
+
622
+ def racc_e_pop(state, tstack, vstack)
623
+ @racc_debug_out.puts 'error recovering mode: pop token'
624
+ racc_print_states state
625
+ racc_print_stacks tstack, vstack
626
+ @racc_debug_out.puts
627
+ end
628
+
629
+ def racc_next_state(curstate, state)
630
+ @racc_debug_out.puts "goto #{curstate}"
631
+ racc_print_states state
632
+ @racc_debug_out.puts
633
+ end
634
+
635
+ def racc_print_stacks(t, v)
636
+ out = @racc_debug_out
637
+ out.print ' ['
638
+ t.each_index do |i|
639
+ out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
288
640
  end
641
+ out.puts ' ]'
642
+ end
643
+
644
+ def racc_print_states(s)
645
+ out = @racc_debug_out
646
+ out.print ' ['
647
+ s.each {|st| out.print ' ', st }
648
+ out.puts ' ]'
649
+ end
289
650
 
290
- return a
651
+ def racc_token2str(tok)
652
+ self.class::Racc_token_to_s_table[tok] or
653
+ raise "[Racc Bug] can't convert token #{tok} to string"
291
654
  end
655
+
656
+ # Convert internal ID of token symbol to the string.
657
+ def token_to_str(t)
658
+ self.class::Racc_token_to_s_table[t]
659
+ end
660
+
661
+ end
662
+
663
+ end
664
+
665
+ ...end racc/parser.rb/module_eval...
666
+ end
667
+ ###### racc/parser.rb end
668
+ module Lrama
669
+ class Parser < Racc::Parser
670
+
671
+ module_eval(<<'...end parser.y/module_eval...', 'parser.y', 387)
672
+
673
+ include Lrama::Report::Duration
674
+
675
+ def initialize(text)
676
+ @text = text
677
+ end
678
+
679
+ def parse
680
+ report_duration(:parse) do
681
+ @lexer = Lrama::Lexer.new(@text)
682
+ @grammar = Lrama::Grammar.new
683
+ @precedence_number = 0
684
+ do_parse
685
+ @grammar.extract_references
686
+ @grammar.prepare
687
+ @grammar.compute_nullable
688
+ @grammar.compute_first_set
689
+ @grammar.validate!
690
+ @grammar
691
+ end
692
+ end
693
+
694
+ def next_token
695
+ @lexer.next_token
696
+ end
697
+
698
+ def on_error(error_token_id, error_value, value_stack)
699
+ raise ParseError, sprintf("\n%d:%d: parse error on value %s (%s)",
700
+ @lexer.line, @lexer.column, error_value.inspect, token_to_str(error_token_id) || '?')
701
+ end
702
+ ...end parser.y/module_eval...
703
+ ##### State transition tables begin ###
704
+
705
+ racc_action_table = [
706
+ 77, 6, 41, 42, 7, 83, 65, 56, 41, 42,
707
+ 68, 41, 42, 3, 134, 8, 20, 22, 23, 24,
708
+ 25, 26, 27, 28, 29, 30, 65, 82, 41, 42,
709
+ 65, 132, 135, 32, 38, 84, 41, 42, 134, 68,
710
+ 41, 42, 65, 68, 41, 42, 131, 61, 41, 42,
711
+ 39, 9, 41, 42, 44, 14, 135, 12, 65, 13,
712
+ 15, 16, 17, 18, 41, 42, 19, 20, 22, 23,
713
+ 24, 25, 26, 27, 28, 29, 30, 65, 46, 65,
714
+ 41, 42, 65, 46, 65, 41, 42, 65, 41, 42,
715
+ 65, 41, 42, 65, 41, 42, 65, 41, 42, 41,
716
+ 42, 41, 42, 65, 41, 42, 41, 42, 153, 41,
717
+ 42, 153, 41, 42, 153, 41, 42, 153, 41, 42,
718
+ 65, 68, 41, 42, 153, 41, 42, 20, 22, 23,
719
+ 24, 25, 26, 27, 28, 29, 30, 41, 42, 41,
720
+ 42, 153, 41, 42, 46, 38, 41, 42, 41, 42,
721
+ 41, 42, 41, 42, 41, 42, 49, 50, 51, 52,
722
+ 53, 74, 78, 80, 85, 85, 85, 92, 96, 97,
723
+ 105, 106, 108, 109, 110, 111, 112, 113, 116, 118,
724
+ 119, 122, 123, 124, 138, 139, 140, 141, 142, 143,
725
+ 122, 80, 148, 149, 156, 160, 161, 80, 80 ]
726
+
727
+ racc_action_check = [
728
+ 33, 2, 13, 13, 2, 40, 121, 25, 25, 25,
729
+ 27, 27, 27, 1, 121, 3, 33, 33, 33, 33,
730
+ 33, 33, 33, 33, 33, 33, 26, 40, 121, 121,
731
+ 144, 120, 121, 7, 33, 40, 55, 55, 144, 28,
732
+ 28, 28, 60, 29, 29, 29, 120, 26, 26, 26,
733
+ 12, 4, 144, 144, 14, 4, 144, 4, 61, 4,
734
+ 4, 4, 4, 4, 60, 60, 4, 4, 4, 4,
735
+ 4, 4, 4, 4, 4, 4, 4, 97, 15, 99,
736
+ 61, 61, 117, 16, 135, 56, 56, 141, 66, 66,
737
+ 142, 67, 67, 143, 68, 68, 150, 71, 71, 97,
738
+ 97, 99, 99, 154, 117, 117, 135, 135, 141, 141,
739
+ 141, 142, 142, 142, 143, 143, 143, 150, 150, 150,
740
+ 155, 30, 30, 30, 154, 154, 154, 9, 9, 9,
741
+ 9, 9, 9, 9, 9, 9, 9, 72, 72, 73,
742
+ 73, 155, 155, 155, 17, 9, 92, 92, 94, 94,
743
+ 100, 100, 102, 102, 114, 114, 18, 20, 22, 23,
744
+ 24, 31, 36, 37, 45, 47, 48, 54, 58, 59,
745
+ 79, 80, 86, 87, 88, 89, 90, 91, 95, 103,
746
+ 104, 105, 106, 107, 125, 126, 127, 128, 129, 130,
747
+ 131, 133, 136, 137, 146, 157, 159, 160, 161 ]
748
+
749
+ racc_action_pointer = [
750
+ nil, 13, -2, 15, 49, nil, nil, 26, nil, 109,
751
+ nil, nil, 41, -27, 47, 63, 68, 129, 141, nil,
752
+ 142, nil, 143, 144, 145, -21, 19, -18, 11, 15,
753
+ 93, 157, nil, -2, nil, nil, 145, 129, nil, nil,
754
+ -2, nil, nil, nil, nil, 149, nil, 150, 151, nil,
755
+ nil, nil, nil, nil, 139, 7, 56, nil, 159, 141,
756
+ 35, 51, nil, nil, nil, nil, 59, 62, 65, nil,
757
+ nil, 68, 108, 110, nil, nil, nil, nil, nil, 139,
758
+ 142, nil, nil, nil, nil, nil, 168, 169, 170, 171,
759
+ 172, 173, 117, nil, 119, 171, nil, 70, nil, 72,
760
+ 121, nil, 123, 174, 176, 166, 147, 179, nil, nil,
761
+ nil, nil, nil, nil, 125, nil, nil, 75, nil, nil,
762
+ 14, -1, nil, nil, nil, 168, 169, 170, 171, 172,
763
+ 173, 175, nil, 157, nil, 77, 188, 177, nil, nil,
764
+ nil, 80, 83, 86, 23, nil, 190, nil, nil, nil,
765
+ 89, nil, nil, nil, 96, 113, nil, 179, nil, 180,
766
+ 163, 164, nil, nil ]
767
+
768
+ racc_action_default = [
769
+ -2, -104, -8, -104, -104, -3, -4, -104, 164, -104,
770
+ -9, -10, -104, -104, -104, -104, -104, -104, -104, -20,
771
+ -104, -24, -104, -104, -104, -104, -104, -104, -104, -104,
772
+ -104, -104, -7, -91, -71, -73, -104, -88, -90, -11,
773
+ -95, -69, -70, -94, -13, -14, -60, -15, -16, -17,
774
+ -21, -25, -28, -31, -34, -40, -104, -43, -46, -35,
775
+ -50, -104, -53, -55, -56, -103, -36, -63, -104, -66,
776
+ -68, -37, -38, -39, -5, -1, -72, -92, -74, -104,
777
+ -104, -12, -96, -97, -98, -57, -104, -104, -104, -104,
778
+ -104, -104, -104, -44, -41, -48, -47, -104, -54, -51,
779
+ -65, -67, -64, -104, -104, -79, -104, -104, -61, -18,
780
+ -22, -26, -29, -32, -42, -45, -49, -52, -6, -93,
781
+ -75, -76, -84, -89, -58, -104, -104, -104, -104, -104,
782
+ -104, -79, -78, -88, -81, -104, -104, -104, -62, -19,
783
+ -23, -104, -104, -104, -77, -80, -104, -87, -85, -59,
784
+ -27, -99, -101, -102, -30, -33, -82, -104, -100, -104,
785
+ -88, -88, -86, -83 ]
786
+
787
+ racc_goto_table = [
788
+ 79, 43, 62, 60, 55, 121, 93, 101, 34, 66,
789
+ 71, 72, 73, 58, 1, 70, 70, 70, 70, 100,
790
+ 2, 102, 4, 158, 100, 100, 100, 158, 158, 33,
791
+ 75, 144, 76, 5, 31, 94, 98, 62, 99, 103,
792
+ 101, 10, 101, 58, 58, 93, 45, 47, 48, 150,
793
+ 154, 155, 11, 40, 70, 70, 70, 81, 87, 70,
794
+ 70, 70, 126, 88, 127, 93, 89, 128, 90, 129,
795
+ 91, 114, 130, 62, 117, 98, 54, 59, 95, 115,
796
+ 58, 107, 58, 137, 86, 125, 120, 146, 70, 159,
797
+ 70, 136, 157, 98, 104, nil, 145, 133, nil, nil,
798
+ nil, nil, 58, nil, nil, nil, nil, nil, nil, nil,
799
+ nil, 147, nil, nil, nil, nil, nil, nil, nil, nil,
800
+ 133, nil, nil, 162, 163 ]
801
+
802
+ racc_goto_check = [
803
+ 46, 31, 35, 34, 29, 48, 30, 42, 43, 28,
804
+ 28, 28, 28, 31, 1, 31, 31, 31, 31, 41,
805
+ 2, 41, 3, 54, 41, 41, 41, 54, 54, 4,
806
+ 5, 48, 43, 6, 7, 29, 35, 35, 34, 8,
807
+ 42, 9, 42, 31, 31, 30, 13, 13, 13, 17,
808
+ 17, 17, 10, 11, 31, 31, 31, 12, 14, 31,
809
+ 31, 31, 15, 18, 19, 30, 20, 21, 22, 23,
810
+ 24, 29, 25, 35, 34, 35, 26, 27, 32, 33,
811
+ 31, 37, 31, 38, 39, 40, 47, 49, 31, 50,
812
+ 31, 51, 52, 35, 53, nil, 46, 35, nil, nil,
813
+ nil, nil, 31, nil, nil, nil, nil, nil, nil, nil,
814
+ nil, 35, nil, nil, nil, nil, nil, nil, nil, nil,
815
+ 35, nil, nil, 46, 46 ]
816
+
817
+ racc_goto_pointer = [
818
+ nil, 14, 20, 20, 20, -3, 31, 28, -35, 37,
819
+ 48, 40, 17, 31, 9, -47, nil, -92, 13, -46,
820
+ 15, -44, 16, -43, 17, -41, 51, 51, -18, -21,
821
+ -49, -12, 20, -16, -23, -24, nil, -4, -41, 38,
822
+ -23, -47, -60, -1, nil, nil, -37, -19, -100, -47,
823
+ -67, -31, -56, 17, -127 ]
824
+
825
+ racc_goto_default = [
826
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
827
+ 36, nil, nil, nil, nil, nil, 21, nil, nil, nil,
828
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
829
+ 57, 63, nil, nil, nil, 152, 64, nil, nil, nil,
830
+ nil, 67, 69, nil, 35, 37, nil, nil, nil, nil,
831
+ nil, nil, nil, nil, 151 ]
832
+
833
+ racc_reduce_table = [
834
+ 0, 0, :racc_error,
835
+ 5, 39, :_reduce_none,
836
+ 0, 40, :_reduce_none,
837
+ 2, 40, :_reduce_none,
838
+ 0, 45, :_reduce_4,
839
+ 0, 46, :_reduce_5,
840
+ 5, 44, :_reduce_6,
841
+ 2, 44, :_reduce_none,
842
+ 0, 41, :_reduce_8,
843
+ 2, 41, :_reduce_none,
844
+ 1, 47, :_reduce_none,
845
+ 2, 47, :_reduce_11,
846
+ 3, 47, :_reduce_none,
847
+ 2, 47, :_reduce_none,
848
+ 2, 47, :_reduce_none,
849
+ 2, 47, :_reduce_15,
850
+ 2, 47, :_reduce_16,
851
+ 0, 52, :_reduce_17,
852
+ 0, 53, :_reduce_18,
853
+ 6, 47, :_reduce_19,
854
+ 1, 47, :_reduce_none,
855
+ 0, 56, :_reduce_21,
856
+ 0, 57, :_reduce_22,
857
+ 6, 48, :_reduce_23,
858
+ 1, 48, :_reduce_none,
859
+ 0, 58, :_reduce_25,
860
+ 0, 59, :_reduce_26,
861
+ 7, 48, :_reduce_none,
862
+ 0, 60, :_reduce_28,
863
+ 0, 61, :_reduce_29,
864
+ 7, 48, :_reduce_30,
865
+ 0, 62, :_reduce_31,
866
+ 0, 63, :_reduce_32,
867
+ 7, 48, :_reduce_33,
868
+ 2, 54, :_reduce_none,
869
+ 2, 54, :_reduce_35,
870
+ 2, 54, :_reduce_36,
871
+ 2, 54, :_reduce_37,
872
+ 2, 54, :_reduce_38,
873
+ 2, 54, :_reduce_39,
874
+ 1, 64, :_reduce_40,
875
+ 2, 64, :_reduce_41,
876
+ 3, 64, :_reduce_42,
877
+ 1, 67, :_reduce_43,
878
+ 2, 67, :_reduce_44,
879
+ 3, 68, :_reduce_45,
880
+ 0, 70, :_reduce_none,
881
+ 1, 70, :_reduce_none,
882
+ 0, 71, :_reduce_none,
883
+ 1, 71, :_reduce_none,
884
+ 1, 65, :_reduce_50,
885
+ 2, 65, :_reduce_51,
886
+ 3, 65, :_reduce_52,
887
+ 1, 72, :_reduce_53,
888
+ 2, 72, :_reduce_54,
889
+ 1, 73, :_reduce_none,
890
+ 1, 73, :_reduce_none,
891
+ 0, 75, :_reduce_57,
892
+ 0, 76, :_reduce_58,
893
+ 6, 51, :_reduce_59,
894
+ 0, 77, :_reduce_60,
895
+ 0, 78, :_reduce_61,
896
+ 5, 51, :_reduce_62,
897
+ 1, 66, :_reduce_63,
898
+ 2, 66, :_reduce_64,
899
+ 2, 66, :_reduce_65,
900
+ 1, 79, :_reduce_66,
901
+ 2, 79, :_reduce_67,
902
+ 1, 80, :_reduce_none,
903
+ 1, 69, :_reduce_69,
904
+ 1, 69, :_reduce_70,
905
+ 1, 42, :_reduce_none,
906
+ 2, 42, :_reduce_none,
907
+ 1, 81, :_reduce_none,
908
+ 2, 81, :_reduce_none,
909
+ 4, 82, :_reduce_75,
910
+ 1, 85, :_reduce_76,
911
+ 3, 85, :_reduce_77,
912
+ 2, 85, :_reduce_none,
913
+ 0, 86, :_reduce_79,
914
+ 3, 86, :_reduce_80,
915
+ 0, 87, :_reduce_81,
916
+ 0, 88, :_reduce_82,
917
+ 7, 86, :_reduce_83,
918
+ 0, 89, :_reduce_84,
919
+ 0, 90, :_reduce_85,
920
+ 6, 86, :_reduce_86,
921
+ 3, 86, :_reduce_87,
922
+ 0, 84, :_reduce_none,
923
+ 3, 84, :_reduce_89,
924
+ 1, 83, :_reduce_none,
925
+ 0, 43, :_reduce_none,
926
+ 0, 91, :_reduce_92,
927
+ 3, 43, :_reduce_93,
928
+ 1, 49, :_reduce_none,
929
+ 0, 50, :_reduce_none,
930
+ 1, 50, :_reduce_none,
931
+ 1, 50, :_reduce_none,
932
+ 1, 50, :_reduce_none,
933
+ 1, 55, :_reduce_99,
934
+ 2, 55, :_reduce_100,
935
+ 1, 92, :_reduce_none,
936
+ 1, 92, :_reduce_none,
937
+ 1, 74, :_reduce_103 ]
938
+
939
+ racc_reduce_n = 104
940
+
941
+ racc_shift_n = 164
942
+
943
+ racc_token_table = {
944
+ false => 0,
945
+ :error => 1,
946
+ "%%" => 2,
947
+ "%{" => 3,
948
+ :C_DECLARATION => 4,
949
+ "%}" => 5,
950
+ "%require" => 6,
951
+ :STRING => 7,
952
+ "%expect" => 8,
953
+ :INTEGER => 9,
954
+ "%define" => 10,
955
+ "%param" => 11,
956
+ "%lex-param" => 12,
957
+ "%parse-param" => 13,
958
+ "%initial-action" => 14,
959
+ "{" => 15,
960
+ "}" => 16,
961
+ ";" => 17,
962
+ "%union" => 18,
963
+ "%destructor" => 19,
964
+ "%printer" => 20,
965
+ "%error-token" => 21,
966
+ "%token" => 22,
967
+ "%type" => 23,
968
+ "%left" => 24,
969
+ "%right" => 25,
970
+ "%precedence" => 26,
971
+ "%nonassoc" => 27,
972
+ :TAG => 28,
973
+ :IDENTIFIER => 29,
974
+ :CHARACTER => 30,
975
+ ":" => 31,
976
+ "|" => 32,
977
+ "%prec" => 33,
978
+ "[" => 34,
979
+ "]" => 35,
980
+ :IDENT_COLON => 36,
981
+ "{...}" => 37 }
982
+
983
+ racc_nt_base = 38
984
+
985
+ racc_use_result_var = true
986
+
987
+ Racc_arg = [
988
+ racc_action_table,
989
+ racc_action_check,
990
+ racc_action_default,
991
+ racc_action_pointer,
992
+ racc_goto_table,
993
+ racc_goto_check,
994
+ racc_goto_default,
995
+ racc_goto_pointer,
996
+ racc_nt_base,
997
+ racc_reduce_table,
998
+ racc_token_table,
999
+ racc_shift_n,
1000
+ racc_reduce_n,
1001
+ racc_use_result_var ]
1002
+ Ractor.make_shareable(Racc_arg) if defined?(Ractor)
1003
+
1004
+ Racc_token_to_s_table = [
1005
+ "$end",
1006
+ "error",
1007
+ "\"%%\"",
1008
+ "\"%{\"",
1009
+ "C_DECLARATION",
1010
+ "\"%}\"",
1011
+ "\"%require\"",
1012
+ "STRING",
1013
+ "\"%expect\"",
1014
+ "INTEGER",
1015
+ "\"%define\"",
1016
+ "\"%param\"",
1017
+ "\"%lex-param\"",
1018
+ "\"%parse-param\"",
1019
+ "\"%initial-action\"",
1020
+ "\"{\"",
1021
+ "\"}\"",
1022
+ "\";\"",
1023
+ "\"%union\"",
1024
+ "\"%destructor\"",
1025
+ "\"%printer\"",
1026
+ "\"%error-token\"",
1027
+ "\"%token\"",
1028
+ "\"%type\"",
1029
+ "\"%left\"",
1030
+ "\"%right\"",
1031
+ "\"%precedence\"",
1032
+ "\"%nonassoc\"",
1033
+ "TAG",
1034
+ "IDENTIFIER",
1035
+ "CHARACTER",
1036
+ "\":\"",
1037
+ "\"|\"",
1038
+ "\"%prec\"",
1039
+ "\"[\"",
1040
+ "\"]\"",
1041
+ "IDENT_COLON",
1042
+ "\"{...}\"",
1043
+ "$start",
1044
+ "input",
1045
+ "prologue_declarations",
1046
+ "bison_declarations",
1047
+ "grammar",
1048
+ "epilogue_opt",
1049
+ "prologue_declaration",
1050
+ "@1",
1051
+ "@2",
1052
+ "bison_declaration",
1053
+ "grammar_declaration",
1054
+ "variable",
1055
+ "value",
1056
+ "params",
1057
+ "@3",
1058
+ "@4",
1059
+ "symbol_declaration",
1060
+ "generic_symlist",
1061
+ "@5",
1062
+ "@6",
1063
+ "@7",
1064
+ "@8",
1065
+ "@9",
1066
+ "@10",
1067
+ "@11",
1068
+ "@12",
1069
+ "token_declarations",
1070
+ "symbol_declarations",
1071
+ "token_declarations_for_precedence",
1072
+ "token_declaration_list",
1073
+ "token_declaration",
1074
+ "id",
1075
+ "int_opt",
1076
+ "alias",
1077
+ "symbol_declaration_list",
1078
+ "symbol",
1079
+ "string_as_id",
1080
+ "@13",
1081
+ "@14",
1082
+ "@15",
1083
+ "@16",
1084
+ "token_declaration_list_for_precedence",
1085
+ "token_declaration_for_precedence",
1086
+ "rules_or_grammar_declaration",
1087
+ "rules",
1088
+ "id_colon",
1089
+ "named_ref_opt",
1090
+ "rhs_list",
1091
+ "rhs",
1092
+ "@17",
1093
+ "@18",
1094
+ "@19",
1095
+ "@20",
1096
+ "@21",
1097
+ "generic_symlist_item" ]
1098
+ Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
1099
+
1100
+ Racc_debug_parser = false
1101
+
1102
+ ##### State transition tables end #####
1103
+
1104
+ # reduce 0 omitted
1105
+
1106
+ # reduce 1 omitted
1107
+
1108
+ # reduce 2 omitted
1109
+
1110
+ # reduce 3 omitted
1111
+
1112
+ module_eval(<<'.,.,', 'parser.y', 9)
1113
+ def _reduce_4(val, _values, result)
1114
+ @lexer.status = :c_declaration
1115
+ @lexer.end_symbol = '%}'
1116
+ @grammar.prologue_first_lineno = @lexer.line
1117
+
1118
+ result
1119
+ end
1120
+ .,.,
1121
+
1122
+ module_eval(<<'.,.,', 'parser.y', 15)
1123
+ def _reduce_5(val, _values, result)
1124
+ @lexer.status = :initial
1125
+ @lexer.end_symbol = nil
1126
+
1127
+ result
1128
+ end
1129
+ .,.,
1130
+
1131
+ module_eval(<<'.,.,', 'parser.y', 20)
1132
+ def _reduce_6(val, _values, result)
1133
+ @grammar.prologue = val[2].s_value
1134
+
1135
+ result
1136
+ end
1137
+ .,.,
1138
+
1139
+ # reduce 7 omitted
1140
+
1141
+ module_eval(<<'.,.,', 'parser.y', 24)
1142
+ def _reduce_8(val, _values, result)
1143
+ result = ""
1144
+ result
1145
+ end
1146
+ .,.,
1147
+
1148
+ # reduce 9 omitted
1149
+
1150
+ # reduce 10 omitted
1151
+
1152
+ module_eval(<<'.,.,', 'parser.y', 28)
1153
+ def _reduce_11(val, _values, result)
1154
+ @grammar.expect = val[1]
1155
+ result
1156
+ end
1157
+ .,.,
1158
+
1159
+ # reduce 12 omitted
1160
+
1161
+ # reduce 13 omitted
1162
+
1163
+ # reduce 14 omitted
1164
+
1165
+ module_eval(<<'.,.,', 'parser.y', 34)
1166
+ def _reduce_15(val, _values, result)
1167
+ val[1].each {|token|
1168
+ token.references = []
1169
+ @grammar.lex_param = @grammar.build_code(:lex_param, token).token_code.s_value
1170
+ }
1171
+
1172
+ result
1173
+ end
1174
+ .,.,
1175
+
1176
+ module_eval(<<'.,.,', 'parser.y', 41)
1177
+ def _reduce_16(val, _values, result)
1178
+ val[1].each {|token|
1179
+ token.references = []
1180
+ @grammar.parse_param = @grammar.build_code(:parse_param, token).token_code.s_value
1181
+ }
1182
+
1183
+ result
1184
+ end
1185
+ .,.,
1186
+
1187
+ module_eval(<<'.,.,', 'parser.y', 48)
1188
+ def _reduce_17(val, _values, result)
1189
+ @lexer.status = :c_declaration
1190
+ @lexer.end_symbol = '}'
1191
+
1192
+ result
1193
+ end
1194
+ .,.,
1195
+
1196
+ module_eval(<<'.,.,', 'parser.y', 53)
1197
+ def _reduce_18(val, _values, result)
1198
+ @lexer.status = :initial
1199
+ @lexer.end_symbol = nil
1200
+
1201
+ result
1202
+ end
1203
+ .,.,
1204
+
1205
+ module_eval(<<'.,.,', 'parser.y', 58)
1206
+ def _reduce_19(val, _values, result)
1207
+ @grammar.initial_action = @grammar.build_code(:initial_action, val[3])
1208
+
1209
+ result
1210
+ end
1211
+ .,.,
1212
+
1213
+ # reduce 20 omitted
1214
+
1215
+ module_eval(<<'.,.,', 'parser.y', 64)
1216
+ def _reduce_21(val, _values, result)
1217
+ @lexer.status = :c_declaration
1218
+ @lexer.end_symbol = '}'
1219
+
1220
+ result
1221
+ end
1222
+ .,.,
1223
+
1224
+ module_eval(<<'.,.,', 'parser.y', 69)
1225
+ def _reduce_22(val, _values, result)
1226
+ @lexer.status = :initial
1227
+ @lexer.end_symbol = nil
1228
+
1229
+ result
292
1230
  end
1231
+ .,.,
1232
+
1233
+ module_eval(<<'.,.,', 'parser.y', 74)
1234
+ def _reduce_23(val, _values, result)
1235
+ @grammar.set_union(@grammar.build_code(:union, val[3]), val[3].line)
1236
+
1237
+ result
1238
+ end
1239
+ .,.,
1240
+
1241
+ # reduce 24 omitted
1242
+
1243
+ module_eval(<<'.,.,', 'parser.y', 79)
1244
+ def _reduce_25(val, _values, result)
1245
+ @lexer.status = :c_declaration
1246
+ @lexer.end_symbol = '}'
1247
+
1248
+ result
1249
+ end
1250
+ .,.,
1251
+
1252
+ module_eval(<<'.,.,', 'parser.y', 84)
1253
+ def _reduce_26(val, _values, result)
1254
+ @lexer.status = :initial
1255
+ @lexer.end_symbol = nil
1256
+
1257
+ result
1258
+ end
1259
+ .,.,
1260
+
1261
+ # reduce 27 omitted
1262
+
1263
+ module_eval(<<'.,.,', 'parser.y', 90)
1264
+ def _reduce_28(val, _values, result)
1265
+ @lexer.status = :c_declaration
1266
+ @lexer.end_symbol = '}'
1267
+
1268
+ result
1269
+ end
1270
+ .,.,
1271
+
1272
+ module_eval(<<'.,.,', 'parser.y', 95)
1273
+ def _reduce_29(val, _values, result)
1274
+ @lexer.status = :initial
1275
+ @lexer.end_symbol = nil
1276
+
1277
+ result
1278
+ end
1279
+ .,.,
1280
+
1281
+ module_eval(<<'.,.,', 'parser.y', 100)
1282
+ def _reduce_30(val, _values, result)
1283
+ @grammar.add_printer(ident_or_tags: val[6], code: @grammar.build_code(:printer, val[3]), lineno: val[3].line)
1284
+
1285
+ result
1286
+ end
1287
+ .,.,
1288
+
1289
+ module_eval(<<'.,.,', 'parser.y', 104)
1290
+ def _reduce_31(val, _values, result)
1291
+ @lexer.status = :c_declaration
1292
+ @lexer.end_symbol = '}'
1293
+
1294
+ result
1295
+ end
1296
+ .,.,
1297
+
1298
+ module_eval(<<'.,.,', 'parser.y', 109)
1299
+ def _reduce_32(val, _values, result)
1300
+ @lexer.status = :initial
1301
+ @lexer.end_symbol = nil
1302
+
1303
+ result
1304
+ end
1305
+ .,.,
1306
+
1307
+ module_eval(<<'.,.,', 'parser.y', 114)
1308
+ def _reduce_33(val, _values, result)
1309
+ @grammar.add_error_token(ident_or_tags: val[6], code: @grammar.build_code(:error_token, val[3]), lineno: val[3].line)
1310
+
1311
+ result
1312
+ end
1313
+ .,.,
1314
+
1315
+ # reduce 34 omitted
1316
+
1317
+ module_eval(<<'.,.,', 'parser.y', 120)
1318
+ def _reduce_35(val, _values, result)
1319
+ val[1].each {|hash|
1320
+ hash[:tokens].each {|id|
1321
+ @grammar.add_type(id: id, tag: hash[:tag])
1322
+ }
1323
+ }
1324
+
1325
+ result
1326
+ end
1327
+ .,.,
1328
+
1329
+ module_eval(<<'.,.,', 'parser.y', 128)
1330
+ def _reduce_36(val, _values, result)
1331
+ val[1].each {|hash|
1332
+ hash[:tokens].each {|id|
1333
+ sym = @grammar.add_term(id: id)
1334
+ @grammar.add_left(sym, @precedence_number)
1335
+ }
1336
+ }
1337
+ @precedence_number += 1
1338
+
1339
+ result
1340
+ end
1341
+ .,.,
1342
+
1343
+ module_eval(<<'.,.,', 'parser.y', 138)
1344
+ def _reduce_37(val, _values, result)
1345
+ val[1].each {|hash|
1346
+ hash[:tokens].each {|id|
1347
+ sym = @grammar.add_term(id: id)
1348
+ @grammar.add_right(sym, @precedence_number)
1349
+ }
1350
+ }
1351
+ @precedence_number += 1
1352
+
1353
+ result
1354
+ end
1355
+ .,.,
1356
+
1357
+ module_eval(<<'.,.,', 'parser.y', 148)
1358
+ def _reduce_38(val, _values, result)
1359
+ val[1].each {|hash|
1360
+ hash[:tokens].each {|id|
1361
+ sym = @grammar.add_term(id: id)
1362
+ @grammar.add_precedence(sym, @precedence_number)
1363
+ }
1364
+ }
1365
+ @precedence_number += 1
1366
+
1367
+ result
1368
+ end
1369
+ .,.,
1370
+
1371
+ module_eval(<<'.,.,', 'parser.y', 158)
1372
+ def _reduce_39(val, _values, result)
1373
+ val[1].each {|hash|
1374
+ hash[:tokens].each {|id|
1375
+ sym = @grammar.add_term(id: id)
1376
+ @grammar.add_nonassoc(sym, @precedence_number)
1377
+ }
1378
+ }
1379
+ @precedence_number += 1
1380
+
1381
+ result
1382
+ end
1383
+ .,.,
1384
+
1385
+ module_eval(<<'.,.,', 'parser.y', 169)
1386
+ def _reduce_40(val, _values, result)
1387
+ val[0].each {|token_declaration|
1388
+ @grammar.add_term(id: token_declaration[0], alias_name: token_declaration[2], token_id: token_declaration[1], tag: nil, replace: true)
1389
+ }
1390
+
1391
+ result
1392
+ end
1393
+ .,.,
1394
+
1395
+ module_eval(<<'.,.,', 'parser.y', 175)
1396
+ def _reduce_41(val, _values, result)
1397
+ val[1].each {|token_declaration|
1398
+ @grammar.add_term(id: token_declaration[0], alias_name: token_declaration[2], token_id: token_declaration[1], tag: val[0], replace: true)
1399
+ }
1400
+
1401
+ result
1402
+ end
1403
+ .,.,
1404
+
1405
+ module_eval(<<'.,.,', 'parser.y', 181)
1406
+ def _reduce_42(val, _values, result)
1407
+ val[2].each {|token_declaration|
1408
+ @grammar.add_term(id: token_declaration[0], alias_name: token_declaration[2], token_id: token_declaration[1], tag: val[1], replace: true)
1409
+ }
1410
+
1411
+ result
1412
+ end
1413
+ .,.,
1414
+
1415
+ module_eval(<<'.,.,', 'parser.y', 186)
1416
+ def _reduce_43(val, _values, result)
1417
+ result = [val[0]]
1418
+ result
1419
+ end
1420
+ .,.,
1421
+
1422
+ module_eval(<<'.,.,', 'parser.y', 187)
1423
+ def _reduce_44(val, _values, result)
1424
+ result = val[0].append(val[1])
1425
+ result
1426
+ end
1427
+ .,.,
1428
+
1429
+ module_eval(<<'.,.,', 'parser.y', 189)
1430
+ def _reduce_45(val, _values, result)
1431
+ result = val
1432
+ result
1433
+ end
1434
+ .,.,
1435
+
1436
+ # reduce 46 omitted
1437
+
1438
+ # reduce 47 omitted
1439
+
1440
+ # reduce 48 omitted
1441
+
1442
+ # reduce 49 omitted
1443
+
1444
+ module_eval(<<'.,.,', 'parser.y', 199)
1445
+ def _reduce_50(val, _values, result)
1446
+ result = [{tag: nil, tokens: val[0]}]
1447
+
1448
+ result
1449
+ end
1450
+ .,.,
1451
+
1452
+ module_eval(<<'.,.,', 'parser.y', 203)
1453
+ def _reduce_51(val, _values, result)
1454
+ result = [{tag: val[0], tokens: val[1]}]
1455
+
1456
+ result
1457
+ end
1458
+ .,.,
1459
+
1460
+ module_eval(<<'.,.,', 'parser.y', 207)
1461
+ def _reduce_52(val, _values, result)
1462
+ result = val[0].append({tag: val[1], tokens: val[2]})
1463
+
1464
+ result
1465
+ end
1466
+ .,.,
1467
+
1468
+ module_eval(<<'.,.,', 'parser.y', 210)
1469
+ def _reduce_53(val, _values, result)
1470
+ result = [val[0]]
1471
+ result
1472
+ end
1473
+ .,.,
1474
+
1475
+ module_eval(<<'.,.,', 'parser.y', 211)
1476
+ def _reduce_54(val, _values, result)
1477
+ result = val[0].append(val[1])
1478
+ result
1479
+ end
1480
+ .,.,
1481
+
1482
+ # reduce 55 omitted
1483
+
1484
+ # reduce 56 omitted
1485
+
1486
+ module_eval(<<'.,.,', 'parser.y', 218)
1487
+ def _reduce_57(val, _values, result)
1488
+ @lexer.status = :c_declaration
1489
+ @lexer.end_symbol = '}'
1490
+
1491
+ result
1492
+ end
1493
+ .,.,
1494
+
1495
+ module_eval(<<'.,.,', 'parser.y', 223)
1496
+ def _reduce_58(val, _values, result)
1497
+ @lexer.status = :initial
1498
+ @lexer.end_symbol = nil
1499
+
1500
+ result
1501
+ end
1502
+ .,.,
1503
+
1504
+ module_eval(<<'.,.,', 'parser.y', 228)
1505
+ def _reduce_59(val, _values, result)
1506
+ result = val[0].append(val[3])
1507
+
1508
+ result
1509
+ end
1510
+ .,.,
1511
+
1512
+ module_eval(<<'.,.,', 'parser.y', 232)
1513
+ def _reduce_60(val, _values, result)
1514
+ @lexer.status = :c_declaration
1515
+ @lexer.end_symbol = '}'
1516
+
1517
+ result
1518
+ end
1519
+ .,.,
1520
+
1521
+ module_eval(<<'.,.,', 'parser.y', 237)
1522
+ def _reduce_61(val, _values, result)
1523
+ @lexer.status = :initial
1524
+ @lexer.end_symbol = nil
1525
+
1526
+ result
1527
+ end
1528
+ .,.,
1529
+
1530
+ module_eval(<<'.,.,', 'parser.y', 242)
1531
+ def _reduce_62(val, _values, result)
1532
+ result = [val[2]]
1533
+
1534
+ result
1535
+ end
1536
+ .,.,
1537
+
1538
+ module_eval(<<'.,.,', 'parser.y', 247)
1539
+ def _reduce_63(val, _values, result)
1540
+ result = [{tag: nil, tokens: val[0]}]
1541
+
1542
+ result
1543
+ end
1544
+ .,.,
1545
+
1546
+ module_eval(<<'.,.,', 'parser.y', 251)
1547
+ def _reduce_64(val, _values, result)
1548
+ result = [{tag: val[0], tokens: val[1]}]
1549
+
1550
+ result
1551
+ end
1552
+ .,.,
1553
+
1554
+ module_eval(<<'.,.,', 'parser.y', 255)
1555
+ def _reduce_65(val, _values, result)
1556
+ result = val[0].append({tag: nil, tokens: val[1]})
1557
+
1558
+ result
1559
+ end
1560
+ .,.,
1561
+
1562
+ module_eval(<<'.,.,', 'parser.y', 258)
1563
+ def _reduce_66(val, _values, result)
1564
+ result = [val[0]]
1565
+ result
1566
+ end
1567
+ .,.,
1568
+
1569
+ module_eval(<<'.,.,', 'parser.y', 259)
1570
+ def _reduce_67(val, _values, result)
1571
+ result = val[0].append(val[1])
1572
+ result
1573
+ end
1574
+ .,.,
1575
+
1576
+ # reduce 68 omitted
1577
+
1578
+ module_eval(<<'.,.,', 'parser.y', 263)
1579
+ def _reduce_69(val, _values, result)
1580
+ raise "Ident after %prec" if @prec_seen
1581
+ result
1582
+ end
1583
+ .,.,
1584
+
1585
+ module_eval(<<'.,.,', 'parser.y', 264)
1586
+ def _reduce_70(val, _values, result)
1587
+ raise "Char after %prec" if @prec_seen
1588
+ result
1589
+ end
1590
+ .,.,
1591
+
1592
+ # reduce 71 omitted
1593
+
1594
+ # reduce 72 omitted
1595
+
1596
+ # reduce 73 omitted
1597
+
1598
+ # reduce 74 omitted
1599
+
1600
+ module_eval(<<'.,.,', 'parser.y', 274)
1601
+ def _reduce_75(val, _values, result)
1602
+ lhs = val[0]
1603
+ lhs.alias = val[1]
1604
+ val[3].each {|hash|
1605
+ @grammar.add_rule(lhs: lhs, rhs: hash[:rhs], lineno: hash[:lineno])
1606
+ }
1607
+
1608
+ result
1609
+ end
1610
+ .,.,
1611
+
1612
+ module_eval(<<'.,.,', 'parser.y', 283)
1613
+ def _reduce_76(val, _values, result)
1614
+ result = [{rhs: val[0], lineno: val[0].first&.line || @lexer.line - 1}]
1615
+
1616
+ result
1617
+ end
1618
+ .,.,
1619
+
1620
+ module_eval(<<'.,.,', 'parser.y', 287)
1621
+ def _reduce_77(val, _values, result)
1622
+ result = val[0].append({rhs: val[2], lineno: val[2].first&.line || @lexer.line - 1})
1623
+
1624
+ result
1625
+ end
1626
+ .,.,
1627
+
1628
+ # reduce 78 omitted
1629
+
1630
+ module_eval(<<'.,.,', 'parser.y', 293)
1631
+ def _reduce_79(val, _values, result)
1632
+ result = []
1633
+ @prec_seen = false
1634
+ @code_after_prec = false
1635
+
1636
+ result
1637
+ end
1638
+ .,.,
1639
+
1640
+ module_eval(<<'.,.,', 'parser.y', 299)
1641
+ def _reduce_80(val, _values, result)
1642
+ token = val[1]
1643
+ val[1].alias = val[2]
1644
+ result = val[0].append(token)
1645
+
1646
+ result
1647
+ end
1648
+ .,.,
1649
+
1650
+ module_eval(<<'.,.,', 'parser.y', 305)
1651
+ def _reduce_81(val, _values, result)
1652
+ if @prec_seen
1653
+ raise "Multiple User_code after %prec" if @code_after_prec
1654
+ @code_after_prec = true
1655
+ end
1656
+ @lexer.status = :c_declaration
1657
+ @lexer.end_symbol = '}'
1658
+
1659
+ result
1660
+ end
1661
+ .,.,
1662
+
1663
+ module_eval(<<'.,.,', 'parser.y', 314)
1664
+ def _reduce_82(val, _values, result)
1665
+ @lexer.status = :initial
1666
+ @lexer.end_symbol = nil
1667
+
1668
+ result
1669
+ end
1670
+ .,.,
1671
+
1672
+ module_eval(<<'.,.,', 'parser.y', 319)
1673
+ def _reduce_83(val, _values, result)
1674
+ token = val[3]
1675
+ token.alias = val[6]
1676
+ result = val[0].append(token)
1677
+
1678
+ result
1679
+ end
1680
+ .,.,
1681
+
1682
+ module_eval(<<'.,.,', 'parser.y', 325)
1683
+ def _reduce_84(val, _values, result)
1684
+ if @prec_seen
1685
+ raise "Multiple User_code after %prec" if @code_after_prec
1686
+ @code_after_prec = true
1687
+ end
1688
+ @lexer.status = :c_declaration
1689
+ @lexer.end_symbol = '}'
1690
+
1691
+ result
1692
+ end
1693
+ .,.,
1694
+
1695
+ module_eval(<<'.,.,', 'parser.y', 334)
1696
+ def _reduce_85(val, _values, result)
1697
+ @lexer.status = :initial
1698
+ @lexer.end_symbol = nil
1699
+
1700
+ result
1701
+ end
1702
+ .,.,
1703
+
1704
+ module_eval(<<'.,.,', 'parser.y', 339)
1705
+ def _reduce_86(val, _values, result)
1706
+ token = val[2]
1707
+ token.alias = val[5]
1708
+ result = [token]
1709
+
1710
+ result
1711
+ end
1712
+ .,.,
1713
+
1714
+ module_eval(<<'.,.,', 'parser.y', 345)
1715
+ def _reduce_87(val, _values, result)
1716
+ sym = @grammar.find_symbol_by_id!(val[2])
1717
+ result = val[0].append(sym)
1718
+ @prec_seen = true
1719
+
1720
+ result
1721
+ end
1722
+ .,.,
1723
+
1724
+ # reduce 88 omitted
1725
+
1726
+ module_eval(<<'.,.,', 'parser.y', 351)
1727
+ def _reduce_89(val, _values, result)
1728
+ result = val[1].s_value
1729
+ result
1730
+ end
1731
+ .,.,
1732
+
1733
+ # reduce 90 omitted
1734
+
1735
+ # reduce 91 omitted
1736
+
1737
+ module_eval(<<'.,.,', 'parser.y', 358)
1738
+ def _reduce_92(val, _values, result)
1739
+ @lexer.status = :c_declaration
1740
+ @lexer.end_symbol = '\Z'
1741
+ @grammar.epilogue_first_lineno = @lexer.line + 1
1742
+
1743
+ result
1744
+ end
1745
+ .,.,
1746
+
1747
+ module_eval(<<'.,.,', 'parser.y', 364)
1748
+ def _reduce_93(val, _values, result)
1749
+ @lexer.status = :initial
1750
+ @lexer.end_symbol = nil
1751
+ @grammar.epilogue = val[2].s_value
1752
+
1753
+ result
1754
+ end
1755
+ .,.,
1756
+
1757
+ # reduce 94 omitted
1758
+
1759
+ # reduce 95 omitted
1760
+
1761
+ # reduce 96 omitted
1762
+
1763
+ # reduce 97 omitted
1764
+
1765
+ # reduce 98 omitted
1766
+
1767
+ module_eval(<<'.,.,', 'parser.y', 376)
1768
+ def _reduce_99(val, _values, result)
1769
+ result = [val[0]]
1770
+ result
1771
+ end
1772
+ .,.,
1773
+
1774
+ module_eval(<<'.,.,', 'parser.y', 377)
1775
+ def _reduce_100(val, _values, result)
1776
+ result = val[0].append(val[1])
1777
+ result
1778
+ end
1779
+ .,.,
1780
+
1781
+ # reduce 101 omitted
1782
+
1783
+ # reduce 102 omitted
1784
+
1785
+ module_eval(<<'.,.,', 'parser.y', 382)
1786
+ def _reduce_103(val, _values, result)
1787
+ result = Lrama::Lexer::Token.new(type: Lrama::Lexer::Token::Ident, s_value: val[0])
1788
+ result
1789
+ end
1790
+ .,.,
1791
+
1792
+ def _reduce_none(val, _values, result)
1793
+ val[0]
293
1794
  end
1795
+
1796
+ end # class Parser
1797
+ end # module Lrama