mirror of
https://github.com/fluencelabs/aquavm
synced 2025-06-27 05:31:36 +00:00
Support scalars in lambda (#192)
This commit is contained in:
@ -28,7 +28,10 @@ pub enum ValueAccessor<'input> {
|
||||
ArrayAccess { idx: u32 },
|
||||
|
||||
// .field
|
||||
FieldAccess { field_name: &'input str },
|
||||
FieldAccessByName { field_name: &'input str },
|
||||
|
||||
// (.)?[field]
|
||||
FieldAccessByScalar { scalar_name: &'input str },
|
||||
|
||||
// needed to allow parser catch all errors from a lambda expression without stopping
|
||||
// on the very first one. Although, this variant is guaranteed not to be present in a lambda.
|
||||
|
@ -24,7 +24,8 @@ impl fmt::Display for ValueAccessor<'_> {
|
||||
|
||||
match self {
|
||||
ArrayAccess { idx } => write!(f, ".[{}]", idx),
|
||||
FieldAccess { field_name } => write!(f, ".{}", field_name),
|
||||
FieldAccessByName { field_name } => write!(f, ".{}", field_name),
|
||||
FieldAccessByScalar { scalar_name } => write!(f, ".[{}]", scalar_name),
|
||||
Error => write!(f, "a parser error occurred while parsing lambda expression"),
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ pub use ast::*;
|
||||
|
||||
pub fn format_ast(lambda_ast: &LambdaAST<'_>) -> String {
|
||||
let mut formatted_ast = String::new();
|
||||
for algebra in lambda_ast.iter() {
|
||||
formatted_ast.push_str(&algebra.to_string());
|
||||
for accessor in lambda_ast.iter() {
|
||||
formatted_ast.push_str(&accessor.to_string());
|
||||
}
|
||||
|
||||
formatted_ast
|
||||
|
Reference in New Issue
Block a user