Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ion
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Enzo Cioppettini
ion
Commits
4ac9b428
Commit
4ac9b428
authored
6 years ago
by
stratact
Browse files
Options
Downloads
Patches
Plain Diff
Add support for Multiple Indices in arrays (Fixes #472)
parent
1300013c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/arrays.ion
+6
-0
6 additions, 0 deletions
examples/arrays.ion
examples/arrays.out
+4
-0
4 additions, 0 deletions
examples/arrays.out
src/lib/parser/shell_expand/mod.rs
+24
-2
24 additions, 2 deletions
src/lib/parser/shell_expand/mod.rs
with
34 additions
and
2 deletions
examples/arrays.ion
+
6
−
0
View file @
4ac9b428
...
...
@@ -75,3 +75,9 @@ end
let array = [ 1 2 3 4 5 ]
let as_string = @array
echo $as_string
let array = [1 2 3 4 5 6 7 8 9 10]
echo @array[0 1 7..]
echo @array[2 3 5..]
echo @array[5.. 3 2]
echo @array[5..8 1..3 9 2]
This diff is collapsed.
Click to expand it.
examples/arrays.out
+
4
−
0
View file @
4ac9b428
...
...
@@ -54,3 +54,7 @@ a b c d e
😉
😉
1 2 3 4 5
1 2 8 9 10
3 4 6 7 8 9 10
6 7 8 9 10 4 3
6 7 8 2 3 10 3
This diff is collapsed.
Click to expand it.
src/lib/parser/shell_expand/mod.rs
+
24
−
2
View file @
4ac9b428
...
...
@@ -205,10 +205,32 @@ pub(crate) fn expand_string<E: Expander>(
match
word
{
WordToken
::
Brace
(
_
)
=>
{
contains_brace
=
true
;
token_buffer
.push
(
word
);
}
_
=>
(),
WordToken
::
ArrayVariable
(
data
,
contains_quote
,
selection
)
=>
{
if
let
Select
::
Key
(
key
)
=
selection
{
if
key
.key
.contains
(
' '
)
{
for
index
in
key
.key
.split
(
' '
)
{
let
select
=
index
.parse
::
<
Select
>
()
.unwrap_or
(
Select
::
None
);
token_buffer
.push
(
WordToken
::
ArrayVariable
(
data
,
contains_quote
,
select
,
)
);
token_buffer
.push
(
WordToken
::
Whitespace
(
" "
));
}
token_buffer
.pop
();
// Pop out the last unneeded whitespace token
}
else
{
token_buffer
.push
(
WordToken
::
ArrayVariable
(
data
,
contains_quote
,
Select
::
Key
(
key
)));
}
}
else
{
token_buffer
.push
(
WordToken
::
ArrayVariable
(
data
,
contains_quote
,
selection
));
}
}
_
=>
token_buffer
.push
(
word
),
}
token_buffer
.push
(
word
);
}
None
if
original
.is_empty
()
=>
{
token_buffer
.push
(
WordToken
::
Normal
(
""
.into
(),
true
,
false
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment