yap-shell-parser 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yap/shell/parser/lexer.rb +11 -9
- data/lib/yap/shell/parser/version.rb +1 -1
- data/spec/yap/shell/lexer_spec.rb +6 -6
- data/spec/yap/shell/parser_spec.rb +1 -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: c452309759a871f7506451fd55282318434a5b25
|
4
|
+
data.tar.gz: 7a9aed6543577d6c8e9b5244320d02877c2502a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8219284d09acbb0537f352b33c12aaf52fbd7418b8e3c2562443547fd0d30e012035a4dfe5c981b0ec5c07c797fdd6ec875c637122f99b98cca53db1c7ece7ba
|
7
|
+
data.tar.gz: c962d71ed8207bd23593a12bb4e9150d370914623a755411527e19fcbbd7515e9e668d5c058c6b4a9e9e9152d08719c84f0cbe3c5792b21d31213f86cf9a3f58
|
@@ -67,7 +67,7 @@ module Yap::Shell
|
|
67
67
|
|
68
68
|
LINE_CONTINUATION = /.*\\\Z/
|
69
69
|
|
70
|
-
SPLIT_BLOCK_PARAMS_RGX = /\s*,\s
|
70
|
+
SPLIT_BLOCK_PARAMS_RGX = /\s*,\s*/
|
71
71
|
|
72
72
|
# Loop over the given input and yield command substitutions. This yields
|
73
73
|
# an object that responds to #str, and #position.
|
@@ -168,10 +168,7 @@ module Yap::Shell
|
|
168
168
|
if md=@chunk.match(BLOCK_BEGIN)
|
169
169
|
@looking_for_args = false
|
170
170
|
token :BlockBegin, md[1]
|
171
|
-
|
172
|
-
params = md[2].split(SPLIT_BLOCK_PARAMS_RGX)
|
173
|
-
token :BlockParams, params
|
174
|
-
end
|
171
|
+
block_params_token(md[2])
|
175
172
|
md[0].length
|
176
173
|
elsif md=@chunk.match(BLOCK_END)
|
177
174
|
@looking_for_args = false
|
@@ -182,6 +179,13 @@ module Yap::Shell
|
|
182
179
|
end
|
183
180
|
end
|
184
181
|
|
182
|
+
def block_params_token(string)
|
183
|
+
if string
|
184
|
+
params = string.split(SPLIT_BLOCK_PARAMS_RGX).map(&:strip)
|
185
|
+
token :BlockParams, params
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
185
189
|
def comment_token
|
186
190
|
if md=@chunk.match(COMMENT)
|
187
191
|
token :Comment, md[0]
|
@@ -208,8 +212,7 @@ module Yap::Shell
|
|
208
212
|
start, stop = md[2].to_i, md[3].to_i
|
209
213
|
token :Range, (start..stop)
|
210
214
|
token :BlockBegin, '{'
|
211
|
-
|
212
|
-
token :BlockParams, params
|
215
|
+
block_params_token(md[4])
|
213
216
|
@tokens_to_add_when_done << [:BlockEnd, '}']
|
214
217
|
md[0].length
|
215
218
|
|
@@ -224,8 +227,7 @@ module Yap::Shell
|
|
224
227
|
start, stop = 1, md[2].to_i
|
225
228
|
token :Range, (start..stop)
|
226
229
|
token :BlockBegin, '{'
|
227
|
-
|
228
|
-
token :BlockParams, params
|
230
|
+
block_params_token(md[4])
|
229
231
|
@tokens_to_add_when_done << [:BlockEnd, '}']
|
230
232
|
md[0].length
|
231
233
|
|
@@ -97,31 +97,31 @@ describe Yap::Shell::Parser::Lexer do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
describe "can take block params" do
|
100
|
-
describe "ls { |
|
100
|
+
describe "ls { |param1| this_is_a_block }" do
|
101
101
|
it { should eq [
|
102
102
|
t(:Command, "ls", lineno:0),
|
103
103
|
t(:BlockBegin, '{', lineno: 0),
|
104
|
-
t(:BlockParams, ['
|
104
|
+
t(:BlockParams, ['param1'], lineno: 0),
|
105
105
|
t(:Command, "this_is_a_block", lineno:0),
|
106
106
|
t(:BlockEnd, '}', lineno: 0)
|
107
107
|
]}
|
108
108
|
end
|
109
109
|
|
110
|
-
describe "ls { |
|
110
|
+
describe "ls { |param1,b| this_is_a_block }" do
|
111
111
|
it { should eq [
|
112
112
|
t(:Command, "ls", lineno:0),
|
113
113
|
t(:BlockBegin, '{', lineno: 0),
|
114
|
-
t(:BlockParams, ['
|
114
|
+
t(:BlockParams, ['param1', 'b'], lineno: 0),
|
115
115
|
t(:Command, "this_is_a_block", lineno:0),
|
116
116
|
t(:BlockEnd, '}', lineno: 0)
|
117
117
|
]}
|
118
118
|
end
|
119
119
|
|
120
|
-
describe "ls { |
|
120
|
+
describe "ls { |a1, b2, c3| this_is_a_block }" do
|
121
121
|
it { should eq [
|
122
122
|
t(:Command, "ls", lineno:0),
|
123
123
|
t(:BlockBegin, '{', lineno: 0),
|
124
|
-
t(:BlockParams, ['
|
124
|
+
t(:BlockParams, ['a1', 'b2', 'c3'], lineno: 0),
|
125
125
|
t(:Command, "this_is_a_block", lineno:0),
|
126
126
|
t(:BlockEnd, '}', lineno: 0)
|
127
127
|
]}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yap-shell-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Dennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treefell
|