yap-shell-parser 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +3 -0
- data/bin/compile_debug_parser +3 -0
- data/bin/compile_parser +3 -0
- data/lib/tasks/gem.rake +60 -0
- data/lib/yap/shell.rb +2 -0
- data/lib/yap/shell/parser.rb +381 -0
- data/lib/yap/shell/parser/grammar.y +151 -0
- data/lib/yap/shell/parser/lexer.rb +311 -0
- data/lib/yap/shell/parser/nodes.rb +205 -0
- data/lib/yap/shell/parser/version.rb +5 -0
- data/spec/spec_helper.rb +91 -0
- data/spec/yap/shell/lexer_spec.rb +697 -0
- data/yap-shell-parser.gemspec +25 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d22f0856a5b1b260c5d9ade076db5d0ec84ed0d3
|
4
|
+
data.tar.gz: d7281d94d9473c1eee9c98de6e309395cfa21352
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 99bd043d5beb4791c874c695cd73f2178826e3b976729412e8658116d3b45554f6dfea34230ac45c027f08d396320c78f808f57c51ae05de47242354ed71f37a
|
7
|
+
data.tar.gz: 277240948738b082d8da1bc74253be78c4a6128f4f894024e3cc03be538600fef50f9baa4887fddd6ecbb8e40970b7e99da221fa9f19ffa5139f3c8f671620d1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Zach Dennis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
[](https://travis-ci.org/zdennis/yap-shell-parser)
|
2
|
+
|
3
|
+
# Yap::Shell::Parser
|
4
|
+
|
5
|
+
The yap-shell-parser is the input parser for the yap-shell.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'yap-shell-parser'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install yap-shell-parser
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( https://github.com/[my-github-username]/yap-shell-parser/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/compile_parser
ADDED
data/lib/tasks/gem.rake
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
namespace :bump do
|
2
|
+
namespace :version do
|
3
|
+
class ProjectVersion
|
4
|
+
FILE = File.dirname(__FILE__) + '/../yap/shell/parser/version.rb'
|
5
|
+
PATTERN = /VERSION\s*=\s*"(\d+)\.(\d+)\.(\d+)"/m
|
6
|
+
|
7
|
+
def initialize(file=FILE, pattern=PATTERN)
|
8
|
+
@file = file
|
9
|
+
@pattern = pattern
|
10
|
+
end
|
11
|
+
|
12
|
+
def bump(major:nil, minor:nil, patch:nil)
|
13
|
+
version = nil
|
14
|
+
contents.sub!(@pattern) do
|
15
|
+
_major = major.call($1) if major
|
16
|
+
_minor = minor.call($2) if minor
|
17
|
+
_patch = patch.call($3) if patch
|
18
|
+
version = %|VERSION = "#{_major}.#{_minor}.#{_patch}"|
|
19
|
+
end
|
20
|
+
File.write(@file, contents)
|
21
|
+
system "bundle"
|
22
|
+
system "git add #{ProjectVersion::FILE} && git commit -m 'Bumping version to #{version}'"
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def contents
|
28
|
+
@contents ||= File.read(@file)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Increments the patch number by 1 for the project"
|
33
|
+
task :patch do
|
34
|
+
ProjectVersion.new.bump(
|
35
|
+
major: ->(major){ major },
|
36
|
+
minor: ->(minor){ minor },
|
37
|
+
patch: ->(patch){ patch.succ }
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Increments the minor number by 1 for the project"
|
42
|
+
task :minor do
|
43
|
+
ProjectVersion.new.bump(
|
44
|
+
major: ->(major){ major },
|
45
|
+
minor: ->(minor){ minor.succ },
|
46
|
+
patch: ->(patch){ 0 }
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Increments the major number by 1 for the project"
|
51
|
+
task :major do
|
52
|
+
ProjectVersion.new.bump(
|
53
|
+
major: ->(major){ major.succ },
|
54
|
+
minor: ->(minor){ 0 },
|
55
|
+
patch: ->(patch){ 0 }
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
data/lib/yap/shell.rb
ADDED
@@ -0,0 +1,381 @@
|
|
1
|
+
#
|
2
|
+
# DO NOT MODIFY!!!!
|
3
|
+
# This file is automatically generated by Racc 1.4.9
|
4
|
+
# from Racc grammer file "".
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'racc/parser.rb'
|
8
|
+
module Yap
|
9
|
+
module Shell
|
10
|
+
class Parser < Racc::Parser
|
11
|
+
|
12
|
+
module_eval(<<'...end grammar.y/module_eval...', 'grammar.y', 80)
|
13
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../../"
|
14
|
+
require 'yap/shell/parser/lexer'
|
15
|
+
require 'yap/shell/parser/nodes'
|
16
|
+
|
17
|
+
include Yap::Shell::Parser::Nodes
|
18
|
+
|
19
|
+
def parse(str)
|
20
|
+
# @yydebug = true
|
21
|
+
|
22
|
+
@q = Yap::Shell::Parser::Lexer.new.tokenize(str)
|
23
|
+
# @q.push [false, '$'] # is optional from Racc 1.3.7
|
24
|
+
# puts @q.inspect
|
25
|
+
# puts "---- parse tree follows ----"
|
26
|
+
__send__(Racc_Main_Parsing_Routine, _racc_setup(), false)
|
27
|
+
#do_parse
|
28
|
+
end
|
29
|
+
|
30
|
+
def next_token
|
31
|
+
@q.shift
|
32
|
+
end
|
33
|
+
|
34
|
+
...end grammar.y/module_eval...
|
35
|
+
##### State transition tables begin ###
|
36
|
+
|
37
|
+
racc_action_table = [
|
38
|
+
15, 16, 29, 23, 17, 29, 15, 16, 24, 13,
|
39
|
+
17, 6, 15, 16, 27, 13, 17, 6, 15, 16,
|
40
|
+
31, 13, 17, 6, 15, 16, 21, 13, 17, 6,
|
41
|
+
15, 16, 20, 13, 19, 6, 19, 18, 36, 26,
|
42
|
+
37, 35, 37, 20, 21 ]
|
43
|
+
|
44
|
+
racc_action_check = [
|
45
|
+
0, 0, 16, 9, 0, 15, 6, 6, 9, 0,
|
46
|
+
6, 0, 21, 21, 13, 6, 21, 6, 20, 20,
|
47
|
+
18, 21, 20, 21, 19, 19, 4, 20, 19, 20,
|
48
|
+
12, 12, 3, 19, 22, 19, 2, 1, 26, 12,
|
49
|
+
28, 22, 30, 32, 33 ]
|
50
|
+
|
51
|
+
racc_action_pointer = [
|
52
|
+
-2, 37, 29, 24, 17, nil, 4, nil, nil, -2,
|
53
|
+
nil, nil, 28, 2, nil, 1, -2, nil, 20, 22,
|
54
|
+
16, 10, 27, nil, nil, nil, 26, nil, 36, nil,
|
55
|
+
38, nil, 35, 35, nil, nil, nil, nil ]
|
56
|
+
|
57
|
+
racc_action_default = [
|
58
|
+
-28, -28, -1, -3, -5, -7, -28, -9, -10, -12,
|
59
|
+
-14, -15, -16, -28, -20, -21, -23, -27, -28, -28,
|
60
|
+
-28, -28, -28, -11, -13, -17, -28, -19, -22, -25,
|
61
|
+
-24, 38, -2, -4, -6, -8, -18, -26 ]
|
62
|
+
|
63
|
+
racc_goto_table = [
|
64
|
+
2, 28, 30, 33, 32, 34, 22, 25, 1 ]
|
65
|
+
|
66
|
+
racc_goto_check = [
|
67
|
+
2, 13, 13, 4, 3, 5, 2, 10, 1 ]
|
68
|
+
|
69
|
+
racc_goto_pointer = [
|
70
|
+
nil, 8, 0, -15, -17, -16, nil, nil, nil, nil,
|
71
|
+
-5, nil, nil, -14 ]
|
72
|
+
|
73
|
+
racc_goto_default = [
|
74
|
+
nil, nil, nil, 3, 4, 5, 7, 8, 9, 10,
|
75
|
+
11, 12, 14, nil ]
|
76
|
+
|
77
|
+
racc_reduce_table = [
|
78
|
+
0, 0, :racc_error,
|
79
|
+
1, 16, :_reduce_none,
|
80
|
+
3, 17, :_reduce_2,
|
81
|
+
1, 17, :_reduce_3,
|
82
|
+
3, 18, :_reduce_4,
|
83
|
+
1, 18, :_reduce_none,
|
84
|
+
3, 19, :_reduce_6,
|
85
|
+
1, 19, :_reduce_none,
|
86
|
+
3, 20, :_reduce_8,
|
87
|
+
1, 20, :_reduce_none,
|
88
|
+
1, 20, :_reduce_none,
|
89
|
+
2, 21, :_reduce_11,
|
90
|
+
1, 21, :_reduce_none,
|
91
|
+
2, 23, :_reduce_13,
|
92
|
+
1, 23, :_reduce_none,
|
93
|
+
1, 23, :_reduce_none,
|
94
|
+
1, 23, :_reduce_none,
|
95
|
+
2, 24, :_reduce_17,
|
96
|
+
3, 26, :_reduce_18,
|
97
|
+
2, 26, :_reduce_19,
|
98
|
+
1, 25, :_reduce_none,
|
99
|
+
1, 27, :_reduce_21,
|
100
|
+
2, 27, :_reduce_22,
|
101
|
+
1, 27, :_reduce_23,
|
102
|
+
2, 27, :_reduce_24,
|
103
|
+
1, 28, :_reduce_25,
|
104
|
+
2, 28, :_reduce_26,
|
105
|
+
1, 22, :_reduce_27 ]
|
106
|
+
|
107
|
+
racc_reduce_n = 28
|
108
|
+
|
109
|
+
racc_shift_n = 38
|
110
|
+
|
111
|
+
racc_token_table = {
|
112
|
+
false => 0,
|
113
|
+
:error => 1,
|
114
|
+
:Command => 2,
|
115
|
+
:LiteralCommand => 3,
|
116
|
+
:Argument => 4,
|
117
|
+
:Heredoc => 5,
|
118
|
+
:InternalEval => 6,
|
119
|
+
:Separator => 7,
|
120
|
+
:Conditional => 8,
|
121
|
+
:Pipe => 9,
|
122
|
+
:Redirection => 10,
|
123
|
+
:LValue => 11,
|
124
|
+
:RValue => 12,
|
125
|
+
"(" => 13,
|
126
|
+
")" => 14 }
|
127
|
+
|
128
|
+
racc_nt_base = 15
|
129
|
+
|
130
|
+
racc_use_result_var = true
|
131
|
+
|
132
|
+
Racc_arg = [
|
133
|
+
racc_action_table,
|
134
|
+
racc_action_check,
|
135
|
+
racc_action_default,
|
136
|
+
racc_action_pointer,
|
137
|
+
racc_goto_table,
|
138
|
+
racc_goto_check,
|
139
|
+
racc_goto_default,
|
140
|
+
racc_goto_pointer,
|
141
|
+
racc_nt_base,
|
142
|
+
racc_reduce_table,
|
143
|
+
racc_token_table,
|
144
|
+
racc_shift_n,
|
145
|
+
racc_reduce_n,
|
146
|
+
racc_use_result_var ]
|
147
|
+
|
148
|
+
Racc_token_to_s_table = [
|
149
|
+
"$end",
|
150
|
+
"error",
|
151
|
+
"Command",
|
152
|
+
"LiteralCommand",
|
153
|
+
"Argument",
|
154
|
+
"Heredoc",
|
155
|
+
"InternalEval",
|
156
|
+
"Separator",
|
157
|
+
"Conditional",
|
158
|
+
"Pipe",
|
159
|
+
"Redirection",
|
160
|
+
"LValue",
|
161
|
+
"RValue",
|
162
|
+
"\"(\"",
|
163
|
+
"\")\"",
|
164
|
+
"$start",
|
165
|
+
"program",
|
166
|
+
"stmts",
|
167
|
+
"stmt",
|
168
|
+
"pipeline",
|
169
|
+
"stmts2",
|
170
|
+
"command_w_heredoc",
|
171
|
+
"internal_eval",
|
172
|
+
"command_w_redirects",
|
173
|
+
"command_w_vars",
|
174
|
+
"command",
|
175
|
+
"vars",
|
176
|
+
"command2",
|
177
|
+
"args" ]
|
178
|
+
|
179
|
+
Racc_debug_parser = false
|
180
|
+
|
181
|
+
##### State transition tables end #####
|
182
|
+
|
183
|
+
# reduce 0 omitted
|
184
|
+
|
185
|
+
# reduce 1 omitted
|
186
|
+
|
187
|
+
module_eval(<<'.,.,', 'grammar.y', 23)
|
188
|
+
def _reduce_2(val, _values, result)
|
189
|
+
result = StatementsNode.new(val[0], val[2])
|
190
|
+
result
|
191
|
+
end
|
192
|
+
.,.,
|
193
|
+
|
194
|
+
module_eval(<<'.,.,', 'grammar.y', 25)
|
195
|
+
def _reduce_3(val, _values, result)
|
196
|
+
result = StatementsNode.new(val[0])
|
197
|
+
result
|
198
|
+
end
|
199
|
+
.,.,
|
200
|
+
|
201
|
+
module_eval(<<'.,.,', 'grammar.y', 28)
|
202
|
+
def _reduce_4(val, _values, result)
|
203
|
+
result = ConditionalNode.new(val[1].value, val[0], val[2])
|
204
|
+
result
|
205
|
+
end
|
206
|
+
.,.,
|
207
|
+
|
208
|
+
# reduce 5 omitted
|
209
|
+
|
210
|
+
module_eval(<<'.,.,', 'grammar.y', 32)
|
211
|
+
def _reduce_6(val, _values, result)
|
212
|
+
result = PipelineNode.new(val[0], val[2])
|
213
|
+
result
|
214
|
+
end
|
215
|
+
.,.,
|
216
|
+
|
217
|
+
# reduce 7 omitted
|
218
|
+
|
219
|
+
module_eval(<<'.,.,', 'grammar.y', 36)
|
220
|
+
def _reduce_8(val, _values, result)
|
221
|
+
result = val[1]
|
222
|
+
result
|
223
|
+
end
|
224
|
+
.,.,
|
225
|
+
|
226
|
+
# reduce 9 omitted
|
227
|
+
|
228
|
+
# reduce 10 omitted
|
229
|
+
|
230
|
+
module_eval(<<'.,.,', 'grammar.y', 41)
|
231
|
+
def _reduce_11(val, _values, result)
|
232
|
+
val[0].heredoc = val[1] ; result = val[0]
|
233
|
+
result
|
234
|
+
end
|
235
|
+
.,.,
|
236
|
+
|
237
|
+
# reduce 12 omitted
|
238
|
+
|
239
|
+
module_eval(<<'.,.,', 'grammar.y', 45)
|
240
|
+
def _reduce_13(val, _values, result)
|
241
|
+
val[0].redirects << RedirectionNode.new(val[1].value, val[1].attrs[:target]) ; result = val[0]
|
242
|
+
result
|
243
|
+
end
|
244
|
+
.,.,
|
245
|
+
|
246
|
+
# reduce 14 omitted
|
247
|
+
|
248
|
+
# reduce 15 omitted
|
249
|
+
|
250
|
+
# reduce 16 omitted
|
251
|
+
|
252
|
+
module_eval(<<'.,.,', 'grammar.y', 51)
|
253
|
+
def _reduce_17(val, _values, result)
|
254
|
+
result = EnvWrapperNode.new(val[0], val[1])
|
255
|
+
result
|
256
|
+
end
|
257
|
+
.,.,
|
258
|
+
|
259
|
+
module_eval(<<'.,.,', 'grammar.y', 54)
|
260
|
+
def _reduce_18(val, _values, result)
|
261
|
+
val[0].add_var(val[1].value, val[2].value) ; result = val[0]
|
262
|
+
result
|
263
|
+
end
|
264
|
+
.,.,
|
265
|
+
|
266
|
+
module_eval(<<'.,.,', 'grammar.y', 56)
|
267
|
+
def _reduce_19(val, _values, result)
|
268
|
+
result = EnvNode.new(val[0].value, val[1].value)
|
269
|
+
result
|
270
|
+
end
|
271
|
+
.,.,
|
272
|
+
|
273
|
+
# reduce 20 omitted
|
274
|
+
|
275
|
+
module_eval(<<'.,.,', 'grammar.y', 61)
|
276
|
+
def _reduce_21(val, _values, result)
|
277
|
+
result = CommandNode.new(val[0].value)
|
278
|
+
result
|
279
|
+
end
|
280
|
+
.,.,
|
281
|
+
|
282
|
+
module_eval(<<'.,.,', 'grammar.y', 63)
|
283
|
+
def _reduce_22(val, _values, result)
|
284
|
+
result = CommandNode.new(val[0].value, val[1].flatten)
|
285
|
+
result
|
286
|
+
end
|
287
|
+
.,.,
|
288
|
+
|
289
|
+
module_eval(<<'.,.,', 'grammar.y', 65)
|
290
|
+
def _reduce_23(val, _values, result)
|
291
|
+
result = CommandNode.new(val[0].value, literal:true)
|
292
|
+
result
|
293
|
+
end
|
294
|
+
.,.,
|
295
|
+
|
296
|
+
module_eval(<<'.,.,', 'grammar.y', 67)
|
297
|
+
def _reduce_24(val, _values, result)
|
298
|
+
result = CommandNode.new(val[0].value, val[1].flatten, literal:true)
|
299
|
+
result
|
300
|
+
end
|
301
|
+
.,.,
|
302
|
+
|
303
|
+
module_eval(<<'.,.,', 'grammar.y', 70)
|
304
|
+
def _reduce_25(val, _values, result)
|
305
|
+
result = [val[0].value]
|
306
|
+
result
|
307
|
+
end
|
308
|
+
.,.,
|
309
|
+
|
310
|
+
module_eval(<<'.,.,', 'grammar.y', 72)
|
311
|
+
def _reduce_26(val, _values, result)
|
312
|
+
result = [val[0], val[1].value]
|
313
|
+
result
|
314
|
+
end
|
315
|
+
.,.,
|
316
|
+
|
317
|
+
module_eval(<<'.,.,', 'grammar.y', 75)
|
318
|
+
def _reduce_27(val, _values, result)
|
319
|
+
result = InternalEvalNode.new(val[0].value)
|
320
|
+
result
|
321
|
+
end
|
322
|
+
.,.,
|
323
|
+
|
324
|
+
def _reduce_none(val, _values, result)
|
325
|
+
val[0]
|
326
|
+
end
|
327
|
+
|
328
|
+
end # class Parser
|
329
|
+
end # module Shell
|
330
|
+
end # module Yap
|
331
|
+
|
332
|
+
|
333
|
+
if $0 == __FILE__
|
334
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../../"
|
335
|
+
require 'yap/shell/parser/lexer'
|
336
|
+
require 'yap/shell/parser/nodes'
|
337
|
+
[
|
338
|
+
# "echo foo",
|
339
|
+
# "echo foo ; echo bar baz yep",
|
340
|
+
# "echo foo && echo bar baz yep",
|
341
|
+
# "echo foo && echo bar && ls foo && ls bar",
|
342
|
+
# "echo foo ; echo bar baz yep ; ls foo",
|
343
|
+
# "echo foo && echo bar ; ls baz",
|
344
|
+
# "echo foo && echo bar ; ls baz ; echo zach || echo gretchen",
|
345
|
+
# "echo foo | bar",
|
346
|
+
# "echo foo | bar && foo | bar",
|
347
|
+
# "foo && bar ; word || baz ; yep | grep -v foo",
|
348
|
+
# "( foo )",
|
349
|
+
# "( foo a b && bar c d )",
|
350
|
+
# "( foo a b && (bar c d | baz e f))",
|
351
|
+
# "((((foo))))",
|
352
|
+
# "foo -b -c ; (this ;that ;the; other ;thing) && yep",
|
353
|
+
# "foo -b -c ; (this ;that && other ;thing) && yep",
|
354
|
+
# "4 + 5",
|
355
|
+
# "!'hello' ; 4 - 4 && 10 + 3",
|
356
|
+
# "\\foo <<-EOT\nbar\nEOT",
|
357
|
+
# "ls | grep md | grep WISH",
|
358
|
+
# "(!upcase)",
|
359
|
+
# "echo foo > bar.txt",
|
360
|
+
# "ls -l > a.txt ; echo f 2> b.txt ; cat b &> c.txt ; du -sh 1>&2 1>hey.txt",
|
361
|
+
# "!Dir.chdir('..')",
|
362
|
+
# "FOO=123",
|
363
|
+
# "FOO=123 BAR=345",
|
364
|
+
# "FOO=abc bar=2314 car=14ab ls -l",
|
365
|
+
"FOO=abc BAR='hello world' ls -l ; CAR=f echo foo && say hi"
|
366
|
+
].each do |src|
|
367
|
+
puts 'parsing:'
|
368
|
+
print src
|
369
|
+
puts
|
370
|
+
puts 'result:'
|
371
|
+
require 'pp'
|
372
|
+
ast = Yap::Shell::Parser.new.parse(src)
|
373
|
+
pp ast
|
374
|
+
end
|
375
|
+
|
376
|
+
|
377
|
+
# puts "---- Evaluating"
|
378
|
+
# require 'pry'
|
379
|
+
# binding.pry
|
380
|
+
# Evaluator.new.evaltree(ast)
|
381
|
+
end
|