forked from syndicate-lang/preserves
Treat Symbols more uniformly like Strings
This commit is contained in:
parent
7abd4a3d3a
commit
02420543f1
|
@ -175,7 +175,7 @@ impl Step for AxisStep {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
path::Axis::At { key } => match value.value() {
|
path::Axis::At { key } => match value.value() {
|
||||||
Value::String(s) =>
|
Value::String(s) | Value::Symbol(s) =>
|
||||||
step_index(path.step(value), s.chars(), &key, |c| IOValue::new(String::from(c)), &mut self.step),
|
step_index(path.step(value), s.chars(), &key, |c| IOValue::new(String::from(c)), &mut self.step),
|
||||||
Value::Record(r) =>
|
Value::Record(r) =>
|
||||||
step_index(path.step(value), r.fields().iter(), &key, |v| v.clone(), &mut self.step),
|
step_index(path.step(value), r.fields().iter(), &key, |v| v.clone(), &mut self.step),
|
||||||
|
@ -192,9 +192,9 @@ impl Step for AxisStep {
|
||||||
self.step.accept(path.step(value), r.label())
|
self.step.accept(path.step(value), r.label())
|
||||||
},
|
},
|
||||||
path::Axis::Keys => match value.value() {
|
path::Axis::Keys => match value.value() {
|
||||||
Value::String(s) => step_keys(path.step(value), s.len(), &mut self.step),
|
Value::String(s) | Value::Symbol(s) =>
|
||||||
|
step_keys(path.step(value), s.len(), &mut self.step),
|
||||||
Value::ByteString(bs) => step_keys(path.step(value), bs.len(), &mut self.step),
|
Value::ByteString(bs) => step_keys(path.step(value), bs.len(), &mut self.step),
|
||||||
Value::Symbol(s) => step_keys(path.step(value), s.len(), &mut self.step),
|
|
||||||
Value::Record(r) => step_keys(path.step(value), r.arity(), &mut self.step),
|
Value::Record(r) => step_keys(path.step(value), r.arity(), &mut self.step),
|
||||||
Value::Sequence(vs) => step_keys(path.step(value), vs.len(), &mut self.step),
|
Value::Sequence(vs) => step_keys(path.step(value), vs.len(), &mut self.step),
|
||||||
Value::Dictionary(d) => {
|
Value::Dictionary(d) => {
|
||||||
|
@ -206,9 +206,9 @@ impl Step for AxisStep {
|
||||||
_ => (),
|
_ => (),
|
||||||
},
|
},
|
||||||
path::Axis::Length => match value.value() {
|
path::Axis::Length => match value.value() {
|
||||||
Value::String(s) => self.step.accept(path.step(value), &IOValue::new(s.len())),
|
Value::String(s) | Value::Symbol(s) =>
|
||||||
|
self.step.accept(path.step(value), &IOValue::new(s.len())),
|
||||||
Value::ByteString(bs) => self.step.accept(path.step(value), &IOValue::new(bs.len())),
|
Value::ByteString(bs) => self.step.accept(path.step(value), &IOValue::new(bs.len())),
|
||||||
Value::Symbol(s) => self.step.accept(path.step(value), &IOValue::new(s.len())),
|
|
||||||
Value::Record(r) => self.step.accept(path.step(value), &IOValue::new(r.arity())),
|
Value::Record(r) => self.step.accept(path.step(value), &IOValue::new(r.arity())),
|
||||||
Value::Sequence(vs) => self.step.accept(path.step(value), &IOValue::new(vs.len())),
|
Value::Sequence(vs) => self.step.accept(path.step(value), &IOValue::new(vs.len())),
|
||||||
Value::Dictionary(d) => self.step.accept(path.step(value), &IOValue::new(d.len())),
|
Value::Dictionary(d) => self.step.accept(path.step(value), &IOValue::new(d.len())),
|
||||||
|
@ -304,9 +304,10 @@ impl Step for CompareStep {
|
||||||
impl Step for RegexStep {
|
impl Step for RegexStep {
|
||||||
fn accept(&mut self, path: Rc<Path>, value: &IOValue) {
|
fn accept(&mut self, path: Rc<Path>, value: &IOValue) {
|
||||||
match value.value() {
|
match value.value() {
|
||||||
Value::String(s) => if self.regex.is_match(s) { self.step.accept(path, value) },
|
Value::String(s) | Value::Symbol(s) =>
|
||||||
Value::Symbol(s) => if self.regex.is_match(s) { self.step.accept(path, value) },
|
if self.regex.is_match(s) { self.step.accept(path, value) },
|
||||||
_ => (),
|
_ =>
|
||||||
|
(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue