parser 1.3.0 → 1.3.1

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
  SHA1:
3
- metadata.gz: 23913ce91aee27e303077bef4f422f30ac9bc50c
4
- data.tar.gz: 2fb3c11a836c677360f7b17a9590e3a41c30abdc
3
+ metadata.gz: 2bf5ac94c180841ed95eb91426eb5925a01cec77
4
+ data.tar.gz: cf273795bd07e59f5dc23721435782d01579a287
5
5
  SHA512:
6
- metadata.gz: 99b845aa3300fa99c75a726c41d81b33fc1019b6dc937d6eba139602c0c7f75b216344482f6ac57f288e1f1abb804a0ffdf315fc352f3d66ef680622cc7b8566
7
- data.tar.gz: 72ce1310df9f19d5c16f7e4f61287ce187c250898cf15b70c4150e1315f7b57a78189feb48fc71448e9a16966cb44d0abb9d65cd95cba173c8297252a74e76fa
6
+ metadata.gz: 7bae46f95f8443fc99fdb681a8ef7d6aeb03dd7effc3cd214aab37e72da007e701c830a780c8898672c5be5250a21cf768010921018171e73ee9659b4839b57c
7
+ data.tar.gz: e3d932d2f489a690d1f3cf0535820288d8b8af1f0c7d00d41f48eaec79c69853a7e28d9fcc58718218b493fea0acf1d899f5b2a79b6ee7bb22c681c04dd2fe89
@@ -1006,7 +1006,7 @@ class Parser::Lexer
1006
1006
 
1007
1007
  # If the handling was to be delegated to expr_end,
1008
1008
  # these cases would transition to something else than
1009
- # expr_end, which is undesirable.
1009
+ # expr_endfn, which is incorrect.
1010
1010
  operator_fname |
1011
1011
  operator_arithmetic |
1012
1012
  operator_rest
@@ -1519,13 +1519,12 @@ class Parser::Lexer
1519
1519
  #
1520
1520
  expr_value := |*
1521
1521
  # a:b: a(:b), a::B, A::B
1522
- bareword ':'
1523
- => { p = @ts - 1
1522
+ bareword ':' (c_any - ':')
1523
+ => { p = @ts - 2
1524
1524
  fgoto expr_end; };
1525
1525
 
1526
1526
  # TODO whitespace rule
1527
1527
  c_space;
1528
- e_heredoc_nl;
1529
1528
 
1530
1529
  c_any
1531
1530
  => { fhold; fgoto expr_beg; };
@@ -4,16 +4,23 @@ module Parser
4
4
 
5
5
  # Like #advance, but also pretty-print the token and its position
6
6
  # in the stream to `stdout`.
7
- def advance_and_explain
8
- type, (val, range) = advance
7
+ def advance
8
+ type, (val, range) = super
9
9
 
10
10
  puts decorate(range,
11
11
  "\e[0;32m#{type} #{val.inspect}\e[0m",
12
- "#{state.to_s.ljust(10)} #{@cond} #{@cmdarg}\e[0m")
12
+ "#{state.to_s.ljust(12)} #{@cond} #{@cmdarg}\e[0m")
13
13
 
14
14
  [ type, [val, range] ]
15
15
  end
16
16
 
17
+ def state=(new_state)
18
+ puts " \e[1;33m>>> STATE SET <<<\e[0m " +
19
+ "#{new_state.to_s.ljust(12)} #{@cond} #{@cmdarg}".rjust(66)
20
+
21
+ super
22
+ end
23
+
17
24
  private
18
25
 
19
26
  def decorate(range, token, info)
@@ -32,6 +39,4 @@ module Parser
32
39
 
33
40
  end
34
41
 
35
- Lexer.send :include, Lexer::Explanation
36
-
37
42
  end
@@ -1881,8 +1881,6 @@ keyword_variable: kNIL
1881
1881
  | f_args term
1882
1882
  {
1883
1883
  result = @builder.args(nil, val[0], nil)
1884
-
1885
- @lexer.state = :expr_value
1886
1884
  }
1887
1885
 
1888
1886
  f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_f_block_arg
@@ -1987,8 +1987,6 @@ keyword_variable: kNIL
1987
1987
  | f_args term
1988
1988
  {
1989
1989
  result = @builder.args(nil, val[0], nil)
1990
-
1991
- @lexer.state = :expr_value
1992
1990
  }
1993
1991
 
1994
1992
  args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -1988,8 +1988,6 @@ keyword_variable: kNIL
1988
1988
  | f_args term
1989
1989
  {
1990
1990
  result = @builder.args(nil, val[0], nil)
1991
-
1992
- @lexer.state = :expr_value
1993
1991
  }
1994
1992
 
1995
1993
  args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
@@ -107,11 +107,7 @@ module Parser
107
107
  @slop.on 'E', 'explain', 'Explain how the source is tokenized' do
108
108
  ENV['RACC_DEBUG'] = '1'
109
109
 
110
- Parser::Base.class_eval do
111
- def next_token
112
- @lexer.advance_and_explain
113
- end
114
- end
110
+ Lexer.send :prepend, Lexer::Explanation
115
111
  end
116
112
  end
117
113
 
@@ -1,3 +1,3 @@
1
1
  module Parser
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end
@@ -71,7 +71,13 @@ module ParseHelper
71
71
  source_file = Parser::Source::Buffer.new('(assert_parses)')
72
72
  source_file.source = code
73
73
 
74
- parsed_ast = parser.parse(source_file)
74
+ begin
75
+ parsed_ast = parser.parse(source_file)
76
+ rescue => exc
77
+ new_exc = exc.class.new("(#{version}) #{exc.message}")
78
+ new_exc.set_backtrace(exc.backtrace)
79
+ raise new_exc
80
+ end
75
81
 
76
82
  assert_equal ast, parsed_ast,
77
83
  "(#{version}) AST equality"
@@ -2168,6 +2168,16 @@ class TestLexer < MiniTest::Unit::TestCase
2168
2168
  :tREGEXP_OPT, "")
2169
2169
  end
2170
2170
 
2171
+ def test_bug_expr_beg_heredoc
2172
+ util_lex_token("<<EOL % [\nfoo\nEOL\n]",
2173
+ :tSTRING_BEG, '"',
2174
+ :tSTRING_CONTENT, "foo\n",
2175
+ :tSTRING_END, 'EOL',
2176
+ :tPERCENT, '%',
2177
+ :tLBRACK, '[',
2178
+ :tRBRACK, ']')
2179
+ end
2180
+
2171
2181
  def test_bug_expr_arg_percent
2172
2182
  @lex.state = :expr_arg
2173
2183
  util_lex_token("%[",
@@ -2286,6 +2296,12 @@ class TestLexer < MiniTest::Unit::TestCase
2286
2296
  :tIDENTIFIER, 'print')
2287
2297
  end
2288
2298
 
2299
+ def test_bug_expr_value_document
2300
+ util_lex_token("1;\n=begin\n=end",
2301
+ :tINTEGER, 1,
2302
+ :tSEMI, ";")
2303
+ end
2304
+
2289
2305
  def test_bug_expr_end_colon
2290
2306
  util_lex_token("'foo':'bar'",
2291
2307
  :tSTRING, 'foo',
@@ -2303,14 +2319,12 @@ class TestLexer < MiniTest::Unit::TestCase
2303
2319
  :tNL, nil)
2304
2320
  end
2305
2321
 
2306
- def test_bug_expr_beg_heredoc
2307
- util_lex_token("<<EOL % [\nfoo\nEOL\n]",
2308
- :tSTRING_BEG, '"',
2309
- :tSTRING_CONTENT, "foo\n",
2310
- :tSTRING_END, 'EOL',
2311
- :tPERCENT, '%',
2312
- :tLBRACK, '[',
2313
- :tRBRACK, ']')
2322
+ def test_bug_expr_value_rescue_colon2
2323
+ @lex.state = :expr_value
2324
+ util_lex_token("rescue::Exception",
2325
+ :kRESCUE, 'rescue',
2326
+ :tCOLON3, '::',
2327
+ :tCONSTANT, 'Exception')
2314
2328
  end
2315
2329
 
2316
2330
  def test_bug_ragel_stack
@@ -4172,4 +4172,10 @@ class TestParser < MiniTest::Unit::TestCase
4172
4172
  s(:array, s(:dstr, s(:int, 1))),
4173
4173
  %q{%W"#{1}"})
4174
4174
  end
4175
+
4176
+ def test_bug_def_no_paren_eql_begin
4177
+ assert_parses(
4178
+ s(:def, :foo, s(:args), s(:nil)),
4179
+ %Q{def foo\n=begin\n=end\nend})
4180
+ end
4175
4181
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Zotov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-26 00:00:00.000000000 Z
11
+ date: 2013-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast