lrama 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20a0927bedeb14281abb8a5c59daf643fdfe556b5899cbe4872878b022804da2
4
- data.tar.gz: 731fdd0201266db9724a2ebcc1162427a2cfaa9d0d94543e1298b3f2683eb14f
3
+ metadata.gz: 26bcef726eebf61de01200b02250b2aef91ca957df43db5d72e99ae30e320f4e
4
+ data.tar.gz: 751b62d184806c0cff319bffc4990ad0de9dd143accafdf6bdf1652eb02512b7
5
5
  SHA512:
6
- metadata.gz: 3a6e7c0ef4e7266dae41dba15e3a5d7609cb7171b82e0dbd5b75595e8e3cf8a4a402c5b710cc0f714c54357ef9fc20fd0935e55b8c529c99cd3c09ea173efb87
7
- data.tar.gz: fa867c9be43384c7f282bf22ecd2b0939cd0dca263a51914871dba42f409ddc01fb00c34d8696288c3668177fdc450ff1bc9fb5e90fdf053e2d56a5bf31bbe04
6
+ metadata.gz: 02001b5b137d023c4f5ce48c1d9284ce90c5aad2ec269d7ef7a17e6ffa65be9e553e213400fc63d8256c0209908fc4b314de261993442af4a25772449453fbeb
7
+ data.tar.gz: 76a9f6bac19c0dcbdc6f9e2834d3c437f9fc5eb999d1b45d20362d52a94c9dc74bca3411b681993e28f388374df7f9b8ea7d0f534e53399efb8cc24112f75ea4
@@ -35,6 +35,7 @@ jobs:
35
35
  ruby-version: ${{ matrix.ruby }}
36
36
  bundler-cache: true
37
37
  - run: bundle install
38
+ - run: bundle exec rbs collection install
38
39
  - run: bundle exec steep check
39
40
  test-ruby:
40
41
  runs-on: ubuntu-20.04
@@ -57,9 +58,7 @@ jobs:
57
58
  - run: mkdir -p tool/lrama
58
59
  working-directory: ../ruby
59
60
  - name: Copy Lrama to ruby/tool
60
- run: cp -r exe lib ../ruby/tool/lrama
61
- # TODO: Consider how to manage changes on ruby/ruby master and ruby/lrama
62
- # run: cp -r exe lib template ../ruby/tool/lrama
61
+ run: cp -r exe lib template ../ruby/tool/lrama
63
62
  working-directory:
64
63
  - run: tree tool/lrama
65
64
  working-directory: ../ruby
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ /.gem_rbs_collection/
1
2
  /tmp
2
3
  .irbrc
3
4
  /Gemfile.lock
data/README.md CHANGED
@@ -62,7 +62,7 @@ This branch generates "parse.c" compatible with Bison 3.8.2 for ruby 3.0, 3.1, 3
62
62
 
63
63
  1. Update `Lrama::VERSION`
64
64
  2. Release as a gem by `rake release`
65
- 3. Update Lrama in ruby/ruby by `cp -r exe lib ruby/tool/lrama`
65
+ 3. Update Lrama in ruby/ruby by `cp -r LEGAL.md MIT exe lib ruby/tool/lrama`
66
66
  4. Create new release on [GitHub](https://github.com/ruby/lrama/releases)
67
67
 
68
68
  ## License
data/Steepfile CHANGED
@@ -4,4 +4,6 @@ target :lib do
4
4
  signature "sig"
5
5
 
6
6
  check "lib/lrama/bitmap.rb"
7
+ check "lib/lrama/report.rb"
8
+ check "lib/lrama/warning.rb"
7
9
  end
data/lib/lrama/grammar.rb CHANGED
@@ -155,16 +155,16 @@ module Lrama
155
155
  last_column = ref.last_column
156
156
 
157
157
  case
158
- when ref.number == "$" && ref.type == :dollar # $$
158
+ when ref.value == "$" && ref.type == :dollar # $$
159
159
  # Omit "<>"
160
160
  member = tag.s_value[1..-2]
161
161
  str = "((*yyvaluep).#{member})"
162
- when ref.number == "$" && ref.type == :at # @$
162
+ when ref.value == "$" && ref.type == :at # @$
163
163
  str = "(*yylocationp)"
164
164
  when ref.type == :dollar # $n
165
- raise "$#{ref.number} can not be used in %printer."
165
+ raise "$#{ref.value} can not be used in %printer."
166
166
  when ref.type == :at # @n
167
- raise "@#{ref.number} can not be used in %printer."
167
+ raise "@#{ref.value} can not be used in %printer."
168
168
  else
169
169
  raise "Unexpected. #{self}, #{ref}"
170
170
  end
@@ -190,19 +190,19 @@ module Lrama
190
190
  last_column = ref.last_column
191
191
 
192
192
  case
193
- when ref.number == "$" && ref.type == :dollar # $$
193
+ when ref.value == "$" && ref.type == :dollar # $$
194
194
  # Omit "<>"
195
195
  member = ref.tag.s_value[1..-2]
196
196
  str = "(yyval.#{member})"
197
- when ref.number == "$" && ref.type == :at # @$
197
+ when ref.value == "$" && ref.type == :at # @$
198
198
  str = "(yyloc)"
199
199
  when ref.type == :dollar # $n
200
- i = -ref.position_in_rhs + ref.number
200
+ i = -ref.position_in_rhs + ref.value
201
201
  # Omit "<>"
202
202
  member = ref.tag.s_value[1..-2]
203
203
  str = "(yyvsp[#{i}].#{member})"
204
204
  when ref.type == :at # @n
205
- i = -ref.position_in_rhs + ref.number
205
+ i = -ref.position_in_rhs + ref.value
206
206
  str = "(yylsp[#{i}])"
207
207
  else
208
208
  raise "Unexpected. #{self}, #{ref}"
@@ -226,14 +226,14 @@ module Lrama
226
226
  last_column = ref.last_column
227
227
 
228
228
  case
229
- when ref.number == "$" && ref.type == :dollar # $$
229
+ when ref.value == "$" && ref.type == :dollar # $$
230
230
  str = "yylval"
231
- when ref.number == "$" && ref.type == :at # @$
231
+ when ref.value == "$" && ref.type == :at # @$
232
232
  str = "yylloc"
233
233
  when ref.type == :dollar # $n
234
- raise "$#{ref.number} can not be used in initial_action."
234
+ raise "$#{ref.value} can not be used in initial_action."
235
235
  when ref.type == :at # @n
236
- raise "@#{ref.number} can not be used in initial_action."
236
+ raise "@#{ref.value} can not be used in initial_action."
237
237
  else
238
238
  raise "Unexpected. #{self}, #{ref}"
239
239
  end
@@ -247,7 +247,7 @@ module Lrama
247
247
 
248
248
  # type: :dollar or :at
249
249
  # ex_tag: "$<tag>1" (Optional)
250
- Reference = Struct.new(:type, :number, :ex_tag, :first_column, :last_column, :referring_symbol, :position_in_rhs, keyword_init: true) do
250
+ Reference = Struct.new(:type, :value, :ex_tag, :first_column, :last_column, :referring_symbol, :position_in_rhs, keyword_init: true) do
251
251
  def tag
252
252
  if ex_tag
253
253
  ex_tag
@@ -382,8 +382,8 @@ module Lrama
382
382
  end
383
383
 
384
384
  def build_references(token_code)
385
- token_code.references.map! do |type, number, tag, first_column, last_column|
386
- Reference.new(type: type, number: number, ex_tag: tag, first_column: first_column, last_column: last_column)
385
+ token_code.references.map! do |type, value, tag, first_column, last_column|
386
+ Reference.new(type: type, value: value, ex_tag: tag, first_column: first_column, last_column: last_column)
387
387
  end
388
388
 
389
389
  token_code
@@ -627,15 +627,23 @@ module Lrama
627
627
  ref.position_in_rhs = i - 1
628
628
  next if ref.type == :at
629
629
  # $$, $n, @$, @n can be used in any actions
630
- number = ref.number
631
630
 
632
- if number == "$"
631
+ if ref.value == "$"
633
632
  # TODO: Should be postponed after middle actions are extracted?
634
633
  ref.referring_symbol = lhs
635
- else
636
- raise "Can not refer following component. #{number} >= #{i}. #{token}" if number >= i
637
- rhs1[number - 1].referred = true
638
- ref.referring_symbol = rhs1[number - 1]
634
+ elsif ref.value.is_a?(Integer)
635
+ raise "Can not refer following component. #{ref.value} >= #{i}. #{token}" if ref.value >= i
636
+ rhs1[ref.value - 1].referred = true
637
+ ref.referring_symbol = rhs1[ref.value - 1]
638
+ elsif ref.value.is_a?(String)
639
+ target_tokens = ([lhs] + rhs1 + [code]).compact.first(i)
640
+ referring_symbol_candidate = target_tokens.filter {|token| token.referred_by?(ref.value) }
641
+ raise "Referring symbol `#{ref.value}` is duplicated. #{token}" if referring_symbol_candidate.size >= 2
642
+ raise "Referring symbol `#{ref.value}` is not found. #{token}" if referring_symbol_candidate.count == 0
643
+
644
+ referring_symbol = referring_symbol_candidate.first
645
+ referring_symbol.referred = true
646
+ ref.referring_symbol = referring_symbol
639
647
  end
640
648
  end
641
649
  end
data/lib/lrama/lexer.rb CHANGED
@@ -7,7 +7,7 @@ module Lrama
7
7
  include Lrama::Report::Duration
8
8
 
9
9
  # s_value is semantic value
10
- Token = Struct.new(:type, :s_value, keyword_init: true) do
10
+ Token = Struct.new(:type, :s_value, :alias, keyword_init: true) do
11
11
  Type = Struct.new(:id, :name, keyword_init: true)
12
12
 
13
13
  attr_accessor :line, :column, :referred
@@ -18,6 +18,31 @@ module Lrama
18
18
  "#{super} line: #{line}, column: #{column}"
19
19
  end
20
20
 
21
+ def referred_by?(string)
22
+ [self.s_value, self.alias].include?(string)
23
+ end
24
+
25
+ def ==(other)
26
+ self.class == other.class && self.type == other.type && self.s_value == other.s_value
27
+ end
28
+
29
+ def numberize_references(lhs, rhs)
30
+ self.references.map! {|ref|
31
+ ref_name = ref[1]
32
+ if ref_name.is_a?(String) && ref_name != '$'
33
+ value =
34
+ if lhs.referred_by?(ref_name)
35
+ '$'
36
+ else
37
+ rhs.find_index {|token| token.referred_by?(ref_name) } + 1
38
+ end
39
+ [ref[0], value, ref[2], ref[3], ref[4]]
40
+ else
41
+ ref
42
+ end
43
+ }
44
+ end
45
+
21
46
  @i = 0
22
47
  @types = []
23
48
 
@@ -47,6 +72,7 @@ module Lrama
47
72
  define_type(:Number) # 0
48
73
  define_type(:Ident_Colon) # k_if:, k_if : (spaces can be there)
49
74
  define_type(:Ident) # api.pure, tNUMBER
75
+ define_type(:Named_Ref) # [foo]
50
76
  define_type(:Semicolon) # ;
51
77
  define_type(:Bar) # |
52
78
  define_type(:String) # "str"
@@ -166,10 +192,15 @@ module Lrama
166
192
  tokens << create_token(Token::Number, Integer(ss[0]), line, ss.pos - column)
167
193
  when ss.scan(/(<[a-zA-Z0-9_]+>)/)
168
194
  tokens << create_token(Token::Tag, ss[0], line, ss.pos - column)
195
+ when ss.scan(/([a-zA-Z_.][-a-zA-Z0-9_.]*)\[([a-zA-Z_.][-a-zA-Z0-9_.]*)\]\s*:/)
196
+ tokens << create_token(Token::Ident_Colon, ss[1], line, ss.pos - column)
197
+ tokens << create_token(Token::Named_Ref, ss[2], line, ss.pos - column)
169
198
  when ss.scan(/([a-zA-Z_.][-a-zA-Z0-9_.]*)\s*:/)
170
199
  tokens << create_token(Token::Ident_Colon, ss[1], line, ss.pos - column)
171
200
  when ss.scan(/([a-zA-Z_.][-a-zA-Z0-9_.]*)/)
172
201
  tokens << create_token(Token::Ident, ss[0], line, ss.pos - column)
202
+ when ss.scan(/\[([a-zA-Z_.][-a-zA-Z0-9_.]*)\]/)
203
+ tokens << create_token(Token::Named_Ref, ss[1], line, ss.pos - column)
173
204
  when ss.scan(/%expect/)
174
205
  tokens << create_token(Token::P_expect, ss[0], line, ss.pos - column)
175
206
  when ss.scan(/%define/)
@@ -257,6 +288,9 @@ module Lrama
257
288
  when ss.scan(/\$(<[a-zA-Z0-9_]+>)?(\d+)/) # $1, $2, $<long>1
258
289
  tag = ss[1] ? create_token(Token::Tag, ss[1], line, str.length) : nil
259
290
  references << [:dollar, Integer(ss[2]), tag, str.length, str.length + ss[0].length - 1]
291
+ when ss.scan(/\$(<[a-zA-Z0-9_]+>)?([a-zA-Z_.][-a-zA-Z0-9_.]*)/) # $foo, $expr, $<long>program
292
+ tag = ss[1] ? create_token(Token::Tag, ss[1], line, str.length) : nil
293
+ references << [:dollar, ss[2], tag, str.length, str.length + ss[0].length - 1]
260
294
  when ss.scan(/@\$/) # @$
261
295
  references << [:at, "$", nil, str.length, str.length + ss[0].length - 1]
262
296
  when ss.scan(/@(\d)+/) # @1
@@ -14,6 +14,10 @@ module Lrama
14
14
  current_token && current_token.type
15
15
  end
16
16
 
17
+ def previous_token
18
+ @tokens[@index - 1]
19
+ end
20
+
17
21
  def next
18
22
  token = current_token
19
23
  @index += 1
data/lib/lrama/parser.rb CHANGED
@@ -175,8 +175,11 @@ module Lrama
175
175
  # LHS
176
176
  lhs = ts.consume!(T::Ident_Colon) # class:
177
177
  lhs.type = T::Ident
178
+ if named_ref = ts.consume(T::Named_Ref)
179
+ lhs.alias = named_ref.s_value
180
+ end
178
181
 
179
- rhs = parse_grammar_rule_rhs(ts, grammar)
182
+ rhs = parse_grammar_rule_rhs(ts, grammar, lhs)
180
183
 
181
184
  grammar.add_rule(lhs: lhs, rhs: rhs, lineno: rhs.first ? rhs.first.line : lhs.line)
182
185
 
@@ -186,7 +189,7 @@ module Lrama
186
189
  # |
187
190
  bar_lineno = ts.current_token.line
188
191
  ts.next
189
- rhs = parse_grammar_rule_rhs(ts, grammar)
192
+ rhs = parse_grammar_rule_rhs(ts, grammar, lhs)
190
193
  grammar.add_rule(lhs: lhs, rhs: rhs, lineno: rhs.first ? rhs.first.line : bar_lineno)
191
194
  when T::Semicolon
192
195
  # ;
@@ -205,13 +208,13 @@ module Lrama
205
208
  end
206
209
  end
207
210
 
208
- def parse_grammar_rule_rhs(ts, grammar)
211
+ def parse_grammar_rule_rhs(ts, grammar, lhs)
209
212
  a = []
210
213
  prec_seen = false
211
214
  code_after_prec = false
212
215
 
213
216
  while true do
214
- # TODO: Srting can be here
217
+ # TODO: String can be here
215
218
  case ts.current_type
216
219
  when T::Ident
217
220
  # keyword_class
@@ -244,9 +247,13 @@ module Lrama
244
247
  end
245
248
 
246
249
  code = ts.current_token
250
+ code.numberize_references(lhs, a)
247
251
  grammar.build_references(code)
248
252
  a << code
249
253
  ts.next
254
+ when T::Named_Ref
255
+ ts.previous_token.alias = ts.current_token.s_value
256
+ ts.next
250
257
  when T::Bar
251
258
  # |
252
259
  break
data/lib/lrama/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lrama
2
- VERSION = "0.5.1".freeze
2
+ VERSION = "0.5.2".freeze
3
3
  end
data/lrama.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
 
9
9
  spec.summary = "LALR (1) parser generator written by Ruby"
10
10
  spec.description = "LALR (1) parser generator written by Ruby"
11
- spec.homepage = "https://github.com/yui-knk/lrama"
11
+ spec.homepage = "https://github.com/ruby/lrama"
12
12
  # See LEGAL.md file for detail
13
13
  spec.license = "GNU GPLv3"
14
14
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
@@ -0,0 +1,26 @@
1
+ ---
2
+ sources:
3
+ - type: git
4
+ name: ruby/gem_rbs_collection
5
+ revision: 28208148c7e64a25e9b86b9723b4c3a2cef14e81
6
+ remote: https://github.com/ruby/gem_rbs_collection.git
7
+ repo_dir: gems
8
+ path: ".gem_rbs_collection"
9
+ gems:
10
+ - name: erb
11
+ version: '0'
12
+ source:
13
+ type: stdlib
14
+ - name: stackprof
15
+ version: '0.2'
16
+ source:
17
+ type: git
18
+ name: ruby/gem_rbs_collection
19
+ revision: 28208148c7e64a25e9b86b9723b4c3a2cef14e81
20
+ remote: https://github.com/ruby/gem_rbs_collection.git
21
+ repo_dir: gems
22
+ - name: strscan
23
+ version: '0'
24
+ source:
25
+ type: stdlib
26
+ gemfile_lock_path: Gemfile.lock
@@ -0,0 +1,22 @@
1
+ # Download sources
2
+ sources:
3
+ - type: git
4
+ name: ruby/gem_rbs_collection
5
+ remote: https://github.com/ruby/gem_rbs_collection.git
6
+ revision: main
7
+ repo_dir: gems
8
+
9
+ # You can specify local directories as sources also.
10
+ # - type: local
11
+ # path: path/to/your/local/repository
12
+
13
+ # A directory to install the downloaded RBSs
14
+ path: .gem_rbs_collection
15
+
16
+ gems:
17
+ - name: erb
18
+ - name: strscan
19
+ # Skip loading rbs gem's RBS.
20
+ # It's unnecessary if you don't use rbs as a library.
21
+ - name: rbs
22
+ ignore: true
@@ -0,0 +1,15 @@
1
+ module Lrama
2
+ class Report
3
+ module Profile
4
+ def self.report_profile: { -> void } -> StackProf::result
5
+ end
6
+
7
+ module Duration
8
+ self.@_report_duration_enabled: bool | nil
9
+
10
+ def self.enable: -> void
11
+ def self.enabled?: -> bool
12
+ def report_duration: [T] (_ToS method_name) { -> T } -> T
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ module Lrama
2
+ class Warning
3
+ interface _Appendable
4
+ def <<: (String message) -> self
5
+ end
6
+
7
+ @out: _Appendable
8
+
9
+ attr_reader errors: Array[String]
10
+ attr_reader warns: Array[String]
11
+ def initialize: (?_Appendable out) -> void
12
+ def error: (String message) -> void
13
+ def warn: (String message) -> void
14
+ def has_error?: -> bool
15
+ end
16
+ end
@@ -114,7 +114,7 @@
114
114
  #ifndef YYDEBUG
115
115
  # define YYDEBUG 0
116
116
  #endif
117
- #if YYDEBUG
117
+ #if YYDEBUG && !defined(yydebug)
118
118
  extern int yydebug;
119
119
  #endif
120
120
  <%-# b4_percent_code_get([[requires]]). %code is not supported -%>
@@ -731,7 +731,7 @@ do { \
731
731
 
732
732
  /* Temporary convenience wrapper in case some people defined the
733
733
  undocumented and private YY_LOCATION_PRINT macros. */
734
- # define YYLOCATION_PRINT(File, Loc) YY_LOCATION_PRINT(File, *(Loc))
734
+ # define YYLOCATION_PRINT(File, Loc<%= output.user_args %>) YY_LOCATION_PRINT(File, *(Loc)<%= output.user_args %>)
735
735
 
736
736
  # elif defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
737
737
 
@@ -767,11 +767,11 @@ yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
767
767
 
768
768
  /* Temporary convenience wrapper in case some people defined the
769
769
  undocumented and private YY_LOCATION_PRINT macros. */
770
- # define YY_LOCATION_PRINT(File, Loc) YYLOCATION_PRINT(File, &(Loc))
770
+ # define YY_LOCATION_PRINT(File, Loc<%= output.user_args %>) YYLOCATION_PRINT(File, &(Loc)<%= output.user_args %>)
771
771
 
772
772
  # else
773
773
 
774
- # define YYLOCATION_PRINT(File, Loc) ((void) 0)
774
+ # define YYLOCATION_PRINT(File, Loc<%= output.user_args %>) ((void) 0)
775
775
  /* Temporary convenience wrapper in case some people defined the
776
776
  undocumented and private YY_LOCATION_PRINT macros. */
777
777
  # define YY_LOCATION_PRINT YYLOCATION_PRINT
@@ -780,13 +780,13 @@ yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
780
780
  # endif /* !defined YYLOCATION_PRINT */
781
781
 
782
782
 
783
- # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
783
+ # define YY_SYMBOL_PRINT(Title, Kind, Value, Location<%= output.user_args %>) \
784
784
  do { \
785
785
  if (yydebug) \
786
786
  { \
787
787
  YYFPRINTF (stderr, "%s ", Title); \
788
788
  yy_symbol_print (stderr, \
789
- Kind, Value, Location, p); \
789
+ Kind, Value, Location<%= output.user_args %>); \
790
790
  YYFPRINTF (stderr, "\n"); \
791
791
  } \
792
792
  } while (0)
@@ -828,9 +828,9 @@ yy_symbol_print (FILE *yyo,
828
828
  YYFPRINTF (yyo, "%s %s (",
829
829
  yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
830
830
 
831
- YYLOCATION_PRINT (yyo, yylocationp);
831
+ YYLOCATION_PRINT (yyo, yylocationp<%= output.user_args %>);
832
832
  YYFPRINTF (yyo, ": ");
833
- yy_symbol_value_print (yyo, yykind, yyvaluep, yylocationp, p);
833
+ yy_symbol_value_print (yyo, yykind, yyvaluep, yylocationp<%= output.user_args %>);
834
834
  YYFPRINTF (yyo, ")");
835
835
  }
836
836
 
@@ -840,7 +840,7 @@ yy_symbol_print (FILE *yyo,
840
840
  `------------------------------------------------------------------*/
841
841
 
842
842
  static void
843
- yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
843
+ yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop<%= output.user_formals %>)
844
844
  {
845
845
  YYFPRINTF (stderr, "Stack now");
846
846
  for (; yybottom <= yytop; yybottom++)
@@ -851,10 +851,10 @@ yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
851
851
  YYFPRINTF (stderr, "\n");
852
852
  }
853
853
 
854
- # define YY_STACK_PRINT(Bottom, Top) \
854
+ # define YY_STACK_PRINT(Bottom, Top<%= output.user_args %>) \
855
855
  do { \
856
856
  if (yydebug) \
857
- yy_stack_print ((Bottom), (Top)); \
857
+ yy_stack_print ((Bottom), (Top)<%= output.user_args %>); \
858
858
  } while (0)
859
859
 
860
860
 
@@ -878,25 +878,27 @@ yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp,
878
878
  yy_symbol_print (stderr,
879
879
  YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
880
880
  &yyvsp[(yyi + 1) - (yynrhs)],
881
- &(yylsp[(yyi + 1) - (yynrhs)]), p);
881
+ &(yylsp[(yyi + 1) - (yynrhs)])<%= output.user_args %>);
882
882
  YYFPRINTF (stderr, "\n");
883
883
  }
884
884
  }
885
885
 
886
- # define YY_REDUCE_PRINT(Rule) \
886
+ # define YY_REDUCE_PRINT(Rule<%= output.user_args %>) \
887
887
  do { \
888
888
  if (yydebug) \
889
- yy_reduce_print (yyssp, yyvsp, yylsp, Rule, p); \
889
+ yy_reduce_print (yyssp, yyvsp, yylsp, Rule<%= output.user_args %>); \
890
890
  } while (0)
891
891
 
892
892
  /* Nonzero means print parse trace. It is left uninitialized so that
893
893
  multiple parsers can coexist. */
894
+ #ifndef yydebug
894
895
  int yydebug;
896
+ #endif
895
897
  #else /* !YYDEBUG */
896
898
  # define YYDPRINTF(Args) ((void) 0)
897
- # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
898
- # define YY_STACK_PRINT(Bottom, Top)
899
- # define YY_REDUCE_PRINT(Rule)
899
+ # define YY_SYMBOL_PRINT(Title, Kind, Value, Location<%= output.user_args %>)
900
+ # define YY_STACK_PRINT(Bottom, Top<%= output.user_args %>)
901
+ # define YY_REDUCE_PRINT(Rule<%= output.user_args %>)
900
902
  #endif /* !YYDEBUG */
901
903
 
902
904
 
@@ -1110,7 +1112,7 @@ yy_syntax_error_arguments (const yypcontext_t *yyctx,
1110
1112
  required number of bytes is too large to store. */
1111
1113
  static int
1112
1114
  yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
1113
- const yypcontext_t *yyctx)
1115
+ const yypcontext_t *yyctx<%= output.user_formals %>)
1114
1116
  {
1115
1117
  enum { YYARGS_MAX = 5 };
1116
1118
  /* Internationalized format string. */
@@ -1200,7 +1202,7 @@ yydestruct (const char *yymsg,
1200
1202
  <%= output.parse_param_use("yyvaluep", "yylocationp") %>
1201
1203
  if (!yymsg)
1202
1204
  yymsg = "Deleting";
1203
- YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1205
+ YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp<%= output.user_args %>);
1204
1206
 
1205
1207
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1206
1208
  YY_USE (yykind);
@@ -1227,11 +1229,11 @@ int yychar;
1227
1229
  /* The semantic value of the lookahead symbol. */
1228
1230
  /* Default value used for initialization, for pacifying older GCCs
1229
1231
  or non-GCC compilers. */
1230
- YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1232
+ YY_INITIAL_VALUE (static const YYSTYPE yyval_default;)
1231
1233
  YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1232
1234
 
1233
1235
  /* Location data for the lookahead symbol. */
1234
- static YYLTYPE yyloc_default
1236
+ static const YYLTYPE yyloc_default
1235
1237
  # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1236
1238
  = { 1, 1, 1, 1 }
1237
1239
  # endif
@@ -1322,7 +1324,7 @@ yysetstate:
1322
1324
  YY_IGNORE_USELESS_CAST_BEGIN
1323
1325
  *yyssp = YY_CAST (yy_state_t, yystate);
1324
1326
  YY_IGNORE_USELESS_CAST_END
1325
- YY_STACK_PRINT (yyss, yyssp);
1327
+ YY_STACK_PRINT (yyss, yyssp<%= output.user_args %>);
1326
1328
 
1327
1329
  if (yyss + yystacksize - 1 <= yyssp)
1328
1330
  #if !defined yyoverflow && !defined YYSTACK_RELOCATE
@@ -1440,7 +1442,7 @@ yybackup:
1440
1442
  else
1441
1443
  {
1442
1444
  yytoken = YYTRANSLATE (yychar);
1443
- YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1445
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc<%= output.user_args %>);
1444
1446
  }
1445
1447
 
1446
1448
  /* If the proper action on seeing token YYTOKEN is to reduce or to
@@ -1463,7 +1465,7 @@ yybackup:
1463
1465
  yyerrstatus--;
1464
1466
 
1465
1467
  /* Shift the lookahead token. */
1466
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1468
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc<%= output.user_args %>);
1467
1469
  yystate = yyn;
1468
1470
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1469
1471
  *++yyvsp = yylval;
@@ -1505,7 +1507,7 @@ yyreduce:
1505
1507
  /* Default location. */
1506
1508
  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1507
1509
  yyerror_range[1] = yyloc;
1508
- YY_REDUCE_PRINT (yyn);
1510
+ YY_REDUCE_PRINT (yyn<%= output.user_args %>);
1509
1511
  switch (yyn)
1510
1512
  {
1511
1513
  <%= output.user_actions -%>
@@ -1523,7 +1525,7 @@ yyreduce:
1523
1525
  case of YYERROR or YYBACKUP, subsequent parser actions might lead
1524
1526
  to an incorrect destructor call or verbose syntax error message
1525
1527
  before the lookahead is translated. */
1526
- YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1528
+ YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc<%= output.user_args %>);
1527
1529
 
1528
1530
  YYPOPSTACK (yylen);
1529
1531
  yylen = 0;
@@ -1561,7 +1563,7 @@ yyerrlab:
1561
1563
  = {yyssp, yytoken, &yylloc};
1562
1564
  char const *yymsgp = YY_("syntax error");
1563
1565
  int yysyntax_error_status;
1564
- yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
1566
+ yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx<%= output.user_args %>);
1565
1567
  if (yysyntax_error_status == 0)
1566
1568
  yymsgp = yymsg;
1567
1569
  else if (yysyntax_error_status == -1)
@@ -1573,7 +1575,7 @@ yyerrlab:
1573
1575
  if (yymsg)
1574
1576
  {
1575
1577
  yysyntax_error_status
1576
- = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
1578
+ = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx<%= output.user_args %>);
1577
1579
  yymsgp = yymsg;
1578
1580
  }
1579
1581
  else
@@ -1628,7 +1630,7 @@ yyerrorlab:
1628
1630
  this YYERROR. */
1629
1631
  YYPOPSTACK (yylen);
1630
1632
  yylen = 0;
1631
- YY_STACK_PRINT (yyss, yyssp);
1633
+ YY_STACK_PRINT (yyss, yyssp<%= output.user_args %>);
1632
1634
  yystate = *yyssp;
1633
1635
  goto yyerrlab1;
1634
1636
 
@@ -1663,7 +1665,7 @@ yyerrlab1:
1663
1665
  YY_ACCESSING_SYMBOL (yystate), yyvsp, yylsp<%= output.user_args %>);
1664
1666
  YYPOPSTACK (1);
1665
1667
  yystate = *yyssp;
1666
- YY_STACK_PRINT (yyss, yyssp);
1668
+ YY_STACK_PRINT (yyss, yyssp<%= output.user_args %>);
1667
1669
  }
1668
1670
 
1669
1671
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
@@ -1675,7 +1677,7 @@ yyerrlab1:
1675
1677
  YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);
1676
1678
 
1677
1679
  /* Shift the error token. */
1678
- YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1680
+ YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp<%= output.user_args %>);
1679
1681
 
1680
1682
  yystate = yyn;
1681
1683
  goto yynewstate;
@@ -1721,7 +1723,7 @@ yyreturnlab:
1721
1723
  /* Do not reclaim the symbols of the rule whose action triggered
1722
1724
  this YYABORT or YYACCEPT. */
1723
1725
  YYPOPSTACK (yylen);
1724
- YY_STACK_PRINT (yyss, yyssp);
1726
+ YY_STACK_PRINT (yyss, yyssp<%= output.user_args %>);
1725
1727
  while (yyssp != yyss)
1726
1728
  {
1727
1729
  yydestruct ("Cleanup: popping",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lrama
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuichiro Kaneko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-20 00:00:00.000000000 Z
11
+ date: 2023-06-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: LALR (1) parser generator written by Ruby
14
14
  email:
@@ -49,13 +49,17 @@ files:
49
49
  - lib/lrama/version.rb
50
50
  - lib/lrama/warning.rb
51
51
  - lrama.gemspec
52
+ - rbs_collection.lock.yaml
53
+ - rbs_collection.yaml
52
54
  - sample/calc.output
53
55
  - sample/calc.y
54
56
  - sample/parse.y
55
57
  - sig/lrama/bitmap.rbs
58
+ - sig/lrama/report.rbs
59
+ - sig/lrama/warning.rbs
56
60
  - template/bison/yacc.c
57
61
  - template/bison/yacc.h
58
- homepage: https://github.com/yui-knk/lrama
62
+ homepage: https://github.com/ruby/lrama
59
63
  licenses:
60
64
  - GNU GPLv3
61
65
  metadata: {}