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 +4 -4
- data/lib/parser/lexer.rl +3 -4
- data/lib/parser/lexer/explanation.rb +10 -5
- data/lib/parser/ruby19.y +0 -2
- data/lib/parser/ruby20.y +0 -2
- data/lib/parser/ruby21.y +0 -2
- data/lib/parser/runner/ruby_parse.rb +1 -5
- data/lib/parser/version.rb +1 -1
- data/test/parse_helper.rb +7 -1
- data/test/test_lexer.rb +22 -8
- data/test/test_parser.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bf5ac94c180841ed95eb91426eb5925a01cec77
|
4
|
+
data.tar.gz: cf273795bd07e59f5dc23721435782d01579a287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bae46f95f8443fc99fdb681a8ef7d6aeb03dd7effc3cd214aab37e72da007e701c830a780c8898672c5be5250a21cf768010921018171e73ee9659b4839b57c
|
7
|
+
data.tar.gz: e3d932d2f489a690d1f3cf0535820288d8b8af1f0c7d00d41f48eaec79c69853a7e28d9fcc58718218b493fea0acf1d899f5b2a79b6ee7bb22c681c04dd2fe89
|
data/lib/parser/lexer.rl
CHANGED
@@ -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
|
-
#
|
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 -
|
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
|
8
|
-
type, (val, range) =
|
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(
|
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
|
data/lib/parser/ruby19.y
CHANGED
data/lib/parser/ruby20.y
CHANGED
data/lib/parser/ruby21.y
CHANGED
@@ -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
|
-
|
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
|
|
data/lib/parser/version.rb
CHANGED
data/test/parse_helper.rb
CHANGED
@@ -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
|
-
|
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"
|
data/test/test_lexer.rb
CHANGED
@@ -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
|
2307
|
-
|
2308
|
-
|
2309
|
-
:
|
2310
|
-
:
|
2311
|
-
:
|
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
|
data/test/test_parser.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|