ruby_parser 3.0.0.a8 → 3.0.0.a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ruby_parser might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/.autotest +6 -0
- data/History.txt +40 -0
- data/README.txt +6 -11
- data/Rakefile +5 -0
- data/bin/ruby_parse_extract_error +23 -6
- data/lib/ruby18_parser.rb +18 -8
- data/lib/ruby18_parser.y +18 -8
- data/lib/ruby19_parser.rb +67 -35
- data/lib/ruby19_parser.y +62 -32
- data/lib/ruby_lexer.rb +84 -95
- data/lib/ruby_parser_extras.rb +140 -20
- data/test/test_ruby_lexer.rb +58 -3
- data/test/test_ruby_parser.rb +193 -2
- data/test/test_ruby_parser_extras.rb +109 -0
- metadata +17 -22
- metadata.gz.sig +5 -2
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
|
1
3
|
require 'rubygems'
|
2
4
|
gem "minitest"
|
3
5
|
require 'minitest/autorun'
|
@@ -12,6 +14,113 @@ class TestStackState < MiniTest::Unit::TestCase
|
|
12
14
|
@s = RubyParserStuff::StackState.new :test
|
13
15
|
end
|
14
16
|
|
17
|
+
def assert_encoding str, default = false
|
18
|
+
orig_str = str.dup
|
19
|
+
p = Ruby19Parser.new
|
20
|
+
s = nil
|
21
|
+
|
22
|
+
out, err = capture_io do
|
23
|
+
s = p.handle_encoding str
|
24
|
+
end
|
25
|
+
|
26
|
+
assert_equal orig_str.sub(/\357\273\277/, ''), s
|
27
|
+
|
28
|
+
exp_err = ""
|
29
|
+
|
30
|
+
if defined?(Encoding) then
|
31
|
+
assert_equal "UTF-8", s.encoding.to_s, str.inspect
|
32
|
+
else
|
33
|
+
exp_err = "Skipping magic encoding comment\n" unless default
|
34
|
+
end
|
35
|
+
|
36
|
+
assert_equal "", out, str.inspect
|
37
|
+
assert_equal exp_err, err, str.inspect # HACK
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_handle_encoding_bom
|
41
|
+
# bom support, default to utf-8
|
42
|
+
assert_encoding "\xEF\xBB\xBF# blah"
|
43
|
+
# we force_encode to US-ASCII, then encode to UTF-8 so our lexer will work
|
44
|
+
assert_encoding "\xEF\xBB\xBF# encoding: US-ASCII"
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_handle_encoding_default
|
48
|
+
assert_encoding "blah", :default
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_handle_encoding_emacs
|
52
|
+
# Q: how many different ways can we screw these up? A: ALL OF THEM
|
53
|
+
|
54
|
+
assert_encoding "# - encoding: utf-8 -"
|
55
|
+
assert_encoding "# - encoding:utf-8"
|
56
|
+
assert_encoding "# -* coding: UTF-8 -*-"
|
57
|
+
assert_encoding "# -*- coding: UTF-8 -*-"
|
58
|
+
assert_encoding "# -*- coding: utf-8 -*"
|
59
|
+
assert_encoding "# -*- coding: utf-8 -*-"
|
60
|
+
assert_encoding "# -*- coding: utf-8; mode: ruby -*-"
|
61
|
+
assert_encoding "# -*- coding: utf-8; mode: ruby; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2"
|
62
|
+
assert_encoding "# -*- coding:utf-8; mode:ruby; -*-"
|
63
|
+
assert_encoding "# -*- encoding: UTF-8 -*-"
|
64
|
+
assert_encoding "# -*- encoding: utf-8 -*"
|
65
|
+
assert_encoding "# -*- encoding: utf-8 -*-"
|
66
|
+
assert_encoding "# -*- mode:ruby; coding:utf-8 -*-"
|
67
|
+
assert_encoding "# -*- ruby encoding: utf-8 -*-"
|
68
|
+
assert_encoding "# -- encoding: utf-8 --"
|
69
|
+
assert_encoding "# ~*~ encoding: utf-8 ~*~"
|
70
|
+
assert_encoding "#-*- coding: utf-8 -*-"
|
71
|
+
assert_encoding "#-*- coding:utf-8"
|
72
|
+
assert_encoding "#-- -*- mode: ruby; encoding: utf-8 -*-\n"
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_handle_encoding_wtf
|
76
|
+
assert_encoding "# coding : utf-8"
|
77
|
+
assert_encoding "# Ruby 1.9: encoding: utf-8"
|
78
|
+
assert_encoding "# Encoding: UTF-8 <-- required, please leave this in."
|
79
|
+
assert_encoding "# Encoding: UTF-8"
|
80
|
+
assert_encoding "# coding: utf-8"
|
81
|
+
assert_encoding "# coding:utf-8"
|
82
|
+
assert_encoding "# coding=utf-8"
|
83
|
+
assert_encoding "# encoding: ASCII"
|
84
|
+
assert_encoding "# encoding: ASCII-8BIT"
|
85
|
+
assert_encoding "# encoding: ISO-8859-1"
|
86
|
+
assert_encoding "# encoding: UTF-8"
|
87
|
+
assert_encoding "# encoding: ascii-8bit"
|
88
|
+
assert_encoding "# encoding: cp1252"
|
89
|
+
assert_encoding "# encoding: euc-jp -*-"
|
90
|
+
assert_encoding "# encoding: utf-8 # -*- ruby -*-"
|
91
|
+
assert_encoding "# encoding: utf-8 require 'github_api/utils/url'"
|
92
|
+
assert_encoding "# encoding: utf-8!"
|
93
|
+
assert_encoding "# encoding: utf-8"
|
94
|
+
assert_encoding "#<Encoding:UTF-8>"
|
95
|
+
assert_encoding "#Encoding: UTF-8"
|
96
|
+
assert_encoding "#coding:utf-8"
|
97
|
+
assert_encoding "#encoding: UTF-8!"
|
98
|
+
assert_encoding "#encoding: UTF-8"
|
99
|
+
assert_encoding "#encoding: cp1252"
|
100
|
+
assert_encoding "#encoding: sjis"
|
101
|
+
assert_encoding "#encoding: utf-8"
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_handle_encoding_normal
|
105
|
+
assert_encoding "# encoding: UTF-8"
|
106
|
+
assert_encoding "# encoding: UTF-8\r\n" # UGH I hate windoze
|
107
|
+
assert_encoding "# coding: UTF-8"
|
108
|
+
assert_encoding "# encoding = UTF-8"
|
109
|
+
assert_encoding "# coding = UTF-8"
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_handle_encoding_vim
|
113
|
+
assert_encoding "# vim: set fileencoding=utf-8 filetype=ruby ts=2 : "
|
114
|
+
assert_encoding "# vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si"
|
115
|
+
assert_encoding "# vim: fileencoding=UTF-8 nobomb sw=2 ts=2 et"
|
116
|
+
assert_encoding "# vim: filetype=ruby, fileencoding=UTF-8, tabsize=2, shiftwidth=2"
|
117
|
+
assert_encoding "# vim: set fileencoding=utf-8"
|
118
|
+
assert_encoding "# vim:encoding=UTF-8:"
|
119
|
+
assert_encoding "# vim:fileencoding=UTF-8:"
|
120
|
+
assert_encoding "# vim:set fileencoding=utf-8 filetype=ruby"
|
121
|
+
assert_encoding "# vim:set fileencoding=utf-8:"
|
122
|
+
end
|
123
|
+
|
15
124
|
def test_stack_state
|
16
125
|
s.push true
|
17
126
|
s.push false
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 2793290959
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- a
|
11
|
-
-
|
12
|
-
version: 3.0.0.
|
11
|
+
- 9
|
12
|
+
version: 3.0.0.a9
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Ryan Davis
|
@@ -38,7 +38,7 @@ cert_chain:
|
|
38
38
|
FBHgymkyj/AOSqKRIpXPhjC6
|
39
39
|
-----END CERTIFICATE-----
|
40
40
|
|
41
|
-
date: 2012-
|
41
|
+
date: 2012-10-22 00:00:00 Z
|
42
42
|
dependencies:
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: sexp_processor
|
@@ -63,11 +63,11 @@ dependencies:
|
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
hash:
|
66
|
+
hash: 25
|
67
67
|
segments:
|
68
|
-
-
|
69
|
-
-
|
70
|
-
version: "
|
68
|
+
- 4
|
69
|
+
- 1
|
70
|
+
version: "4.1"
|
71
71
|
type: :development
|
72
72
|
version_requirements: *id002
|
73
73
|
- !ruby/object:Gem::Dependency
|
@@ -109,11 +109,11 @@ dependencies:
|
|
109
109
|
requirements:
|
110
110
|
- - ~>
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
hash:
|
112
|
+
hash: 5
|
113
113
|
segments:
|
114
114
|
- 3
|
115
|
-
-
|
116
|
-
version: "3.
|
115
|
+
- 1
|
116
|
+
version: "3.1"
|
117
117
|
type: :development
|
118
118
|
version_requirements: *id005
|
119
119
|
description: |-
|
@@ -124,24 +124,19 @@ description: |-
|
|
124
124
|
|
125
125
|
As an example:
|
126
126
|
|
127
|
-
def conditional1
|
128
|
-
if arg1 == 0
|
129
|
-
return 1
|
130
|
-
end
|
127
|
+
def conditional1 arg1
|
128
|
+
return 1 if arg1 == 0
|
131
129
|
return 0
|
132
130
|
end
|
133
131
|
|
134
132
|
becomes:
|
135
133
|
|
136
|
-
s(:defn, :conditional1,
|
137
|
-
|
138
|
-
|
139
|
-
s(:block,
|
140
|
-
s(:if,
|
141
|
-
s(:call, s(:lvar, :arg1), :==, s(:arglist, s(:lit, 0))),
|
134
|
+
s(:defn, :conditional1, s(:args, :arg1),
|
135
|
+
s(:if,
|
136
|
+
s(:call, s(:lvar, :arg1), :==, s(:lit, 0)),
|
142
137
|
s(:return, s(:lit, 1)),
|
143
138
|
nil),
|
144
|
-
|
139
|
+
s(:return, s(:lit, 0)))
|
145
140
|
email:
|
146
141
|
- ryand-ruby@zenspider.com
|
147
142
|
executables:
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
14난r/�W2�ńĕ�y����6ڷ\��a���n�z^����Λ�?�l�ԑGI "�S����P�Pk�T��5���+կ�
|
2
|
+
�*Y��f*I��p���~�"�%�j:�y��+QSE���Խ��tܽ�|í���
|
3
|
+
��|��m���lY��j�!�\��X�m��+wj��k�l�b��jr��
|
4
|
+
0#qx��ga/t1X5:�����~�B$5��:
|
5
|
+
��e��_�v�v� 7B0=���k��Vf
|