1
0
This commit is contained in:
Jeff 2023-10-22 15:24:10 -04:00
parent f9a4496473
commit 88747e6fe5
6 changed files with 22 additions and 16 deletions

View File

@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use tree_sitter::Node;
use crate::{AbstractTree, Expression, Identifier, Item, Value};
use crate::{AbstractTree, Expression, Identifier, Item, Result, Value, VariableMap};
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct Filter {
@ -10,7 +11,7 @@ pub struct Filter {
}
impl AbstractTree for Filter {
fn from_syntax_node(source: &str, node: tree_sitter::Node) -> crate::Result<Self> {
fn from_syntax_node(source: &str, node: Node) -> Result<Self> {
let identifier_node = node.child(1).unwrap();
let identifier = Identifier::from_syntax_node(source, identifier_node)?;
@ -27,7 +28,7 @@ impl AbstractTree for Filter {
})
}
fn run(&self, source: &str, context: &mut crate::VariableMap) -> crate::Result<crate::Value> {
fn run(&self, source: &str, context: &mut VariableMap) -> Result<Value> {
let value = self.expression.run(source, context)?;
let list = value.as_list()?;
let key = self.identifier.inner();

View File

@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use tree_sitter::Node;
use crate::{AbstractTree, Expression, Identifier, Item, Value};
use crate::{AbstractTree, Expression, Identifier, Item, Result, Value, VariableMap};
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct Find {
@ -10,7 +11,7 @@ pub struct Find {
}
impl AbstractTree for Find {
fn from_syntax_node(source: &str, node: tree_sitter::Node) -> crate::Result<Self> {
fn from_syntax_node(source: &str, node: Node) -> Result<Self> {
let identifier_node = node.child(1).unwrap();
let identifier = Identifier::from_syntax_node(source, identifier_node)?;
@ -27,7 +28,7 @@ impl AbstractTree for Find {
})
}
fn run(&self, source: &str, context: &mut crate::VariableMap) -> crate::Result<crate::Value> {
fn run(&self, source: &str, context: &mut VariableMap) -> Result<Value> {
let value = self.expression.run(source, context)?;
let list = value.as_list()?;
let key = self.identifier.inner();

View File

@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use tree_sitter::Node;
use crate::{AbstractTree, Expression, Identifier, Item, Value};
use crate::{AbstractTree, Expression, Identifier, Item, Result, Value, VariableMap};
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct For {
@ -10,7 +11,7 @@ pub struct For {
}
impl AbstractTree for For {
fn from_syntax_node(source: &str, node: tree_sitter::Node) -> crate::Result<Self> {
fn from_syntax_node(source: &str, node: Node) -> Result<Self> {
let identifier_node = node.child(1).unwrap();
let identifier = Identifier::from_syntax_node(source, identifier_node)?;
@ -27,7 +28,7 @@ impl AbstractTree for For {
})
}
fn run(&self, source: &str, context: &mut crate::VariableMap) -> crate::Result<crate::Value> {
fn run(&self, source: &str, context: &mut VariableMap) -> Result<Value> {
let value = self.expression.run(source, context)?;
let list = value.as_list()?;
let key = self.identifier.inner();

View File

@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use tree_sitter::Node;
use crate::{AbstractTree, Expression, Identifier, Item, Value};
use crate::{AbstractTree, Expression, Identifier, Item, Result, Value, VariableMap};
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct Remove {
@ -10,7 +11,7 @@ pub struct Remove {
}
impl AbstractTree for Remove {
fn from_syntax_node(source: &str, node: tree_sitter::Node) -> crate::Result<Self> {
fn from_syntax_node(source: &str, node: Node) -> Result<Self> {
let identifier_node = node.child(1).unwrap();
let identifier = Identifier::from_syntax_node(source, identifier_node)?;
@ -27,7 +28,7 @@ impl AbstractTree for Remove {
})
}
fn run(&self, source: &str, context: &mut crate::VariableMap) -> crate::Result<crate::Value> {
fn run(&self, source: &str, context: &mut VariableMap) -> Result<Value> {
let value = self.expression.run(source, context)?;
let mut list = value.into_inner_list()?;
let key = self.identifier.inner();

View File

@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize};
use tree_sitter::Node;
use crate::{AbstractTree, Expression, Identifier, Item, Result, Table, Value, VariableMap};
@ -10,7 +11,7 @@ pub struct Select {
}
impl AbstractTree for Select {
fn from_syntax_node(source: &str, node: tree_sitter::Node) -> crate::Result<Self> {
fn from_syntax_node(source: &str, node: Node) -> Result<Self> {
let child_count = node.child_count();
let mut identifiers = Vec::new();

View File

@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use tree_sitter::Node;
use crate::{AbstractTree, Expression, Identifier, Item, Value};
use crate::{AbstractTree, Expression, Identifier, Item, Result, Value, VariableMap};
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct Transform {
@ -10,7 +11,7 @@ pub struct Transform {
}
impl AbstractTree for Transform {
fn from_syntax_node(source: &str, node: tree_sitter::Node) -> crate::Result<Self> {
fn from_syntax_node(source: &str, node: Node) -> Result<Self> {
let identifier_node = node.child(1).unwrap();
let identifier = Identifier::from_syntax_node(source, identifier_node)?;
@ -27,7 +28,7 @@ impl AbstractTree for Transform {
})
}
fn run(&self, source: &str, context: &mut crate::VariableMap) -> crate::Result<crate::Value> {
fn run(&self, source: &str, context: &mut VariableMap) -> Result<Value> {
let value = self.expression.run(source, context)?;
let list = value.as_list()?;
let key = self.identifier.inner();