parser 2.4.0.2 → 2.5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -6
  3. data/CHANGELOG.md +35 -1
  4. data/Gemfile +2 -0
  5. data/README.md +1 -2
  6. data/Rakefile +2 -1
  7. data/bin/ruby-parse +2 -1
  8. data/bin/ruby-rewrite +2 -1
  9. data/lib/gauntlet_parser.rb +2 -0
  10. data/lib/parser.rb +16 -17
  11. data/lib/parser/all.rb +2 -0
  12. data/lib/parser/ast/node.rb +2 -0
  13. data/lib/parser/ast/processor.rb +2 -0
  14. data/lib/parser/base.rb +6 -12
  15. data/lib/parser/builders/default.rb +28 -47
  16. data/lib/parser/clobbering_error.rb +2 -0
  17. data/lib/parser/context.rb +42 -0
  18. data/lib/parser/current.rb +4 -20
  19. data/lib/parser/deprecation.rb +13 -0
  20. data/lib/parser/diagnostic.rb +3 -3
  21. data/lib/parser/diagnostic/engine.rb +2 -0
  22. data/lib/parser/lexer.rl +122 -60
  23. data/lib/parser/lexer/dedenter.rb +2 -0
  24. data/lib/parser/lexer/explanation.rb +2 -0
  25. data/lib/parser/lexer/literal.rb +4 -9
  26. data/lib/parser/lexer/stack_state.rb +4 -1
  27. data/lib/parser/macruby.y +32 -17
  28. data/lib/parser/messages.rb +14 -0
  29. data/lib/parser/meta.rb +2 -0
  30. data/lib/parser/rewriter.rb +30 -44
  31. data/lib/parser/ruby18.y +20 -13
  32. data/lib/parser/ruby19.y +32 -17
  33. data/lib/parser/ruby20.y +33 -18
  34. data/lib/parser/ruby21.y +32 -17
  35. data/lib/parser/ruby22.y +32 -17
  36. data/lib/parser/ruby23.y +32 -17
  37. data/lib/parser/ruby24.y +63 -46
  38. data/lib/parser/ruby25.y +72 -48
  39. data/lib/parser/rubymotion.y +33 -18
  40. data/lib/parser/runner.rb +4 -7
  41. data/lib/parser/runner/ruby_parse.rb +10 -0
  42. data/lib/parser/runner/ruby_rewrite.rb +2 -0
  43. data/lib/parser/source/buffer.rb +19 -24
  44. data/lib/parser/source/comment.rb +2 -0
  45. data/lib/parser/source/comment/associator.rb +2 -0
  46. data/lib/parser/source/map.rb +2 -0
  47. data/lib/parser/source/map/collection.rb +2 -0
  48. data/lib/parser/source/map/condition.rb +2 -0
  49. data/lib/parser/source/map/constant.rb +2 -0
  50. data/lib/parser/source/map/definition.rb +2 -0
  51. data/lib/parser/source/map/for.rb +2 -0
  52. data/lib/parser/source/map/heredoc.rb +2 -0
  53. data/lib/parser/source/map/keyword.rb +2 -0
  54. data/lib/parser/source/map/objc_kwarg.rb +2 -0
  55. data/lib/parser/source/map/operator.rb +2 -0
  56. data/lib/parser/source/map/rescue_body.rb +2 -0
  57. data/lib/parser/source/map/send.rb +2 -0
  58. data/lib/parser/source/map/ternary.rb +2 -0
  59. data/lib/parser/source/map/variable.rb +2 -0
  60. data/lib/parser/source/range.rb +81 -13
  61. data/lib/parser/source/rewriter.rb +48 -10
  62. data/lib/parser/source/rewriter/action.rb +2 -0
  63. data/lib/parser/source/tree_rewriter.rb +301 -0
  64. data/lib/parser/source/tree_rewriter/action.rb +133 -0
  65. data/lib/parser/static_environment.rb +2 -0
  66. data/lib/parser/syntax_error.rb +2 -0
  67. data/lib/parser/tree_rewriter.rb +133 -0
  68. data/lib/parser/version.rb +3 -1
  69. data/parser.gemspec +4 -1
  70. data/test/bug_163/fixtures/input.rb +2 -0
  71. data/test/bug_163/fixtures/output.rb +2 -0
  72. data/test/bug_163/rewriter.rb +2 -0
  73. data/test/helper.rb +7 -7
  74. data/test/parse_helper.rb +57 -10
  75. data/test/racc_coverage_helper.rb +2 -0
  76. data/test/test_base.rb +2 -0
  77. data/test/test_current.rb +2 -4
  78. data/test/test_diagnostic.rb +3 -1
  79. data/test/test_diagnostic_engine.rb +2 -0
  80. data/test/test_encoding.rb +61 -49
  81. data/test/test_lexer.rb +164 -77
  82. data/test/test_lexer_stack_state.rb +2 -0
  83. data/test/test_parse_helper.rb +8 -8
  84. data/test/test_parser.rb +613 -51
  85. data/test/test_runner_rewrite.rb +47 -0
  86. data/test/test_source_buffer.rb +22 -10
  87. data/test/test_source_comment.rb +2 -0
  88. data/test/test_source_comment_associator.rb +2 -0
  89. data/test/test_source_map.rb +2 -0
  90. data/test/test_source_range.rb +92 -45
  91. data/test/test_source_rewriter.rb +3 -1
  92. data/test/test_source_rewriter_action.rb +2 -0
  93. data/test/test_source_tree_rewriter.rb +177 -0
  94. data/test/test_static_environment.rb +2 -0
  95. data/test/using_tree_rewriter/fixtures/input.rb +3 -0
  96. data/test/using_tree_rewriter/fixtures/output.rb +3 -0
  97. data/test/using_tree_rewriter/using_tree_rewriter.rb +9 -0
  98. metadata +21 -10
  99. data/lib/parser/compatibility/ruby1_8.rb +0 -20
  100. data/lib/parser/compatibility/ruby1_9.rb +0 -32
  101. data/test/bug_163/test_runner_rewrite.rb +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21fa6f8258f6f3aa414da7c3d82fe00d6b1313f4
4
- data.tar.gz: b88cb2843f00f3ac299b8b48c21d250d067a9c4c
3
+ metadata.gz: 17012e63bed58664c7f879ca77f492e6d551962a
4
+ data.tar.gz: 1ba7782eabfc5d33ffbcd5a3f5c7ce1b149e0eb1
5
5
  SHA512:
6
- metadata.gz: 40b71684cadcb850f3d58c463dcba4f1a3d25d9909cd989862f566a9827cfa79e5a1fb884c0349234dac7be1475f8ff7c5d396e78457591871f7a6535bbacfb6
7
- data.tar.gz: e7cee38420cd64baa34150c3075532b125eeb98296ca00bf127dd41fe178502ec79a5423b9e4c462b499499f3f8c7110728b16c5d4b18dce1600b07417865786
6
+ metadata.gz: 88787ec044608f586f8d1f9f2ced18005d1af68b5ff6f4cfc7633161bb8e6004aac032803da28c2b37255f98023b47c33d322806096239b1166dc117bf6a1459
7
+ data.tar.gz: 564a7e7e4e75bb412677011482eef36cff953fd023f3b889f0bc922ec0f51e36d6110cd1f01cc18d0d670a286a71aa58b8ad2ef3b268c7582e3afbe4cd45e442
@@ -1,14 +1,13 @@
1
1
  dist: trusty
2
2
  language: ruby
3
3
  rvm:
4
- - 1.9.2
5
- - 1.9.3
6
4
  - 2.0.0
7
- - 2.2.5
8
- - 2.3.1
9
- - 2.4.0
5
+ - 2.2.9
6
+ - 2.3.6
7
+ - 2.4.3
8
+ - 2.5.0
10
9
  - ruby-head
11
- - jruby-9.1.14.0
10
+ - jruby-9.1.15.0
12
11
  - rbx-2
13
12
  matrix:
14
13
  allow_failures:
@@ -1,9 +1,43 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
- Not released (2017-11-13)
4
+ Not released (2018-02-16)
5
5
  -------------------------
6
6
 
7
+ API modifications:
8
+ * Parser::Current: bump to 2.2.9 and 2.3.6. (Stan Hu)
9
+ * Deprecate Parser::Rewriter (Marc-Andre Lafortune)
10
+ * Deprecate Parser::Source::Rewriter (Marc-Andre Lafortune)
11
+ * Change relative order of insert_after_multi and insert_before_multi for non-empty ranges (#399). (Marc-Andre Lafortune)
12
+
13
+ Features implemented:
14
+ * parse.y: Reject brace after literal arg. This commit tracks upstream commits ruby/ruby@9987109 and ruby/ruby@7d6965f. (Ilya Bylich)
15
+ * ruby-parse: add an option for emitting AST as JSON. (Alex Rattray)
16
+ * Add Parser::TreeRewriter (Marc-Andre Lafortune)
17
+ * Add Parser::Rewriter#wrap to ease compatibility (Marc-Andre Lafortune)
18
+ * Add Parser::Source::TreeRewriter (Marc-Andre Lafortune)
19
+ * Add Range#\<=> and include Comparable (Marc-Andre Lafortune)
20
+ * parse.y: disable tLPAREN_ARG state after local variable. (Ilya Bylich)
21
+ * SourceBuffer#source_range (Marc-Andre Lafortune)
22
+ * Range#adjust (Marc-Andre Lafortune)
23
+ * Range#contains?, contained?, crossing? (Marc-Andre Lafortune)
24
+ * Add Range#with. (Marc-André Lafortune)
25
+ * lexer.rl: Relax restriction spaces inside "\u{...}". This commit tracks upstream commit ruby/ruby@7e8b910. (Ilya Bylich)
26
+ * lexer.rl: Allow newlines in heredoc identifiers. This commit tracks upstream commit ruby/ruby@d25faa4. (Ilya Bylich)
27
+ * lexer.rl: allow do after cmdarg in paren. This commit tracks upstream commit ruby/ruby@046c943. (Ilya Bylich)
28
+
29
+ Bugs fixed:
30
+ * Fixed magic encoding comment parsing when encoding comment is on the first line but not in the beginning. (Ilya Bylich)
31
+ * lexer.rl: Parse '1if' as '1 if', '1rescue' as '1 rescue'. (Ilya Bylich)
32
+ * lexer.rl: Save state before entering a block comment to enter it after =end. (Ilya Bylich)
33
+ * parse.y: Prohibit return in class/module body except for singleton class. Replaced @def_level/in_def? in favor of context.indirectly_in_def?. This commit tracks upstream commit ruby/ruby@8c15f40ac. (Ilya Bylich)
34
+ * lexer.rl: Emit :&& as tSYMBEG + tANDOP, :|| as tSYMBEG + tOROP. (Ilya Bylich)
35
+ * ruby{24,25}.y: preserve cmdarg stack around do/end block [Bug #13073]. (Mateusz Lenik)
36
+ * Parser::Lexer::State: Fixed #lexpop to match MRI behavior. (Ilya Bylich)
37
+
38
+ v2.4.0.2 (2017-11-13)
39
+ ---------------------
40
+
7
41
  API modifications:
8
42
  * parser/current: update for 2.3.5 release. (whitequark)
9
43
 
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in parser.gemspec
data/README.md CHANGED
@@ -110,8 +110,7 @@ with Parser:
110
110
  * [Rewriting][rewriting] support.
111
111
  * Parsing error recovery.
112
112
  * Improved [clang-like][] diagnostic messages with location information.
113
- * Written in pure Ruby, runs on MRI 1.8.7 or >=1.9.2, JRuby and Rubinius in 1.8
114
- and 1.9 mode.
113
+ * Written in pure Ruby, runs on MRI >=2.0.0, JRuby and Rubinius (and historically, all versions of Ruby since 1.8)
115
114
  * Only one runtime dependency: the [ast][] gem.
116
115
  * [Insane][insane-lexer] Ruby lexer rewritten from scratch in Ragel.
117
116
  * 100% test coverage for Bison grammars (except error recovery).
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
- # encoding:utf-8
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/gem_tasks'
4
5
  require 'rake/testtask'
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
4
5
  require 'parser/runner/ruby_parse'
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env ruby
1
+ #! /usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
4
5
  require 'parser/runner/ruby_rewrite'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gauntlet'
2
4
  require 'parser/all'
3
5
  require 'shellwords'
@@ -1,22 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ if RUBY_VERSION =~ /^1\.[89]\./
4
+ require 'parser/version'
5
+ raise LoadError, <<-UNSUPPORTED_VERSION_MSG
6
+ parser v#{Parser::VERSION} cannot run on Ruby #{RUBY_VERSION}.
7
+ Please upgrade to Ruby 2.0.0 or higher, or use an older version of the parser gem.
8
+ UNSUPPORTED_VERSION_MSG
9
+ end
10
+
1
11
  require 'set'
2
12
  require 'racc/parser'
3
13
 
4
14
  require 'ast'
5
15
 
6
- if RUBY_VERSION < '1.9'
7
- require 'parser/compatibility/ruby1_8'
8
- end
9
-
10
- if RUBY_VERSION < '2.0'
11
- require 'parser/compatibility/ruby1_9'
12
- end
13
-
14
16
  ##
15
17
  # @api public
16
18
  #
17
19
  module Parser
18
20
  require 'parser/version'
19
21
  require 'parser/messages'
22
+ require 'parser/deprecation'
20
23
 
21
24
  module AST
22
25
  require 'parser/ast/node'
@@ -33,6 +36,8 @@ module Parser
33
36
 
34
37
  require 'parser/source/rewriter'
35
38
  require 'parser/source/rewriter/action'
39
+ require 'parser/source/tree_rewriter'
40
+ require 'parser/source/tree_rewriter/action'
36
41
 
37
42
  require 'parser/source/map'
38
43
  require 'parser/source/map/operator'
@@ -66,16 +71,10 @@ module Parser
66
71
  require 'parser/builders/default'
67
72
  end
68
73
 
74
+ require 'parser/context'
75
+
69
76
  require 'parser/base'
70
77
 
71
78
  require 'parser/rewriter'
72
-
73
- ##
74
- # Verify that the current Ruby implementation supports Encoding.
75
- # @raise [RuntimeError]
76
- def self.check_for_encoding_support
77
- unless defined?(Encoding)
78
- raise RuntimeError, 'Parsing 1.9 and later versions of Ruby is not supported on 1.8 due to the lack of Encoding support'
79
- end
80
- end
79
+ require 'parser/tree_rewriter'
81
80
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'parser/ruby18'
2
4
  require 'parser/ruby19'
3
5
  require 'parser/ruby20'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Parser
2
4
  module AST
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Parser
2
4
  module AST
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Parser
2
4
 
3
5
  ##
@@ -93,9 +95,7 @@ module Parser
93
95
  end
94
96
 
95
97
  def self.setup_source_buffer(file, line, string, encoding)
96
- if string.respond_to? :force_encoding
97
- string = string.dup.force_encoding(encoding)
98
- end
98
+ string = string.dup.force_encoding(encoding)
99
99
 
100
100
  source_buffer = Source::Buffer.new(file, line)
101
101
 
@@ -113,6 +113,7 @@ module Parser
113
113
  attr_reader :builder
114
114
  attr_reader :static_env
115
115
  attr_reader :source_buffer
116
+ attr_reader :context
116
117
 
117
118
  ##
118
119
  # @param [Parser::Builders::Default] builder The AST builder to use.
@@ -128,6 +129,7 @@ module Parser
128
129
 
129
130
  @builder = builder
130
131
  @builder.parser = self
132
+ @context = Context.new
131
133
 
132
134
  if self.class::Racc_debug_parser && ENV['RACC_DEBUG']
133
135
  @yydebug = true
@@ -141,10 +143,10 @@ module Parser
141
143
  #
142
144
  def reset
143
145
  @source_buffer = nil
144
- @def_level = 0 # count of nested def's.
145
146
 
146
147
  @lexer.reset
147
148
  @static_env.reset
149
+ @context.reset
148
150
 
149
151
  self
150
152
  end
@@ -217,14 +219,6 @@ module Parser
217
219
  @lexer.comments = nil
218
220
  end
219
221
 
220
- ##
221
- # @api private
222
- # @return [Boolean]
223
- #
224
- def in_def?
225
- @def_level > 0
226
- end
227
-
228
222
  private
229
223
 
230
224
  def next_token
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Parser
2
4
 
3
5
  ##
@@ -479,7 +481,7 @@ module Parser
479
481
  node.updated(:gvasgn)
480
482
 
481
483
  when :const
482
- if @parser.in_def?
484
+ if @parser.context.indirectly_in_def?
483
485
  diagnostic :error, :dynamic_const, nil, node.loc.expression
484
486
  end
485
487
 
@@ -1207,13 +1209,9 @@ module Parser
1207
1209
  def delimited_string_map(string_t)
1208
1210
  str_range = loc(string_t)
1209
1211
 
1210
- begin_l = Source::Range.new(str_range.source_buffer,
1211
- str_range.begin_pos,
1212
- str_range.begin_pos + 1)
1212
+ begin_l = str_range.with(end_pos: str_range.begin_pos + 1)
1213
1213
 
1214
- end_l = Source::Range.new(str_range.source_buffer,
1215
- str_range.end_pos - 1,
1216
- str_range.end_pos)
1214
+ end_l = str_range.with(begin_pos: str_range.end_pos - 1)
1217
1215
 
1218
1216
  Source::Map::Collection.new(begin_l, end_l,
1219
1217
  loc(string_t))
@@ -1222,9 +1220,7 @@ module Parser
1222
1220
  def prefix_string_map(symbol)
1223
1221
  str_range = loc(symbol)
1224
1222
 
1225
- begin_l = Source::Range.new(str_range.source_buffer,
1226
- str_range.begin_pos,
1227
- str_range.begin_pos + 1)
1223
+ begin_l = str_range.with(end_pos: str_range.begin_pos + 1)
1228
1224
 
1229
1225
  Source::Map::Collection.new(begin_l, nil,
1230
1226
  loc(symbol))
@@ -1238,13 +1234,9 @@ module Parser
1238
1234
  def pair_keyword_map(key_t, value_e)
1239
1235
  key_range = loc(key_t)
1240
1236
 
1241
- key_l = Source::Range.new(key_range.source_buffer,
1242
- key_range.begin_pos,
1243
- key_range.end_pos - 1)
1237
+ key_l = key_range.adjust(end_pos: -1)
1244
1238
 
1245
- colon_l = Source::Range.new(key_range.source_buffer,
1246
- key_range.end_pos - 1,
1247
- key_range.end_pos)
1239
+ colon_l = key_range.with(begin_pos: key_range.end_pos - 1)
1248
1240
 
1249
1241
  [ # key map
1250
1242
  Source::Map::Collection.new(nil, nil,
@@ -1257,13 +1249,10 @@ module Parser
1257
1249
  def pair_quoted_map(begin_t, end_t, value_e)
1258
1250
  end_l = loc(end_t)
1259
1251
 
1260
- quote_l = Source::Range.new(end_l.source_buffer,
1261
- end_l.end_pos - 2,
1262
- end_l.end_pos - 1)
1252
+ quote_l = end_l.with(begin_pos: end_l.end_pos - 2,
1253
+ end_pos: end_l.end_pos - 1)
1263
1254
 
1264
- colon_l = Source::Range.new(end_l.source_buffer,
1265
- end_l.end_pos - 1,
1266
- end_l.end_pos)
1255
+ colon_l = end_l.with(begin_pos: end_l.end_pos - 1)
1267
1256
 
1268
1257
  [ # modified end token
1269
1258
  [ value(end_t), quote_l ],
@@ -1351,9 +1340,7 @@ module Parser
1351
1340
 
1352
1341
  def kwarg_map(name_t, value_e=nil)
1353
1342
  label_range = loc(name_t)
1354
- name_range = Source::Range.new(label_range.source_buffer,
1355
- label_range.begin_pos,
1356
- label_range.end_pos - 1)
1343
+ name_range = label_range.adjust(end_pos: -1)
1357
1344
 
1358
1345
  if value_e
1359
1346
  expr_l = loc(name_t).join(value_e.loc.expression)
@@ -1557,19 +1544,17 @@ module Parser
1557
1544
  source = static_string(parts)
1558
1545
  return nil if source.nil?
1559
1546
 
1560
- if defined?(Encoding)
1561
- source = case
1562
- when options.children.include?(:u)
1563
- source.encode(Encoding::UTF_8)
1564
- when options.children.include?(:e)
1565
- source.encode(Encoding::EUC_JP)
1566
- when options.children.include?(:s)
1567
- source.encode(Encoding::WINDOWS_31J)
1568
- when options.children.include?(:n)
1569
- source.encode(Encoding::BINARY)
1570
- else
1571
- source
1572
- end
1547
+ source = case
1548
+ when options.children.include?(:u)
1549
+ source.encode(Encoding::UTF_8)
1550
+ when options.children.include?(:e)
1551
+ source.encode(Encoding::EUC_JP)
1552
+ when options.children.include?(:s)
1553
+ source.encode(Encoding::WINDOWS_31J)
1554
+ when options.children.include?(:n)
1555
+ source.encode(Encoding::BINARY)
1556
+ else
1557
+ source
1573
1558
  end
1574
1559
 
1575
1560
  Regexp.new(source, (Regexp::EXTENDED if options.children.include?(:x)))
@@ -1591,16 +1576,12 @@ module Parser
1591
1576
  token[0]
1592
1577
  end
1593
1578
 
1594
- if defined?(Encoding)
1595
- def string_value(token)
1596
- unless token[0].valid_encoding?
1597
- diagnostic(:error, :invalid_encoding, nil, token[1])
1598
- end
1599
-
1600
- token[0]
1579
+ def string_value(token)
1580
+ unless token[0].valid_encoding?
1581
+ diagnostic(:error, :invalid_encoding, nil, token[1])
1601
1582
  end
1602
- else
1603
- alias string_value value
1583
+
1584
+ token[0]
1604
1585
  end
1605
1586
 
1606
1587
  def loc(token)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Parser
2
4
  ##
3
5
  # {Parser::ClobberingError} is raised when {Parser::Source::Rewriter}
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Parser
4
+ # Context of parsing that is represented by a stack of scopes.
5
+ #
6
+ # Supported states:
7
+ # + :class - in the class body (class A; end)
8
+ # + :sclass - in the singleton class body (class << obj; end)
9
+ # + :def - in the method body (def m; end)
10
+ # + :defs - in the singleton method body (def self.m; end)
11
+ # + :block - in the block body (tap {})
12
+ # + :lambda - in the lambda body (-> {})
13
+ #
14
+ class Context
15
+ attr_reader :stack
16
+
17
+ def initialize
18
+ @stack = []
19
+ freeze
20
+ end
21
+
22
+ def push(state)
23
+ @stack << state
24
+ end
25
+
26
+ def pop
27
+ @stack.pop
28
+ end
29
+
30
+ def reset
31
+ @stack.clear
32
+ end
33
+
34
+ def in_class?
35
+ @stack.last == :class
36
+ end
37
+
38
+ def indirectly_in_def?
39
+ @stack.include?(:def) || @stack.include?(:defs)
40
+ end
41
+ end
42
+ end