Permalink
Browse files

Improved method argument parsing

  • Loading branch information...
mmstick committed Oct 11, 2017
1 parent 1305495 commit 1fb9bf75c874f9de9c9e506126293b676ea14283
@@ -35,4 +35,8 @@ echo $replace($join([one two three], "\n"), "\n" "\t")
let a = "applesauce"
let pos = $find(a, "s")
let array = [@split_at(a, $pos)]
echo $join(array, "\n")
echo $join(array, "\n")
let a = [1 2 3 4 5]
let a = "1 2 3 4 5"
echo $join(@split(a, " "), $join(a, " "))
@@ -65,3 +65,4 @@ one\ntwo\nthree
one two three
apple
sauce
11 2 3 4 521 2 3 4 531 2 3 4 541 2 3 4 55
@@ -148,7 +148,7 @@ impl<'a> StringMethod<'a> {
);
}
}
"len" => if variable.starts_with('@') || variable.starts_with('[') {
"len" => if variable.starts_with('@') || is_array(variable) {
let expanded = expand_string(variable, expand, false);
output.push_str(&expanded.len().to_string());
} else if let Some(value) = expand.variable(variable, false) {
@@ -124,8 +124,12 @@ impl<'a, E: Expander + 'a> WordIterator<'a, E> {
start = self.read;
while let Some(character) = iterator.next() {
if character == b')' {
let pattern = &self.data[start..self.read].trim();
self.read += 1;
if depth != 0 {
depth -= 1;
continue;
}
let pattern = &self.data[start..self.read - 1].trim();
return if let Some(&b'[') =
self.data.as_bytes().get(self.read)
{
@@ -144,6 +148,11 @@ impl<'a, E: Expander + 'a> WordIterator<'a, E> {
selection: Select::All,
})
};
} else if character == b'(' {
depth += 1;
} else if character == b'\\' {
self.read += 1;
let _ = iterator.next();
}
self.read += 1;
}

0 comments on commit 1fb9bf7

Please sign in to comment.