Move parsing files around (#4626)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -171,7 +171,7 @@ fn do_stdlib_inner(
|
|||||||
code_blocks.iter().map(|cb| {
|
code_blocks.iter().map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
|
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
}).collect::<Vec<String>>()
|
}).collect::<Vec<String>>()
|
||||||
|
@ -113,7 +113,7 @@ impl crate::docs::StdLibFn for SomeFn {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|cb| {
|
.map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
})
|
})
|
||||||
|
@ -113,7 +113,7 @@ impl crate::docs::StdLibFn for SomeFn {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|cb| {
|
.map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
})
|
})
|
||||||
|
@ -150,7 +150,7 @@ impl crate::docs::StdLibFn for Show {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|cb| {
|
.map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
})
|
})
|
||||||
|
@ -113,7 +113,7 @@ impl crate::docs::StdLibFn for Show {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|cb| {
|
.map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
})
|
})
|
||||||
|
@ -150,7 +150,7 @@ impl crate::docs::StdLibFn for MyFunc {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|cb| {
|
.map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
})
|
})
|
||||||
|
@ -158,7 +158,7 @@ impl crate::docs::StdLibFn for LineTo {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|cb| {
|
.map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
})
|
})
|
||||||
|
@ -150,7 +150,7 @@ impl crate::docs::StdLibFn for Min {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|cb| {
|
.map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
})
|
})
|
||||||
|
@ -113,7 +113,7 @@ impl crate::docs::StdLibFn for Show {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|cb| {
|
.map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
})
|
})
|
||||||
|
@ -113,7 +113,7 @@ impl crate::docs::StdLibFn for Import {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|cb| {
|
.map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
})
|
})
|
||||||
|
@ -113,7 +113,7 @@ impl crate::docs::StdLibFn for Import {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|cb| {
|
.map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
})
|
})
|
||||||
|
@ -113,7 +113,7 @@ impl crate::docs::StdLibFn for Import {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|cb| {
|
.map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
})
|
})
|
||||||
|
@ -113,7 +113,7 @@ impl crate::docs::StdLibFn for Show {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|cb| {
|
.map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
})
|
})
|
||||||
|
@ -108,7 +108,7 @@ impl crate::docs::StdLibFn for SomeFunction {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|cb| {
|
.map(|cb| {
|
||||||
let program = crate::Program::parse(cb).unwrap();
|
let program = crate::Program::parse(cb).unwrap();
|
||||||
let mut options: crate::ast::types::FormatOptions = Default::default();
|
let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
|
||||||
options.insert_final_newline = false;
|
options.insert_final_newline = false;
|
||||||
program.ast.recast(&options, 0)
|
program.ast.recast(&options, 0)
|
||||||
})
|
})
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
pub mod modify;
|
|
||||||
pub mod types;
|
|
@ -797,7 +797,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serialize_function() {
|
fn test_serialize_function() {
|
||||||
let some_function = crate::ast::types::Function::StdLib {
|
let some_function = crate::parsing::ast::types::Function::StdLib {
|
||||||
func: Box::new(crate::std::sketch::Line),
|
func: Box::new(crate::std::sketch::Line),
|
||||||
};
|
};
|
||||||
let serialized = serde_json::to_string(&some_function).unwrap();
|
let serialized = serde_json::to_string(&some_function).unwrap();
|
||||||
@ -807,11 +807,11 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_deserialize_function() {
|
fn test_deserialize_function() {
|
||||||
let some_function_string = r#"{"type":"StdLib","func":{"name":"line","summary":"","description":"","tags":[],"returnValue":{"type":"","required":false,"name":"","schema":{},"schemaDefinitions":{}},"args":[],"unpublished":false,"deprecated":false, "examples": []}}"#;
|
let some_function_string = r#"{"type":"StdLib","func":{"name":"line","summary":"","description":"","tags":[],"returnValue":{"type":"","required":false,"name":"","schema":{},"schemaDefinitions":{}},"args":[],"unpublished":false,"deprecated":false, "examples": []}}"#;
|
||||||
let some_function: crate::ast::types::Function = serde_json::from_str(some_function_string).unwrap();
|
let some_function: crate::parsing::ast::types::Function = serde_json::from_str(some_function_string).unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
some_function,
|
some_function,
|
||||||
crate::ast::types::Function::StdLib {
|
crate::parsing::ast::types::Function::StdLib {
|
||||||
func: Box::new(crate::std::sketch::Line)
|
func: Box::new(crate::std::sketch::Line)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -25,10 +25,12 @@ type Point3D = kcmc::shared::Point3d<f64>;
|
|||||||
|
|
||||||
pub use crate::kcl_value::KclValue;
|
pub use crate::kcl_value::KclValue;
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::types::{BodyItem, Expr, FunctionExpression, ItemVisibility, KclNone, Node, NodeRef, TagDeclarator, TagNode},
|
|
||||||
engine::{EngineManager, ExecutionKind},
|
engine::{EngineManager, ExecutionKind},
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
fs::{FileManager, FileSystem},
|
fs::{FileManager, FileSystem},
|
||||||
|
parsing::ast::types::{
|
||||||
|
BodyItem, Expr, FunctionExpression, ItemVisibility, KclNone, Node, NodeRef, TagDeclarator, TagNode,
|
||||||
|
},
|
||||||
settings::types::UnitLength,
|
settings::types::UnitLength,
|
||||||
source_range::{ModuleId, SourceRange},
|
source_range::{ModuleId, SourceRange},
|
||||||
std::{args::Arg, StdLib},
|
std::{args::Arg, StdLib},
|
||||||
@ -733,7 +735,7 @@ pub type MemoryFunction =
|
|||||||
fn(
|
fn(
|
||||||
s: Vec<Arg>,
|
s: Vec<Arg>,
|
||||||
memory: ProgramMemory,
|
memory: ProgramMemory,
|
||||||
expression: crate::ast::types::BoxNode<FunctionExpression>,
|
expression: crate::parsing::ast::types::BoxNode<FunctionExpression>,
|
||||||
metadata: Vec<Metadata>,
|
metadata: Vec<Metadata>,
|
||||||
exec_state: &ExecState,
|
exec_state: &ExecState,
|
||||||
ctx: ExecutorContext,
|
ctx: ExecutorContext,
|
||||||
@ -1842,7 +1844,7 @@ impl ExecutorContext {
|
|||||||
#[async_recursion]
|
#[async_recursion]
|
||||||
pub(crate) async fn inner_execute<'a>(
|
pub(crate) async fn inner_execute<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
program: NodeRef<'a, crate::ast::types::Program>,
|
program: NodeRef<'a, crate::parsing::ast::types::Program>,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
body_type: BodyType,
|
body_type: BodyType,
|
||||||
) -> Result<Option<KclValue>, KclError> {
|
) -> Result<Option<KclValue>, KclError> {
|
||||||
@ -1883,7 +1885,7 @@ impl ExecutorContext {
|
|||||||
let module_id = exec_state.add_module(resolved_path.clone());
|
let module_id = exec_state.add_module(resolved_path.clone());
|
||||||
let source = self.fs.read_to_string(&resolved_path, source_range).await?;
|
let source = self.fs.read_to_string(&resolved_path, source_range).await?;
|
||||||
// TODO handle parsing errors properly
|
// TODO handle parsing errors properly
|
||||||
let program = crate::parser::parse_str(&source, module_id).parse_errs_as_err()?;
|
let program = crate::parsing::parse_str(&source, module_id).parse_errs_as_err()?;
|
||||||
let (module_memory, module_exports) = {
|
let (module_memory, module_exports) = {
|
||||||
exec_state.import_stack.push(resolved_path.clone());
|
exec_state.import_stack.push(resolved_path.clone());
|
||||||
let original_execution = self.engine.replace_execution_kind(ExecutionKind::Isolated);
|
let original_execution = self.engine.replace_execution_kind(ExecutionKind::Isolated);
|
||||||
@ -2239,7 +2241,7 @@ mod tests {
|
|||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::ast::types::{Identifier, Node, Parameter};
|
use crate::parsing::ast::types::{Identifier, Node, Parameter};
|
||||||
|
|
||||||
pub async fn parse_execute(code: &str) -> Result<ProgramMemory> {
|
pub async fn parse_execute(code: &str) -> Result<ProgramMemory> {
|
||||||
let program = Program::parse(code)?;
|
let program = Program::parse(code)?;
|
||||||
@ -3088,7 +3090,7 @@ let w = f() + f()
|
|||||||
let func_expr = &Node::no_src(FunctionExpression {
|
let func_expr = &Node::no_src(FunctionExpression {
|
||||||
params,
|
params,
|
||||||
body: Node {
|
body: Node {
|
||||||
inner: crate::ast::types::Program {
|
inner: crate::parsing::ast::types::Program {
|
||||||
body: Vec::new(),
|
body: Vec::new(),
|
||||||
non_code_meta: Default::default(),
|
non_code_meta: Default::default(),
|
||||||
shebang: None,
|
shebang: None,
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::types::FunctionExpression,
|
|
||||||
errors::KclError,
|
errors::KclError,
|
||||||
executor::{
|
executor::{
|
||||||
call_user_defined_function, ExecState, ExecutorContext, KclValue, MemoryFunction, Metadata, ProgramMemory,
|
call_user_defined_function, ExecState, ExecutorContext, KclValue, MemoryFunction, Metadata, ProgramMemory,
|
||||||
},
|
},
|
||||||
|
parsing::ast::types::FunctionExpression,
|
||||||
std::args::Arg,
|
std::args::Arg,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ use crate::{
|
|||||||
pub struct FunctionParam<'a> {
|
pub struct FunctionParam<'a> {
|
||||||
pub inner: Option<&'a MemoryFunction>,
|
pub inner: Option<&'a MemoryFunction>,
|
||||||
pub memory: ProgramMemory,
|
pub memory: ProgramMemory,
|
||||||
pub fn_expr: crate::ast::types::BoxNode<FunctionExpression>,
|
pub fn_expr: crate::parsing::ast::types::BoxNode<FunctionExpression>,
|
||||||
pub meta: Vec<Metadata>,
|
pub meta: Vec<Metadata>,
|
||||||
pub ctx: ExecutorContext,
|
pub ctx: ExecutorContext,
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ use schemars::JsonSchema;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::types::{FunctionExpression, KclNone, TagDeclarator, TagNode},
|
|
||||||
errors::KclErrorDetails,
|
errors::KclErrorDetails,
|
||||||
exec::{ProgramMemory, Sketch},
|
exec::{ProgramMemory, Sketch},
|
||||||
executor::{Face, ImportedGeometry, MemoryFunction, Metadata, Plane, SketchSet, Solid, SolidSet, TagIdentifier},
|
executor::{Face, ImportedGeometry, MemoryFunction, Metadata, Plane, SketchSet, Solid, SolidSet, TagIdentifier},
|
||||||
|
parsing::ast::types::{FunctionExpression, KclNone, TagDeclarator, TagNode},
|
||||||
std::{args::Arg, FnAsArg},
|
std::{args::Arg, FnAsArg},
|
||||||
ExecState, ExecutorContext, KclError, SourceRange,
|
ExecState, ExecutorContext, KclError, SourceRange,
|
||||||
};
|
};
|
||||||
@ -56,7 +56,7 @@ pub enum KclValue {
|
|||||||
meta: Vec<Metadata>,
|
meta: Vec<Metadata>,
|
||||||
},
|
},
|
||||||
TagIdentifier(Box<TagIdentifier>),
|
TagIdentifier(Box<TagIdentifier>),
|
||||||
TagDeclarator(crate::ast::types::BoxNode<TagDeclarator>),
|
TagDeclarator(crate::parsing::ast::types::BoxNode<TagDeclarator>),
|
||||||
Plane(Box<Plane>),
|
Plane(Box<Plane>),
|
||||||
Face(Box<Face>),
|
Face(Box<Face>),
|
||||||
Sketch {
|
Sketch {
|
||||||
@ -75,7 +75,7 @@ pub enum KclValue {
|
|||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
func: Option<MemoryFunction>,
|
func: Option<MemoryFunction>,
|
||||||
#[schemars(skip)]
|
#[schemars(skip)]
|
||||||
expression: crate::ast::types::BoxNode<FunctionExpression>,
|
expression: crate::parsing::ast::types::BoxNode<FunctionExpression>,
|
||||||
memory: Box<ProgramMemory>,
|
memory: Box<ProgramMemory>,
|
||||||
#[serde(rename = "__meta")]
|
#[serde(rename = "__meta")]
|
||||||
meta: Vec<Metadata>,
|
meta: Vec<Metadata>,
|
||||||
|
@ -56,7 +56,6 @@ macro_rules! eprint {
|
|||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static ALLOC: dhat::Alloc = dhat::Alloc;
|
static ALLOC: dhat::Alloc = dhat::Alloc;
|
||||||
|
|
||||||
mod ast;
|
|
||||||
mod coredump;
|
mod coredump;
|
||||||
mod docs;
|
mod docs;
|
||||||
mod engine;
|
mod engine;
|
||||||
@ -68,7 +67,7 @@ mod kcl_value;
|
|||||||
pub mod lint;
|
pub mod lint;
|
||||||
mod log;
|
mod log;
|
||||||
mod lsp;
|
mod lsp;
|
||||||
mod parser;
|
mod parsing;
|
||||||
mod settings;
|
mod settings;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod simulation_tests;
|
mod simulation_tests;
|
||||||
@ -77,13 +76,11 @@ mod std;
|
|||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub mod test_server;
|
pub mod test_server;
|
||||||
mod thread;
|
mod thread;
|
||||||
mod token;
|
|
||||||
mod unparser;
|
mod unparser;
|
||||||
mod walk;
|
mod walk;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
mod wasm;
|
mod wasm;
|
||||||
|
|
||||||
pub use ast::{modify::modify_ast_for_sketch, types::FormatOptions};
|
|
||||||
pub use coredump::CoreDump;
|
pub use coredump::CoreDump;
|
||||||
pub use engine::{EngineManager, ExecutionKind};
|
pub use engine::{EngineManager, ExecutionKind};
|
||||||
pub use errors::{ConnectionError, ExecError, KclError};
|
pub use errors::{ConnectionError, ExecError, KclError};
|
||||||
@ -92,6 +89,7 @@ pub use lsp::{
|
|||||||
copilot::Backend as CopilotLspBackend,
|
copilot::Backend as CopilotLspBackend,
|
||||||
kcl::{Backend as KclLspBackend, Server as KclLspServerSubCommand},
|
kcl::{Backend as KclLspBackend, Server as KclLspServerSubCommand},
|
||||||
};
|
};
|
||||||
|
pub use parsing::ast::{modify::modify_ast_for_sketch, types::FormatOptions};
|
||||||
pub use settings::types::{project::ProjectConfiguration, Configuration, UnitLength};
|
pub use settings::types::{project::ProjectConfiguration, Configuration, UnitLength};
|
||||||
pub use source_range::{ModuleId, SourceRange};
|
pub use source_range::{ModuleId, SourceRange};
|
||||||
|
|
||||||
@ -127,7 +125,7 @@ use crate::log::{log, logln};
|
|||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Program {
|
pub struct Program {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
ast: ast::types::Node<ast::types::Program>,
|
ast: parsing::ast::types::Node<parsing::ast::types::Program>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "lsp-test-util"))]
|
#[cfg(any(test, feature = "lsp-test-util"))]
|
||||||
@ -138,14 +136,14 @@ pub use lsp::test_util::kcl_lsp_server;
|
|||||||
impl Program {
|
impl Program {
|
||||||
pub fn parse(input: &str) -> Result<Program, KclError> {
|
pub fn parse(input: &str) -> Result<Program, KclError> {
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let tokens = token::lexer(input, module_id)?;
|
let tokens = parsing::token::lexer(input, module_id)?;
|
||||||
// TODO handle parsing errors properly
|
// TODO handle parsing errors properly
|
||||||
let ast = parser::parse_tokens(tokens).parse_errs_as_err()?;
|
let ast = parsing::parse_tokens(tokens).parse_errs_as_err()?;
|
||||||
|
|
||||||
Ok(Program { ast })
|
Ok(Program { ast })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compute_digest(&mut self) -> ast::types::digest::Digest {
|
pub fn compute_digest(&mut self) -> parsing::ast::digest::Digest {
|
||||||
self.ast.compute_digest()
|
self.ast.compute_digest()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,8 +165,8 @@ impl Program {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ast::types::Node<ast::types::Program>> for Program {
|
impl From<parsing::ast::types::Node<parsing::ast::types::Program>> for Program {
|
||||||
fn from(ast: ast::types::Node<ast::types::Program>) -> Program {
|
fn from(ast: parsing::ast::types::Node<parsing::ast::types::Program>) -> Program {
|
||||||
Self { ast }
|
Self { ast }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ use anyhow::Result;
|
|||||||
use convert_case::Casing;
|
use convert_case::Casing;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::types::{ObjectProperty, VariableDeclarator},
|
|
||||||
lint::rule::{def_finding, Discovered, Finding},
|
lint::rule::{def_finding, Discovered, Finding},
|
||||||
|
parsing::ast::types::{ObjectProperty, VariableDeclarator},
|
||||||
walk::Node,
|
walk::Node,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
};
|
};
|
||||||
|
@ -3,8 +3,8 @@ use std::collections::HashMap;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::types::{BinaryPart, Expr, LiteralValue, ObjectExpression, UnaryOperator},
|
|
||||||
lint::rule::{def_finding, Discovered, Finding},
|
lint::rule::{def_finding, Discovered, Finding},
|
||||||
|
parsing::ast::types::{BinaryPart, Expr, LiteralValue, ObjectExpression, UnaryOperator},
|
||||||
walk::Node,
|
walk::Node,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
};
|
};
|
||||||
|
@ -3,9 +3,9 @@ use std::sync::Arc;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::types::{CallExpression, NodeRef},
|
|
||||||
docs::StdLibFn,
|
docs::StdLibFn,
|
||||||
lint::rule::{def_finding, Discovered, Finding},
|
lint::rule::{def_finding, Discovered, Finding},
|
||||||
|
parsing::ast::types::{CallExpression, NodeRef},
|
||||||
std::{FunctionKind, StdLib},
|
std::{FunctionKind, StdLib},
|
||||||
walk::Node,
|
walk::Node,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
|
@ -182,7 +182,7 @@ mod test {
|
|||||||
|
|
||||||
macro_rules! assert_no_finding {
|
macro_rules! assert_no_finding {
|
||||||
( $check:expr, $finding:expr, $kcl:expr ) => {
|
( $check:expr, $finding:expr, $kcl:expr ) => {
|
||||||
let prog = $crate::parser::top_level_parse($kcl).unwrap();
|
let prog = $crate::parsing::top_level_parse($kcl).unwrap();
|
||||||
for discovered_finding in prog.lint($check).unwrap() {
|
for discovered_finding in prog.lint($check).unwrap() {
|
||||||
if discovered_finding.finding == $finding {
|
if discovered_finding.finding == $finding {
|
||||||
assert!(false, "Finding {:?} was emitted", $finding.code);
|
assert!(false, "Finding {:?} was emitted", $finding.code);
|
||||||
@ -193,7 +193,7 @@ mod test {
|
|||||||
|
|
||||||
macro_rules! assert_finding {
|
macro_rules! assert_finding {
|
||||||
( $check:expr, $finding:expr, $kcl:expr ) => {
|
( $check:expr, $finding:expr, $kcl:expr ) => {
|
||||||
let prog = $crate::parser::top_level_parse($kcl).unwrap();
|
let prog = $crate::parsing::top_level_parse($kcl).unwrap();
|
||||||
|
|
||||||
for discovered_finding in prog.lint($check).unwrap() {
|
for discovered_finding in prog.lint($check).unwrap() {
|
||||||
if discovered_finding.finding == $finding {
|
if discovered_finding.finding == $finding {
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tower_lsp::lsp_types::notification::Notification;
|
use tower_lsp::lsp_types::notification::Notification;
|
||||||
|
|
||||||
use crate::{ast::types::Node, settings::types::UnitLength};
|
use crate::{parsing::ast::types::Node, settings::types::UnitLength};
|
||||||
|
|
||||||
/// A notification that the AST has changed.
|
/// A notification that the AST has changed.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum AstUpdated {}
|
pub enum AstUpdated {}
|
||||||
|
|
||||||
impl Notification for AstUpdated {
|
impl Notification for AstUpdated {
|
||||||
type Params = Node<crate::ast::types::Program>;
|
type Params = Node<crate::parsing::ast::types::Program>;
|
||||||
const METHOD: &'static str = "kcl/astUpdated";
|
const METHOD: &'static str = "kcl/astUpdated";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,10 +41,12 @@ use tower_lsp::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::types::{Expr, Node, VariableKind},
|
|
||||||
lsp::{backend::Backend as _, util::IntoDiagnostic},
|
lsp::{backend::Backend as _, util::IntoDiagnostic},
|
||||||
parser::PIPE_OPERATOR,
|
parsing::{
|
||||||
token::TokenType,
|
ast::types::{Expr, Node, VariableKind},
|
||||||
|
token::TokenType,
|
||||||
|
PIPE_OPERATOR,
|
||||||
|
},
|
||||||
ExecState, ModuleId, Program, SourceRange,
|
ExecState, ModuleId, Program, SourceRange,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -98,9 +100,9 @@ pub struct Backend {
|
|||||||
/// The stdlib signatures for the language.
|
/// The stdlib signatures for the language.
|
||||||
pub stdlib_signatures: HashMap<String, SignatureHelp>,
|
pub stdlib_signatures: HashMap<String, SignatureHelp>,
|
||||||
/// Token maps.
|
/// Token maps.
|
||||||
pub token_map: DashMap<String, Vec<crate::token::Token>>,
|
pub token_map: DashMap<String, Vec<crate::parsing::token::Token>>,
|
||||||
/// AST maps.
|
/// AST maps.
|
||||||
pub ast_map: DashMap<String, Node<crate::ast::types::Program>>,
|
pub ast_map: DashMap<String, Node<crate::parsing::ast::types::Program>>,
|
||||||
/// Memory maps.
|
/// Memory maps.
|
||||||
pub memory_map: DashMap<String, crate::executor::ProgramMemory>,
|
pub memory_map: DashMap<String, crate::executor::ProgramMemory>,
|
||||||
/// Current code.
|
/// Current code.
|
||||||
@ -257,7 +259,7 @@ impl crate::lsp::backend::Backend for Backend {
|
|||||||
|
|
||||||
// Lets update the tokens.
|
// Lets update the tokens.
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let tokens = match crate::token::lexer(¶ms.text, module_id) {
|
let tokens = match crate::parsing::token::lexer(¶ms.text, module_id) {
|
||||||
Ok(tokens) => tokens,
|
Ok(tokens) => tokens,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.add_to_diagnostics(¶ms, &[err], true).await;
|
self.add_to_diagnostics(¶ms, &[err], true).await;
|
||||||
@ -298,7 +300,7 @@ impl crate::lsp::backend::Backend for Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lets update the ast.
|
// Lets update the ast.
|
||||||
let result = crate::parser::parse_tokens(tokens.clone());
|
let result = crate::parsing::parse_tokens(tokens.clone());
|
||||||
// TODO handle parse errors properly
|
// TODO handle parse errors properly
|
||||||
let mut ast = match result.parse_errs_as_err() {
|
let mut ast = match result.parse_errs_as_err() {
|
||||||
Ok(ast) => ast,
|
Ok(ast) => ast,
|
||||||
@ -376,7 +378,7 @@ impl Backend {
|
|||||||
self.executor_ctx.read().await
|
self.executor_ctx.read().await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update_semantic_tokens(&self, tokens: &[crate::token::Token], params: &TextDocumentItem) {
|
async fn update_semantic_tokens(&self, tokens: &[crate::parsing::token::Token], params: &TextDocumentItem) {
|
||||||
// Update the semantic tokens map.
|
// Update the semantic tokens map.
|
||||||
let mut semantic_tokens = vec![];
|
let mut semantic_tokens = vec![];
|
||||||
let mut last_position = Position::new(0, 0);
|
let mut last_position = Position::new(0, 0);
|
||||||
@ -1036,7 +1038,7 @@ impl LanguageServer for Backend {
|
|||||||
};
|
};
|
||||||
|
|
||||||
match hover {
|
match hover {
|
||||||
crate::ast::types::Hover::Function { name, range } => {
|
crate::parsing::ast::types::Hover::Function { name, range } => {
|
||||||
// Get the docs for this function.
|
// Get the docs for this function.
|
||||||
let Some(completion) = self.stdlib_completions.get(&name) else {
|
let Some(completion) = self.stdlib_completions.get(&name) else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
@ -1071,8 +1073,8 @@ impl LanguageServer for Backend {
|
|||||||
range: Some(range),
|
range: Some(range),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
crate::ast::types::Hover::Signature { .. } => Ok(None),
|
crate::parsing::ast::types::Hover::Signature { .. } => Ok(None),
|
||||||
crate::ast::types::Hover::Comment { value, range } => Ok(Some(Hover {
|
crate::parsing::ast::types::Hover::Comment { value, range } => Ok(Some(Hover {
|
||||||
contents: HoverContents::Markup(MarkupContent {
|
contents: HoverContents::Markup(MarkupContent {
|
||||||
kind: MarkupKind::Markdown,
|
kind: MarkupKind::Markdown,
|
||||||
value,
|
value,
|
||||||
@ -1230,7 +1232,7 @@ impl LanguageServer for Backend {
|
|||||||
};
|
};
|
||||||
|
|
||||||
match hover {
|
match hover {
|
||||||
crate::ast::types::Hover::Function { name, range: _ } => {
|
crate::parsing::ast::types::Hover::Function { name, range: _ } => {
|
||||||
// Get the docs for this function.
|
// Get the docs for this function.
|
||||||
let Some(signature) = self.stdlib_signatures.get(&name) else {
|
let Some(signature) = self.stdlib_signatures.get(&name) else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
@ -1238,7 +1240,7 @@ impl LanguageServer for Backend {
|
|||||||
|
|
||||||
Ok(Some(signature.clone()))
|
Ok(Some(signature.clone()))
|
||||||
}
|
}
|
||||||
crate::ast::types::Hover::Signature {
|
crate::parsing::ast::types::Hover::Signature {
|
||||||
name,
|
name,
|
||||||
parameter_index,
|
parameter_index,
|
||||||
range: _,
|
range: _,
|
||||||
@ -1253,7 +1255,7 @@ impl LanguageServer for Backend {
|
|||||||
|
|
||||||
Ok(Some(signature))
|
Ok(Some(signature))
|
||||||
}
|
}
|
||||||
crate::ast::types::Hover::Comment { value: _, range: _ } => {
|
crate::parsing::ast::types::Hover::Comment { value: _, range: _ } => {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1302,12 +1304,12 @@ impl LanguageServer for Backend {
|
|||||||
// I don't know if we need to do this again since it should be updated in the context.
|
// I don't know if we need to do this again since it should be updated in the context.
|
||||||
// But I figure better safe than sorry since this will write back out to the file.
|
// But I figure better safe than sorry since this will write back out to the file.
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let Ok(ast) = crate::parser::parse_str(current_code, module_id).parse_errs_as_err() else {
|
let Ok(ast) = crate::parsing::parse_str(current_code, module_id).parse_errs_as_err() else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
// Now recast it.
|
// Now recast it.
|
||||||
let recast = ast.recast(
|
let recast = ast.recast(
|
||||||
&crate::ast::types::FormatOptions {
|
&crate::parsing::ast::types::FormatOptions {
|
||||||
tab_size: params.options.tab_size as usize,
|
tab_size: params.options.tab_size as usize,
|
||||||
insert_final_newline: params.options.insert_final_newline.unwrap_or(false),
|
insert_final_newline: params.options.insert_final_newline.unwrap_or(false),
|
||||||
use_tabs: !params.options.insert_spaces,
|
use_tabs: !params.options.insert_spaces,
|
||||||
@ -1336,7 +1338,7 @@ impl LanguageServer for Backend {
|
|||||||
// I don't know if we need to do this again since it should be updated in the context.
|
// I don't know if we need to do this again since it should be updated in the context.
|
||||||
// But I figure better safe than sorry since this will write back out to the file.
|
// But I figure better safe than sorry since this will write back out to the file.
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let Ok(mut ast) = crate::parser::parse_str(current_code, module_id).parse_errs_as_err() else {
|
let Ok(mut ast) = crate::parsing::parse_str(current_code, module_id).parse_errs_as_err() else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ use tower_lsp::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::types::{Node, Program},
|
|
||||||
executor::ProgramMemory,
|
executor::ProgramMemory,
|
||||||
lsp::test_util::{copilot_lsp_server, kcl_lsp_server},
|
lsp::test_util::{copilot_lsp_server, kcl_lsp_server},
|
||||||
|
parsing::ast::types::{Node, Program},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 12)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 12)]
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
macro_rules! parse_and_lex {
|
|
||||||
($func_name:ident, $test_kcl_program:expr) => {
|
|
||||||
#[test]
|
|
||||||
fn $func_name() {
|
|
||||||
let _ = crate::parser::top_level_parse($test_kcl_program);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_and_lex!(crash_eof_1, "{\"ގގ\0\0\0\"\".");
|
|
||||||
parse_and_lex!(crash_eof_2, "(/=e\"\u{616}ݝ\"\"");
|
|
||||||
}
|
|
@ -1,9 +1,10 @@
|
|||||||
use sha2::{Digest as DigestTrait, Sha256};
|
use sha2::{Digest as DigestTrait, Sha256};
|
||||||
|
|
||||||
use super::{
|
use super::types::{ItemVisibility, VariableKind};
|
||||||
|
use crate::parsing::ast::types::{
|
||||||
ArrayExpression, ArrayRangeExpression, BinaryExpression, BinaryPart, BodyItem, CallExpression, CallExpressionKw,
|
ArrayExpression, ArrayRangeExpression, BinaryExpression, BinaryPart, BodyItem, CallExpression, CallExpressionKw,
|
||||||
ElseIf, Expr, ExpressionStatement, FnArgType, FunctionExpression, Identifier, IfExpression, ImportItem,
|
CommentStyle, ElseIf, Expr, ExpressionStatement, FnArgType, FunctionExpression, Identifier, IfExpression,
|
||||||
ImportStatement, Literal, LiteralIdentifier, MemberExpression, MemberObject, NonCodeMeta, NonCodeNode,
|
ImportItem, ImportStatement, Literal, LiteralIdentifier, MemberExpression, MemberObject, NonCodeMeta, NonCodeNode,
|
||||||
NonCodeValue, ObjectExpression, ObjectProperty, Parameter, PipeExpression, PipeSubstitution, Program,
|
NonCodeValue, ObjectExpression, ObjectProperty, Parameter, PipeExpression, PipeSubstitution, Program,
|
||||||
ReturnStatement, TagDeclarator, UnaryExpression, VariableDeclaration, VariableDeclarator,
|
ReturnStatement, TagDeclarator, UnaryExpression, VariableDeclaration, VariableDeclarator,
|
||||||
};
|
};
|
||||||
@ -209,6 +210,15 @@ impl ReturnStatement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl CommentStyle {
|
||||||
|
fn digestable_id(&self) -> [u8; 2] {
|
||||||
|
match &self {
|
||||||
|
CommentStyle::Line => *b"//",
|
||||||
|
CommentStyle::Block => *b"/*",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl NonCodeNode {
|
impl NonCodeNode {
|
||||||
compute_digest!(|slf, hasher| {
|
compute_digest!(|slf, hasher| {
|
||||||
match &slf.value {
|
match &slf.value {
|
||||||
@ -264,6 +274,24 @@ impl VariableDeclaration {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl VariableKind {
|
||||||
|
fn digestable_id(&self) -> [u8; 1] {
|
||||||
|
match self {
|
||||||
|
VariableKind::Const => [2],
|
||||||
|
VariableKind::Fn => [3],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ItemVisibility {
|
||||||
|
fn digestable_id(&self) -> [u8; 1] {
|
||||||
|
match self {
|
||||||
|
ItemVisibility::Default => [0],
|
||||||
|
ItemVisibility::Export => [1],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl VariableDeclarator {
|
impl VariableDeclarator {
|
||||||
compute_digest!(|slf, hasher| {
|
compute_digest!(|slf, hasher| {
|
||||||
hasher.update(slf.id.compute_digest());
|
hasher.update(slf.id.compute_digest());
|
||||||
@ -406,3 +434,31 @@ impl ElseIf {
|
|||||||
hasher.update(slf.then_val.compute_digest());
|
hasher.update(slf.then_val.compute_digest());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn test_parse_digest() {
|
||||||
|
let prog1_string = r#"startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|
|> line([5, 5], %)
|
||||||
|
"#;
|
||||||
|
let prog1_digest = crate::parsing::top_level_parse(prog1_string).unwrap().compute_digest();
|
||||||
|
|
||||||
|
let prog2_string = r#"startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 2], %)
|
||||||
|
|> line([5, 5], %)
|
||||||
|
"#;
|
||||||
|
let prog2_digest = crate::parsing::top_level_parse(prog2_string).unwrap().compute_digest();
|
||||||
|
|
||||||
|
assert!(prog1_digest != prog2_digest);
|
||||||
|
|
||||||
|
let prog3_string = r#"startSketchOn('XY')
|
||||||
|
|> startProfileAt([0, 0], %)
|
||||||
|
|> line([5, 5], %)
|
||||||
|
"#;
|
||||||
|
let prog3_digest = crate::parsing::top_level_parse(prog3_string).unwrap().compute_digest();
|
||||||
|
|
||||||
|
assert_eq!(prog1_digest, prog3_digest);
|
||||||
|
}
|
||||||
|
}
|
@ -2,14 +2,14 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use async_recursion::async_recursion;
|
use async_recursion::async_recursion;
|
||||||
|
|
||||||
use super::{
|
|
||||||
ArrayExpression, ArrayRangeExpression, BinaryExpression, BinaryOperator, BinaryPart, CallExpression,
|
|
||||||
CallExpressionKw, Expr, IfExpression, KclNone, LiteralIdentifier, LiteralValue, MemberExpression, MemberObject,
|
|
||||||
Node, ObjectExpression, TagDeclarator, UnaryExpression, UnaryOperator,
|
|
||||||
};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
executor::{BodyType, ExecState, ExecutorContext, KclValue, Metadata, StatementKind, TagEngineInfo, TagIdentifier},
|
executor::{BodyType, ExecState, ExecutorContext, KclValue, Metadata, StatementKind, TagEngineInfo, TagIdentifier},
|
||||||
|
parsing::ast::types::{
|
||||||
|
ArrayExpression, ArrayRangeExpression, BinaryExpression, BinaryOperator, BinaryPart, CallExpression,
|
||||||
|
CallExpressionKw, Expr, IfExpression, KclNone, LiteralIdentifier, LiteralValue, MemberExpression, MemberObject,
|
||||||
|
Node, ObjectExpression, TagDeclarator, UnaryExpression, UnaryOperator,
|
||||||
|
},
|
||||||
source_range::SourceRange,
|
source_range::SourceRange,
|
||||||
std::{args::Arg, FunctionKind},
|
std::{args::Arg, FunctionKind},
|
||||||
};
|
};
|
5
src/wasm-lib/kcl/src/parsing/ast/mod.rs
Normal file
5
src/wasm-lib/kcl/src/parsing/ast/mod.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
pub(crate) mod digest;
|
||||||
|
pub(crate) mod execute;
|
||||||
|
pub mod modify;
|
||||||
|
pub(crate) mod source_range;
|
||||||
|
pub mod types;
|
@ -7,13 +7,13 @@ use kcmc::{
|
|||||||
use kittycad_modeling_cmds as kcmc;
|
use kittycad_modeling_cmds as kcmc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::types::{
|
|
||||||
ArrayExpression, CallExpression, ConstraintLevel, FormatOptions, Literal, Node, PipeExpression,
|
|
||||||
PipeSubstitution, VariableDeclarator,
|
|
||||||
},
|
|
||||||
engine::EngineManager,
|
engine::EngineManager,
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
executor::Point2d,
|
executor::Point2d,
|
||||||
|
parsing::ast::types::{
|
||||||
|
ArrayExpression, CallExpression, ConstraintLevel, FormatOptions, Literal, Node, PipeExpression,
|
||||||
|
PipeSubstitution, VariableDeclarator,
|
||||||
|
},
|
||||||
source_range::{ModuleId, SourceRange},
|
source_range::{ModuleId, SourceRange},
|
||||||
Program,
|
Program,
|
||||||
};
|
};
|
||||||
@ -184,7 +184,7 @@ pub async fn modify_ast_for_sketch(
|
|||||||
let recasted = program.ast.recast(&FormatOptions::default(), 0);
|
let recasted = program.ast.recast(&FormatOptions::default(), 0);
|
||||||
|
|
||||||
// Re-parse the ast so we get the correct source ranges.
|
// Re-parse the ast so we get the correct source ranges.
|
||||||
*program = crate::parser::parse_str(&recasted, module_id)
|
*program = crate::parsing::parse_str(&recasted, module_id)
|
||||||
.parse_errs_as_err()?
|
.parse_errs_as_err()?
|
||||||
.into();
|
.into();
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
use super::{BinaryPart, BodyItem, Expr, LiteralIdentifier, MemberObject};
|
use crate::parsing::ast::types::{BinaryPart, BodyItem, Expr, LiteralIdentifier, MemberObject};
|
||||||
use crate::source_range::ModuleId;
|
use crate::source_range::ModuleId;
|
||||||
|
|
||||||
impl BodyItem {
|
impl BodyItem {
|
@ -8,7 +8,7 @@ use crate::SourceRange;
|
|||||||
// TODO: This should be its own type, similar to Program,
|
// TODO: This should be its own type, similar to Program,
|
||||||
// but guaranteed to have an Expression as its final item.
|
// but guaranteed to have an Expression as its final item.
|
||||||
// https://github.com/KittyCAD/modeling-app/issues/4015
|
// https://github.com/KittyCAD/modeling-app/issues/4015
|
||||||
type IfBlock = crate::ast::types::Program;
|
type IfBlock = crate::parsing::ast::types::Program;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema, Bake)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema, Bake)]
|
||||||
#[databake(path = kcl_lib::ast::types)]
|
#[databake(path = kcl_lib::ast::types)]
|
@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use serde_json::Value as JValue;
|
use serde_json::Value as JValue;
|
||||||
|
|
||||||
use super::Node;
|
use super::Node;
|
||||||
use crate::ast::types::{Expr, Literal};
|
use crate::parsing::ast::types::{Expr, Literal};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema, Bake)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema, Bake)]
|
||||||
#[databake(path = kcl_lib::ast::types)]
|
#[databake(path = kcl_lib::ast::types)]
|
@ -18,8 +18,8 @@ use tower_lsp::lsp_types::{
|
|||||||
CompletionItem, CompletionItemKind, DocumentSymbol, FoldingRange, FoldingRangeKind, Range as LspRange, SymbolKind,
|
CompletionItem, CompletionItemKind, DocumentSymbol, FoldingRange, FoldingRangeKind, Range as LspRange, SymbolKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
use self::execute::execute_pipe_body;
|
use super::{digest::Digest, execute::execute_pipe_body};
|
||||||
pub use crate::ast::types::{
|
pub use crate::parsing::ast::types::{
|
||||||
condition::{ElseIf, IfExpression},
|
condition::{ElseIf, IfExpression},
|
||||||
literal_value::LiteralValue,
|
literal_value::LiteralValue,
|
||||||
none::KclNone,
|
none::KclNone,
|
||||||
@ -28,19 +28,14 @@ use crate::{
|
|||||||
docs::StdLibFn,
|
docs::StdLibFn,
|
||||||
errors::KclError,
|
errors::KclError,
|
||||||
executor::{ExecState, ExecutorContext, KclValue, Metadata, TagIdentifier},
|
executor::{ExecState, ExecutorContext, KclValue, Metadata, TagIdentifier},
|
||||||
parser::PIPE_OPERATOR,
|
parsing::PIPE_OPERATOR,
|
||||||
source_range::{ModuleId, SourceRange},
|
source_range::{ModuleId, SourceRange},
|
||||||
std::kcl_stdlib::KclStdLibFn,
|
std::kcl_stdlib::KclStdLibFn,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod condition;
|
mod condition;
|
||||||
pub(crate) mod digest;
|
|
||||||
pub(crate) mod execute;
|
|
||||||
mod literal_value;
|
mod literal_value;
|
||||||
mod none;
|
mod none;
|
||||||
pub(crate) mod source_range;
|
|
||||||
|
|
||||||
use digest::Digest;
|
|
||||||
|
|
||||||
pub enum Definition<'a> {
|
pub enum Definition<'a> {
|
||||||
Variable(&'a VariableDeclarator),
|
Variable(&'a VariableDeclarator),
|
||||||
@ -1029,15 +1024,6 @@ pub enum CommentStyle {
|
|||||||
Block,
|
Block,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CommentStyle {
|
|
||||||
fn digestable_id(&self) -> [u8; 2] {
|
|
||||||
match &self {
|
|
||||||
CommentStyle::Line => *b"//",
|
|
||||||
CommentStyle::Block => *b"/*",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema, Bake)]
|
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema, Bake)]
|
||||||
#[databake(path = kcl_lib::ast::types)]
|
#[databake(path = kcl_lib::ast::types)]
|
||||||
#[ts(export)]
|
#[ts(export)]
|
||||||
@ -1502,13 +1488,6 @@ pub enum ItemVisibility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ItemVisibility {
|
impl ItemVisibility {
|
||||||
fn digestable_id(&self) -> [u8; 1] {
|
|
||||||
match self {
|
|
||||||
ItemVisibility::Default => [0],
|
|
||||||
ItemVisibility::Export => [1],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_default(&self) -> bool {
|
fn is_default(&self) -> bool {
|
||||||
matches!(self, Self::Default)
|
matches!(self, Self::Default)
|
||||||
}
|
}
|
||||||
@ -1732,13 +1711,6 @@ pub enum VariableKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl VariableKind {
|
impl VariableKind {
|
||||||
fn digestable_id(&self) -> [u8; 1] {
|
|
||||||
match self {
|
|
||||||
VariableKind::Const => [2],
|
|
||||||
VariableKind::Fn => [3],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn to_completion_items() -> Result<Vec<CompletionItem>> {
|
pub fn to_completion_items() -> Result<Vec<CompletionItem>> {
|
||||||
let mut settings = schemars::gen::SchemaSettings::openapi3();
|
let mut settings = schemars::gen::SchemaSettings::openapi3();
|
||||||
settings.inline_subschemas = true;
|
settings.inline_subschemas = true;
|
||||||
@ -3158,7 +3130,7 @@ fn ghi = (x) => {
|
|||||||
|
|
||||||
ghi("things")
|
ghi("things")
|
||||||
"#;
|
"#;
|
||||||
let program = crate::parser::top_level_parse(code).unwrap();
|
let program = crate::parsing::top_level_parse(code).unwrap();
|
||||||
let folding_ranges = program.get_lsp_folding_ranges();
|
let folding_ranges = program.get_lsp_folding_ranges();
|
||||||
assert_eq!(folding_ranges.len(), 3);
|
assert_eq!(folding_ranges.len(), 3);
|
||||||
assert_eq!(folding_ranges[0].start_line, 29);
|
assert_eq!(folding_ranges[0].start_line, 29);
|
||||||
@ -3194,7 +3166,7 @@ fn ghi = (x) => {
|
|||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
"#;
|
"#;
|
||||||
let program = crate::parser::top_level_parse(code).unwrap();
|
let program = crate::parsing::top_level_parse(code).unwrap();
|
||||||
let symbols = program.get_lsp_symbols(code).unwrap();
|
let symbols = program.get_lsp_symbols(code).unwrap();
|
||||||
assert_eq!(symbols.len(), 7);
|
assert_eq!(symbols.len(), 7);
|
||||||
}
|
}
|
||||||
@ -3214,7 +3186,7 @@ const cylinder = startSketchOn('-XZ')
|
|||||||
}, %)
|
}, %)
|
||||||
|> extrude(h, %)
|
|> extrude(h, %)
|
||||||
"#;
|
"#;
|
||||||
let program = crate::parser::top_level_parse(some_program_string).unwrap();
|
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||||
|
|
||||||
let value = program.get_non_code_meta_for_position(50);
|
let value = program.get_non_code_meta_for_position(50);
|
||||||
|
|
||||||
@ -3237,7 +3209,7 @@ const cylinder = startSketchOn('-XZ')
|
|||||||
}, %)
|
}, %)
|
||||||
|> extrude(h, %)
|
|> extrude(h, %)
|
||||||
"#;
|
"#;
|
||||||
let program = crate::parser::top_level_parse(some_program_string).unwrap();
|
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||||
|
|
||||||
let value = program.get_non_code_meta_for_position(124);
|
let value = program.get_non_code_meta_for_position(124);
|
||||||
|
|
||||||
@ -3250,7 +3222,7 @@ const cylinder = startSketchOn('-XZ')
|
|||||||
|> startProfileAt([0,0], %)
|
|> startProfileAt([0,0], %)
|
||||||
|> xLine(5, %) // lin
|
|> xLine(5, %) // lin
|
||||||
"#;
|
"#;
|
||||||
let program = crate::parser::top_level_parse(some_program_string).unwrap();
|
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||||
|
|
||||||
let value = program.get_non_code_meta_for_position(86);
|
let value = program.get_non_code_meta_for_position(86);
|
||||||
|
|
||||||
@ -3262,7 +3234,7 @@ const cylinder = startSketchOn('-XZ')
|
|||||||
let some_program_string = r#"fn thing = (arg0: number, arg1: string, tag?: string) => {
|
let some_program_string = r#"fn thing = (arg0: number, arg1: string, tag?: string) => {
|
||||||
return arg0
|
return arg0
|
||||||
}"#;
|
}"#;
|
||||||
let program = crate::parser::top_level_parse(some_program_string).unwrap();
|
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||||
|
|
||||||
// Check the program output for the types of the parameters.
|
// Check the program output for the types of the parameters.
|
||||||
let function = program.body.first().unwrap();
|
let function = program.body.first().unwrap();
|
||||||
@ -3284,7 +3256,7 @@ const cylinder = startSketchOn('-XZ')
|
|||||||
let some_program_string = r#"fn thing = (arg0: number[], arg1: string[], tag?: string) => {
|
let some_program_string = r#"fn thing = (arg0: number[], arg1: string[], tag?: string) => {
|
||||||
return arg0
|
return arg0
|
||||||
}"#;
|
}"#;
|
||||||
let program = crate::parser::top_level_parse(some_program_string).unwrap();
|
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||||
|
|
||||||
// Check the program output for the types of the parameters.
|
// Check the program output for the types of the parameters.
|
||||||
let function = program.body.first().unwrap();
|
let function = program.body.first().unwrap();
|
||||||
@ -3307,7 +3279,7 @@ const cylinder = startSketchOn('-XZ')
|
|||||||
return arg0
|
return arg0
|
||||||
}"#;
|
}"#;
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let program = crate::parser::parse_str(some_program_string, module_id).unwrap();
|
let program = crate::parsing::parse_str(some_program_string, module_id).unwrap();
|
||||||
|
|
||||||
// Check the program output for the types of the parameters.
|
// Check the program output for the types of the parameters.
|
||||||
let function = program.body.first().unwrap();
|
let function = program.body.first().unwrap();
|
||||||
@ -3378,7 +3350,7 @@ const cylinder = startSketchOn('-XZ')
|
|||||||
return 1
|
return 1
|
||||||
}"#;
|
}"#;
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let program = crate::parser::parse_str(some_program_string, module_id).unwrap();
|
let program = crate::parsing::parse_str(some_program_string, module_id).unwrap();
|
||||||
|
|
||||||
// Check the program output for the types of the parameters.
|
// Check the program output for the types of the parameters.
|
||||||
let function = program.body.first().unwrap();
|
let function = program.body.first().unwrap();
|
||||||
@ -3566,7 +3538,7 @@ const cylinder = startSketchOn('-XZ')
|
|||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn test_parse_object_bool() {
|
async fn test_parse_object_bool() {
|
||||||
let some_program_string = r#"some_func({thing: true, other_thing: false})"#;
|
let some_program_string = r#"some_func({thing: true, other_thing: false})"#;
|
||||||
let program = crate::parser::top_level_parse(some_program_string).unwrap();
|
let program = crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||||
|
|
||||||
// We want to get the bool and verify it is a bool.
|
// We want to get the bool and verify it is a bool.
|
||||||
|
|
||||||
@ -3607,29 +3579,4 @@ const cylinder = startSketchOn('-XZ')
|
|||||||
|
|
||||||
assert_eq!(l.raw, "false");
|
assert_eq!(l.raw, "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
|
||||||
async fn test_parse_digest() {
|
|
||||||
let prog1_string = r#"startSketchOn('XY')
|
|
||||||
|> startProfileAt([0, 0], %)
|
|
||||||
|> line([5, 5], %)
|
|
||||||
"#;
|
|
||||||
let prog1_digest = crate::parser::top_level_parse(prog1_string).unwrap().compute_digest();
|
|
||||||
|
|
||||||
let prog2_string = r#"startSketchOn('XY')
|
|
||||||
|> startProfileAt([0, 2], %)
|
|
||||||
|> line([5, 5], %)
|
|
||||||
"#;
|
|
||||||
let prog2_digest = crate::parser::top_level_parse(prog2_string).unwrap().compute_digest();
|
|
||||||
|
|
||||||
assert!(prog1_digest != prog2_digest);
|
|
||||||
|
|
||||||
let prog3_string = r#"startSketchOn('XY')
|
|
||||||
|> startProfileAt([0, 0], %)
|
|
||||||
|> line([5, 5], %)
|
|
||||||
"#;
|
|
||||||
let prog3_digest = crate::parser::top_level_parse(prog3_string).unwrap().compute_digest();
|
|
||||||
|
|
||||||
assert_eq!(prog1_digest, prog3_digest);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ use schemars::JsonSchema;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::Node;
|
use super::Node;
|
||||||
use crate::{ast::types::ConstraintLevel, executor::KclValue};
|
use crate::{executor::KclValue, parsing::ast::types::ConstraintLevel};
|
||||||
|
|
||||||
const KCL_NONE_ID: &str = "KCL_NONE_ID";
|
const KCL_NONE_ID: &str = "KCL_NONE_ID";
|
||||||
|
|
@ -2,7 +2,7 @@ use winnow::{error::StrContext, stream::Stream};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
token::Token,
|
parsing::token::Token,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
};
|
};
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
ast::types::{BinaryExpression, BinaryOperator, BinaryPart, Node},
|
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
|
parsing::ast::types::{BinaryExpression, BinaryOperator, BinaryPart, Node},
|
||||||
SourceRange,
|
SourceRange,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -126,7 +126,8 @@ impl From<BinaryOperator> for BinaryExpressionToken {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{ast::types::Literal, source_range::ModuleId};
|
use crate::parsing::ast::types::Literal;
|
||||||
|
use crate::source_range::ModuleId;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_and_evaluate() {
|
fn parse_and_evaluate() {
|
@ -1,15 +1,19 @@
|
|||||||
use parser_impl::ParseContext;
|
use parser::ParseContext;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::types::{Node, Program},
|
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
|
parsing::{
|
||||||
|
ast::types::{Node, Program},
|
||||||
|
token::{Token, TokenType},
|
||||||
|
},
|
||||||
source_range::{ModuleId, SourceRange},
|
source_range::{ModuleId, SourceRange},
|
||||||
token::{Token, TokenType},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mod bad_inputs;
|
pub(crate) mod ast;
|
||||||
|
mod error;
|
||||||
mod math;
|
mod math;
|
||||||
pub(crate) mod parser_impl;
|
pub(crate) mod parser;
|
||||||
|
pub(crate) mod token;
|
||||||
|
|
||||||
pub const PIPE_SUBSTITUTION_OPERATOR: &str = "%";
|
pub const PIPE_SUBSTITUTION_OPERATOR: &str = "%";
|
||||||
pub const PIPE_OPERATOR: &str = "|>";
|
pub const PIPE_OPERATOR: &str = "|>";
|
||||||
@ -33,7 +37,7 @@ pub fn top_level_parse(code: &str) -> ParseResult {
|
|||||||
|
|
||||||
/// Parse the given KCL code into an AST.
|
/// Parse the given KCL code into an AST.
|
||||||
pub fn parse_str(code: &str, module_id: ModuleId) -> ParseResult {
|
pub fn parse_str(code: &str, module_id: ModuleId) -> ParseResult {
|
||||||
let tokens = pr_try!(crate::token::lexer(code, module_id));
|
let tokens = pr_try!(crate::parsing::token::lexer(code, module_id));
|
||||||
parse_tokens(tokens)
|
parse_tokens(tokens)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +72,7 @@ pub fn parse_tokens(tokens: Vec<Token>) -> ParseResult {
|
|||||||
return Node::<Program>::default().into();
|
return Node::<Program>::default().into();
|
||||||
}
|
}
|
||||||
|
|
||||||
parser_impl::run_parser(&mut tokens.as_slice())
|
parser::run_parser(&mut tokens.as_slice())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Result of parsing.
|
/// Result of parsing.
|
||||||
@ -104,7 +108,7 @@ impl ParseResult {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn unwrap_errs(&self) -> &[parser_impl::error::ParseError] {
|
pub fn unwrap_errs(&self) -> &[error::ParseError] {
|
||||||
&self.0.as_ref().unwrap().1.errors
|
&self.0.as_ref().unwrap().1.errors
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,3 +149,18 @@ impl From<KclError> for ParseResult {
|
|||||||
ParseResult(Err(e))
|
ParseResult(Err(e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
macro_rules! parse_and_lex {
|
||||||
|
($func_name:ident, $test_kcl_program:expr) => {
|
||||||
|
#[test]
|
||||||
|
fn $func_name() {
|
||||||
|
let _ = crate::parsing::top_level_parse($test_kcl_program);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_and_lex!(crash_eof_1, "{\"ގގ\0\0\0\"\".");
|
||||||
|
parse_and_lex!(crash_eof_2, "(/=e\"\u{616}ݝ\"\"");
|
||||||
|
}
|
@ -8,27 +8,29 @@ use winnow::{
|
|||||||
token::{any, one_of, take_till},
|
token::{any, one_of, take_till},
|
||||||
};
|
};
|
||||||
|
|
||||||
use self::error::ParseError;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::types::{
|
|
||||||
ArrayExpression, ArrayRangeExpression, BinaryExpression, BinaryOperator, BinaryPart, BodyItem, BoxNode,
|
|
||||||
CallExpression, CallExpressionKw, CommentStyle, ElseIf, Expr, ExpressionStatement, FnArgPrimitive, FnArgType,
|
|
||||||
FunctionExpression, Identifier, IfExpression, ImportItem, ImportStatement, ItemVisibility, LabeledArg, Literal,
|
|
||||||
LiteralIdentifier, LiteralValue, MemberExpression, MemberObject, Node, NonCodeMeta, NonCodeNode, NonCodeValue,
|
|
||||||
ObjectExpression, ObjectProperty, Parameter, PipeExpression, PipeSubstitution, Program, ReturnStatement,
|
|
||||||
Shebang, TagDeclarator, UnaryExpression, UnaryOperator, VariableDeclaration, VariableDeclarator, VariableKind,
|
|
||||||
},
|
|
||||||
docs::StdLibFn,
|
docs::StdLibFn,
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
parser::{
|
parsing::{
|
||||||
math::BinaryExpressionToken, parser_impl::error::ContextError, PIPE_OPERATOR, PIPE_SUBSTITUTION_OPERATOR,
|
ast::types::{
|
||||||
|
ArrayExpression, ArrayRangeExpression, BinaryExpression, BinaryOperator, BinaryPart, BodyItem, BoxNode,
|
||||||
|
CallExpression, CallExpressionKw, CommentStyle, ElseIf, Expr, ExpressionStatement, FnArgPrimitive,
|
||||||
|
FnArgType, FunctionExpression, Identifier, IfExpression, ImportItem, ImportStatement, ItemVisibility,
|
||||||
|
Literal, LiteralIdentifier, LiteralValue, MemberExpression, MemberObject, Node, NonCodeMeta, NonCodeNode,
|
||||||
|
NonCodeValue, ObjectExpression, ObjectProperty, Parameter, PipeExpression, PipeSubstitution, Program,
|
||||||
|
ReturnStatement, Shebang, TagDeclarator, UnaryExpression, UnaryOperator, VariableDeclaration,
|
||||||
|
VariableDeclarator, VariableKind,
|
||||||
|
},
|
||||||
|
error::{self, ContextError, ParseError},
|
||||||
|
math::BinaryExpressionToken,
|
||||||
|
token::{Token, TokenType},
|
||||||
|
PIPE_OPERATOR, PIPE_SUBSTITUTION_OPERATOR,
|
||||||
},
|
},
|
||||||
token::{Token, TokenType},
|
|
||||||
unparser::ExprContext,
|
unparser::ExprContext,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) mod error;
|
use super::ast::types::LabeledArg;
|
||||||
|
|
||||||
thread_local! {
|
thread_local! {
|
||||||
/// The current `ParseContext`. `None` if parsing is not currently happening on this thread.
|
/// The current `ParseContext`. `None` if parsing is not currently happening on this thread.
|
||||||
@ -2288,14 +2290,14 @@ mod tests {
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::types::{BodyItem, Expr, VariableKind},
|
parsing::ast::types::{BodyItem, Expr, VariableKind},
|
||||||
ModuleId,
|
ModuleId,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn assert_reserved(word: &str) {
|
fn assert_reserved(word: &str) {
|
||||||
// Try to use it as a variable name.
|
// Try to use it as a variable name.
|
||||||
let code = format!(r#"{} = 0"#, word);
|
let code = format!(r#"{} = 0"#, word);
|
||||||
let result = crate::parser::top_level_parse(code.as_str());
|
let result = crate::parsing::top_level_parse(code.as_str());
|
||||||
let err = &result.unwrap_errs()[0];
|
let err = &result.unwrap_errs()[0];
|
||||||
// Which token causes the error may change. In "return = 0", for
|
// Which token causes the error may change. In "return = 0", for
|
||||||
// example, "return" is the problem.
|
// example, "return" is the problem.
|
||||||
@ -2313,7 +2315,7 @@ mod tests {
|
|||||||
fn reserved_words() {
|
fn reserved_words() {
|
||||||
// Since these are stored in a set, we sort to make the tests
|
// Since these are stored in a set, we sort to make the tests
|
||||||
// deterministic.
|
// deterministic.
|
||||||
for word in crate::token::RESERVED_WORDS.keys().sorted() {
|
for word in crate::parsing::token::RESERVED_WORDS.keys().sorted() {
|
||||||
assert_reserved(word);
|
assert_reserved(word);
|
||||||
}
|
}
|
||||||
assert_reserved("import");
|
assert_reserved("import");
|
||||||
@ -2322,7 +2324,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn parse_args() {
|
fn parse_args() {
|
||||||
for (i, (test, expected_len)) in [("someVar", 1), ("5, 3", 2), (r#""a""#, 1)].into_iter().enumerate() {
|
for (i, (test, expected_len)) in [("someVar", 1), ("5, 3", 2), (r#""a""#, 1)].into_iter().enumerate() {
|
||||||
let tokens = crate::token::lexer(test, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test, ModuleId::default()).unwrap();
|
||||||
let actual = match arguments.parse(&tokens) {
|
let actual = match arguments.parse(&tokens) {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(e) => panic!("Failed test {i}, could not parse function arguments from \"{test}\": {e:?}"),
|
Err(e) => panic!("Failed test {i}, could not parse function arguments from \"{test}\": {e:?}"),
|
||||||
@ -2333,7 +2335,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn weird_program_unclosed_paren() {
|
fn weird_program_unclosed_paren() {
|
||||||
let tokens = crate::token::lexer("fn firstPrime(", ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer("fn firstPrime(", ModuleId::default()).unwrap();
|
||||||
let last = tokens.last().unwrap();
|
let last = tokens.last().unwrap();
|
||||||
let err: super::error::ErrorKind = program.parse(&tokens).unwrap_err().into();
|
let err: super::error::ErrorKind = program.parse(&tokens).unwrap_err().into();
|
||||||
let err = err.unwrap_parse_error();
|
let err = err.unwrap_parse_error();
|
||||||
@ -2345,7 +2347,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn weird_program_just_a_pipe() {
|
fn weird_program_just_a_pipe() {
|
||||||
let tokens = crate::token::lexer("|", ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer("|", ModuleId::default()).unwrap();
|
||||||
let err: super::error::ErrorKind = program.parse(&tokens).unwrap_err().into();
|
let err: super::error::ErrorKind = program.parse(&tokens).unwrap_err().into();
|
||||||
let err = err.unwrap_parse_error();
|
let err = err.unwrap_parse_error();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -2358,7 +2360,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn parse_binary_expressions() {
|
fn parse_binary_expressions() {
|
||||||
for (i, test_program) in ["1 + 2 + 3"].into_iter().enumerate() {
|
for (i, test_program) in ["1 + 2 + 3"].into_iter().enumerate() {
|
||||||
let tokens = crate::token::lexer(test_program, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, ModuleId::default()).unwrap();
|
||||||
let mut slice = tokens.as_slice();
|
let mut slice = tokens.as_slice();
|
||||||
let _actual = match binary_expression.parse_next(&mut slice) {
|
let _actual = match binary_expression.parse_next(&mut slice) {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
@ -2369,7 +2371,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_vardec_no_keyword() {
|
fn test_vardec_no_keyword() {
|
||||||
let tokens = crate::token::lexer("x = 4", ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer("x = 4", ModuleId::default()).unwrap();
|
||||||
let vardec = declaration(&mut tokens.as_slice()).unwrap();
|
let vardec = declaration(&mut tokens.as_slice()).unwrap();
|
||||||
assert_eq!(vardec.inner.kind, VariableKind::Const);
|
assert_eq!(vardec.inner.kind, VariableKind::Const);
|
||||||
let vardec = vardec.declarations.first().unwrap();
|
let vardec = vardec.declarations.first().unwrap();
|
||||||
@ -2382,7 +2384,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_negative_operands() {
|
fn test_negative_operands() {
|
||||||
let tokens = crate::token::lexer("-leg2", ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer("-leg2", ModuleId::default()).unwrap();
|
||||||
let _s = operand.parse_next(&mut tokens.as_slice()).unwrap();
|
let _s = operand.parse_next(&mut tokens.as_slice()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2396,7 +2398,7 @@ mod tests {
|
|||||||
// comment 2
|
// comment 2
|
||||||
return 1
|
return 1
|
||||||
}"#;
|
}"#;
|
||||||
let tokens = crate::token::lexer(test_program, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, ModuleId::default()).unwrap();
|
||||||
let mut slice = tokens.as_slice();
|
let mut slice = tokens.as_slice();
|
||||||
let expr = function_decl.map(|t| t.0).parse_next(&mut slice).unwrap();
|
let expr = function_decl.map(|t| t.0).parse_next(&mut slice).unwrap();
|
||||||
assert_eq!(expr.params, vec![]);
|
assert_eq!(expr.params, vec![]);
|
||||||
@ -2414,7 +2416,7 @@ mod tests {
|
|||||||
const yo = { a = { b = { c = '123' } } } /* block
|
const yo = { a = { b = { c = '123' } } } /* block
|
||||||
comment */
|
comment */
|
||||||
}"#;
|
}"#;
|
||||||
let tokens = crate::token::lexer(test_program, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, ModuleId::default()).unwrap();
|
||||||
let mut slice = tokens.as_slice();
|
let mut slice = tokens.as_slice();
|
||||||
let expr = function_decl.map(|t| t.0).parse_next(&mut slice).unwrap();
|
let expr = function_decl.map(|t| t.0).parse_next(&mut slice).unwrap();
|
||||||
let comment0 = &expr.body.non_code_meta.non_code_nodes.get(&0).unwrap()[0];
|
let comment0 = &expr.body.non_code_meta.non_code_nodes.get(&0).unwrap()[0];
|
||||||
@ -2427,7 +2429,7 @@ comment */
|
|||||||
/* comment at start */
|
/* comment at start */
|
||||||
|
|
||||||
const mySk1 = startSketchAt([0, 0])"#;
|
const mySk1 = startSketchAt([0, 0])"#;
|
||||||
let tokens = crate::token::lexer(test_program, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, ModuleId::default()).unwrap();
|
||||||
let program = program.parse(&tokens).unwrap();
|
let program = program.parse(&tokens).unwrap();
|
||||||
let mut starting_comments = program.inner.non_code_meta.start_nodes;
|
let mut starting_comments = program.inner.non_code_meta.start_nodes;
|
||||||
assert_eq!(starting_comments.len(), 2);
|
assert_eq!(starting_comments.len(), 2);
|
||||||
@ -2445,7 +2447,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_comment_in_pipe() {
|
fn test_comment_in_pipe() {
|
||||||
let tokens = crate::token::lexer(r#"const x = y() |> /*hi*/ z(%)"#, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(r#"const x = y() |> /*hi*/ z(%)"#, ModuleId::default()).unwrap();
|
||||||
let mut body = program.parse(&tokens).unwrap().inner.body;
|
let mut body = program.parse(&tokens).unwrap().inner.body;
|
||||||
let BodyItem::VariableDeclaration(mut item) = body.remove(0) else {
|
let BodyItem::VariableDeclaration(mut item) = body.remove(0) else {
|
||||||
panic!("expected vardec");
|
panic!("expected vardec");
|
||||||
@ -2472,7 +2474,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
return sg
|
return sg
|
||||||
return sg
|
return sg
|
||||||
}"#;
|
}"#;
|
||||||
let tokens = crate::token::lexer(test_program, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, ModuleId::default()).unwrap();
|
||||||
let mut slice = tokens.as_slice();
|
let mut slice = tokens.as_slice();
|
||||||
let _expr = function_decl.parse_next(&mut slice).unwrap();
|
let _expr = function_decl.parse_next(&mut slice).unwrap();
|
||||||
}
|
}
|
||||||
@ -2484,7 +2486,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
return 2
|
return 2
|
||||||
}";
|
}";
|
||||||
let module_id = ModuleId::from_usize(1);
|
let module_id = ModuleId::from_usize(1);
|
||||||
let tokens = crate::token::lexer(test_program, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, module_id).unwrap();
|
||||||
let mut slice = tokens.as_slice();
|
let mut slice = tokens.as_slice();
|
||||||
let expr = function_decl.map(|t| t.0).parse_next(&mut slice).unwrap();
|
let expr = function_decl.map(|t| t.0).parse_next(&mut slice).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -2549,7 +2551,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
|> c(%) // inline-comment
|
|> c(%) // inline-comment
|
||||||
|> d(%)"#;
|
|> d(%)"#;
|
||||||
|
|
||||||
let tokens = crate::token::lexer(test_input, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_input, ModuleId::default()).unwrap();
|
||||||
let mut slice = tokens.as_slice();
|
let mut slice = tokens.as_slice();
|
||||||
let Node {
|
let Node {
|
||||||
inner: PipeExpression {
|
inner: PipeExpression {
|
||||||
@ -2580,7 +2582,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
"#;
|
"#;
|
||||||
|
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let tokens = crate::token::lexer(test_program, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, module_id).unwrap();
|
||||||
let Program { non_code_meta, .. } = function_body.parse(&tokens).unwrap().inner;
|
let Program { non_code_meta, .. } = function_body.parse(&tokens).unwrap().inner;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
vec![Node::new(
|
vec![Node::new(
|
||||||
@ -2648,7 +2650,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
comment */
|
comment */
|
||||||
return 1"#;
|
return 1"#;
|
||||||
|
|
||||||
let tokens = crate::token::lexer(test_program, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, ModuleId::default()).unwrap();
|
||||||
let actual = program.parse(&tokens).unwrap();
|
let actual = program.parse(&tokens).unwrap();
|
||||||
assert_eq!(actual.non_code_meta.non_code_nodes.len(), 1);
|
assert_eq!(actual.non_code_meta.non_code_nodes.len(), 1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -2663,7 +2665,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_bracketed_binary_expression() {
|
fn test_bracketed_binary_expression() {
|
||||||
let input = "(2 - 3)";
|
let input = "(2 - 3)";
|
||||||
let tokens = crate::token::lexer(input, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(input, ModuleId::default()).unwrap();
|
||||||
let actual = match binary_expr_in_parens.parse(&tokens) {
|
let actual = match binary_expr_in_parens.parse(&tokens) {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(e) => panic!("{e:?}"),
|
Err(e) => panic!("{e:?}"),
|
||||||
@ -2678,7 +2680,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
"6 / ( sigmaAllow * width )",
|
"6 / ( sigmaAllow * width )",
|
||||||
"sqrt(distance * p * FOS * 6 / ( sigmaAllow * width ))",
|
"sqrt(distance * p * FOS * 6 / ( sigmaAllow * width ))",
|
||||||
] {
|
] {
|
||||||
let tokens = crate::token::lexer(input, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(input, ModuleId::default()).unwrap();
|
||||||
let _actual = match expression.parse(&tokens) {
|
let _actual = match expression.parse(&tokens) {
|
||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(e) => panic!("{e:?}"),
|
Err(e) => panic!("{e:?}"),
|
||||||
@ -2689,7 +2691,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_arithmetic() {
|
fn test_arithmetic() {
|
||||||
let input = "1 * (2 - 3)";
|
let input = "1 * (2 - 3)";
|
||||||
let tokens = crate::token::lexer(input, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(input, ModuleId::default()).unwrap();
|
||||||
// The RHS should be a binary expression.
|
// The RHS should be a binary expression.
|
||||||
let actual = binary_expression.parse(&tokens).unwrap();
|
let actual = binary_expression.parse(&tokens).unwrap();
|
||||||
assert_eq!(actual.operator, BinaryOperator::Mul);
|
assert_eq!(actual.operator, BinaryOperator::Mul);
|
||||||
@ -2717,7 +2719,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
{
|
{
|
||||||
let tokens = crate::token::lexer(test_input, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_input, ModuleId::default()).unwrap();
|
||||||
let mut actual = match declaration.parse(&tokens) {
|
let mut actual = match declaration.parse(&tokens) {
|
||||||
Err(e) => panic!("Could not parse test {i}: {e:#?}"),
|
Err(e) => panic!("Could not parse test {i}: {e:#?}"),
|
||||||
Ok(a) => a,
|
Ok(a) => a,
|
||||||
@ -2735,7 +2737,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_function_call() {
|
fn test_function_call() {
|
||||||
for (i, test_input) in ["const x = f(1)", "const x = f( 1 )"].into_iter().enumerate() {
|
for (i, test_input) in ["const x = f(1)", "const x = f( 1 )"].into_iter().enumerate() {
|
||||||
let tokens = crate::token::lexer(test_input, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_input, ModuleId::default()).unwrap();
|
||||||
let _actual = match declaration.parse(&tokens) {
|
let _actual = match declaration.parse(&tokens) {
|
||||||
Err(e) => panic!("Could not parse test {i}: {e:#?}"),
|
Err(e) => panic!("Could not parse test {i}: {e:#?}"),
|
||||||
Ok(a) => a,
|
Ok(a) => a,
|
||||||
@ -2746,7 +2748,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_nested_arithmetic() {
|
fn test_nested_arithmetic() {
|
||||||
let input = "1 * ((2 - 3) / 4)";
|
let input = "1 * ((2 - 3) / 4)";
|
||||||
let tokens = crate::token::lexer(input, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(input, ModuleId::default()).unwrap();
|
||||||
// The RHS should be a binary expression.
|
// The RHS should be a binary expression.
|
||||||
let outer = binary_expression.parse(&tokens).unwrap();
|
let outer = binary_expression.parse(&tokens).unwrap();
|
||||||
assert_eq!(outer.operator, BinaryOperator::Mul);
|
assert_eq!(outer.operator, BinaryOperator::Mul);
|
||||||
@ -2765,7 +2767,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
fn binary_expression_ignores_whitespace() {
|
fn binary_expression_ignores_whitespace() {
|
||||||
let tests = ["1 - 2", "1- 2", "1 -2", "1-2"];
|
let tests = ["1 - 2", "1- 2", "1 -2", "1-2"];
|
||||||
for test in tests {
|
for test in tests {
|
||||||
let tokens = crate::token::lexer(test, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test, ModuleId::default()).unwrap();
|
||||||
let actual = binary_expression.parse(&tokens).unwrap();
|
let actual = binary_expression.parse(&tokens).unwrap();
|
||||||
assert_eq!(actual.operator, BinaryOperator::Sub);
|
assert_eq!(actual.operator, BinaryOperator::Sub);
|
||||||
let BinaryPart::Literal(left) = actual.inner.left else {
|
let BinaryPart::Literal(left) = actual.inner.left else {
|
||||||
@ -2786,7 +2788,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
a comment
|
a comment
|
||||||
spanning a few lines */
|
spanning a few lines */
|
||||||
|> z(%)"#;
|
|> z(%)"#;
|
||||||
let tokens = crate::token::lexer(test_program, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, ModuleId::default()).unwrap();
|
||||||
let actual = pipe_expression.parse(&tokens).unwrap();
|
let actual = pipe_expression.parse(&tokens).unwrap();
|
||||||
let n = actual.non_code_meta.non_code_nodes.len();
|
let n = actual.non_code_meta.non_code_nodes.len();
|
||||||
assert_eq!(n, 1, "expected one comment in pipe expression but found {n}");
|
assert_eq!(n, 1, "expected one comment in pipe expression but found {n}");
|
||||||
@ -2814,7 +2816,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
{
|
{
|
||||||
let tokens = crate::token::lexer(test_program, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, ModuleId::default()).unwrap();
|
||||||
let actual = pipe_expression.parse(&tokens);
|
let actual = pipe_expression.parse(&tokens);
|
||||||
assert!(actual.is_ok(), "could not parse test {i}, '{test_program}'");
|
assert!(actual.is_ok(), "could not parse test {i}, '{test_program}'");
|
||||||
let actual = actual.unwrap();
|
let actual = actual.unwrap();
|
||||||
@ -2959,7 +2961,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
{
|
{
|
||||||
let tokens = crate::token::lexer(test_program, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, module_id).unwrap();
|
||||||
let actual = non_code_node.parse(&tokens);
|
let actual = non_code_node.parse(&tokens);
|
||||||
assert!(actual.is_ok(), "could not parse test {i}: {actual:#?}");
|
assert!(actual.is_ok(), "could not parse test {i}: {actual:#?}");
|
||||||
let actual = actual.unwrap();
|
let actual = actual.unwrap();
|
||||||
@ -2971,7 +2973,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
fn recognize_invalid_params() {
|
fn recognize_invalid_params() {
|
||||||
let test_fn = "(let) => { return 1 }";
|
let test_fn = "(let) => { return 1 }";
|
||||||
let module_id = ModuleId::from_usize(2);
|
let module_id = ModuleId::from_usize(2);
|
||||||
let tokens = crate::token::lexer(test_fn, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer(test_fn, module_id).unwrap();
|
||||||
let err = function_decl.parse(&tokens).unwrap_err().into_inner();
|
let err = function_decl.parse(&tokens).unwrap_err().into_inner();
|
||||||
let cause = err.cause.unwrap();
|
let cause = err.cause.unwrap();
|
||||||
// This is the token `let`
|
// This is the token `let`
|
||||||
@ -2987,7 +2989,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
let string_literal = r#""
|
let string_literal = r#""
|
||||||
// a comment
|
// a comment
|
||||||
""#;
|
""#;
|
||||||
let tokens = crate::token::lexer(string_literal, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(string_literal, ModuleId::default()).unwrap();
|
||||||
let parsed_literal = literal.parse(&tokens).unwrap();
|
let parsed_literal = literal.parse(&tokens).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parsed_literal.value,
|
parsed_literal.value,
|
||||||
@ -3004,7 +3006,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
|> lineTo([0, -0], %) // MoveRelative
|
|> lineTo([0, -0], %) // MoveRelative
|
||||||
|
|
||||||
"#;
|
"#;
|
||||||
let tokens = crate::token::lexer(test_program, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, ModuleId::default()).unwrap();
|
||||||
let mut slice = &tokens[..];
|
let mut slice = &tokens[..];
|
||||||
let _actual = pipe_expression.parse_next(&mut slice).unwrap();
|
let _actual = pipe_expression.parse_next(&mut slice).unwrap();
|
||||||
assert_eq!(slice[0].token_type, TokenType::Whitespace);
|
assert_eq!(slice[0].token_type, TokenType::Whitespace);
|
||||||
@ -3013,14 +3015,14 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_pipes_on_pipes() {
|
fn test_pipes_on_pipes() {
|
||||||
let test_program = include_str!("../../../tests/executor/inputs/pipes_on_pipes.kcl");
|
let test_program = include_str!("../../../tests/executor/inputs/pipes_on_pipes.kcl");
|
||||||
let tokens = crate::token::lexer(test_program, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, ModuleId::default()).unwrap();
|
||||||
let _ = run_parser(&mut &*tokens).unwrap();
|
let _ = run_parser(&mut &*tokens).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cube() {
|
fn test_cube() {
|
||||||
let test_program = include_str!("../../../tests/executor/inputs/cube.kcl");
|
let test_program = include_str!("../../../tests/executor/inputs/cube.kcl");
|
||||||
let tokens = crate::token::lexer(test_program, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test_program, ModuleId::default()).unwrap();
|
||||||
match program.parse(&tokens) {
|
match program.parse(&tokens) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@ -3038,7 +3040,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
("a,b", vec!["a", "b"]),
|
("a,b", vec!["a", "b"]),
|
||||||
];
|
];
|
||||||
for (i, (input, expected)) in tests.into_iter().enumerate() {
|
for (i, (input, expected)) in tests.into_iter().enumerate() {
|
||||||
let tokens = crate::token::lexer(input, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(input, ModuleId::default()).unwrap();
|
||||||
let actual = parameters.parse(&tokens);
|
let actual = parameters.parse(&tokens);
|
||||||
assert!(actual.is_ok(), "could not parse test {i}");
|
assert!(actual.is_ok(), "could not parse test {i}");
|
||||||
let actual_ids: Vec<_> = actual.unwrap().into_iter().map(|p| p.identifier.inner.name).collect();
|
let actual_ids: Vec<_> = actual.unwrap().into_iter().map(|p| p.identifier.inner.name).collect();
|
||||||
@ -3052,7 +3054,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
return 2
|
return 2
|
||||||
}";
|
}";
|
||||||
|
|
||||||
let tokens = crate::token::lexer(input, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(input, ModuleId::default()).unwrap();
|
||||||
let actual = function_decl.parse(&tokens);
|
let actual = function_decl.parse(&tokens);
|
||||||
assert!(actual.is_ok(), "could not parse test function");
|
assert!(actual.is_ok(), "could not parse test function");
|
||||||
}
|
}
|
||||||
@ -3062,8 +3064,8 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
let tests = ["const myVar = 5", "const myVar=5", "const myVar =5", "const myVar= 5"];
|
let tests = ["const myVar = 5", "const myVar=5", "const myVar =5", "const myVar= 5"];
|
||||||
for test in tests {
|
for test in tests {
|
||||||
// Run the original parser
|
// Run the original parser
|
||||||
let tokens = crate::token::lexer(test, ModuleId::default()).unwrap();
|
let tokens = crate::parsing::token::lexer(test, ModuleId::default()).unwrap();
|
||||||
let mut expected_body = crate::parser::parse_tokens(tokens.clone()).unwrap().inner.body;
|
let mut expected_body = crate::parsing::parse_tokens(tokens.clone()).unwrap().inner.body;
|
||||||
assert_eq!(expected_body.len(), 1);
|
assert_eq!(expected_body.len(), 1);
|
||||||
let BodyItem::VariableDeclaration(expected) = expected_body.pop().unwrap() else {
|
let BodyItem::VariableDeclaration(expected) = expected_body.pop().unwrap() else {
|
||||||
panic!("Expected variable declaration");
|
panic!("Expected variable declaration");
|
||||||
@ -3090,7 +3092,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_math_parse() {
|
fn test_math_parse() {
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let actual = crate::parser::parse_str(r#"5 + "a""#, module_id).unwrap().inner.body;
|
let actual = crate::parsing::parse_str(r#"5 + "a""#, module_id).unwrap().inner.body;
|
||||||
let expr = Node::boxed(
|
let expr = Node::boxed(
|
||||||
BinaryExpression {
|
BinaryExpression {
|
||||||
operator: BinaryOperator::Add,
|
operator: BinaryOperator::Add,
|
||||||
@ -3226,7 +3228,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
fn test_abstract_syntax_tree() {
|
fn test_abstract_syntax_tree() {
|
||||||
let code = "5 +6";
|
let code = "5 +6";
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let result = crate::parser::parse_str(code, module_id).unwrap();
|
let result = crate::parsing::parse_str(code, module_id).unwrap();
|
||||||
let expected_result = Node::new(
|
let expected_result = Node::new(
|
||||||
Program {
|
Program {
|
||||||
body: vec![BodyItem::ExpressionStatement(Node::new(
|
body: vec![BodyItem::ExpressionStatement(Node::new(
|
||||||
@ -3281,13 +3283,13 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_empty_file() {
|
fn test_empty_file() {
|
||||||
let some_program_string = r#""#;
|
let some_program_string = r#""#;
|
||||||
let result = crate::parser::top_level_parse(some_program_string);
|
let result = crate::parsing::top_level_parse(some_program_string);
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn assert_no_err(p: &str) -> (Node<Program>, ParseContext) {
|
fn assert_no_err(p: &str) -> (Node<Program>, ParseContext) {
|
||||||
let result = crate::parser::top_level_parse(p);
|
let result = crate::parsing::top_level_parse(p);
|
||||||
let result = result.0.unwrap();
|
let result = result.0.unwrap();
|
||||||
assert!(result.1.errors.is_empty(), "found: {:#?}", result.1.errors);
|
assert!(result.1.errors.is_empty(), "found: {:#?}", result.1.errors);
|
||||||
(result.0.unwrap(), result.1)
|
(result.0.unwrap(), result.1)
|
||||||
@ -3295,7 +3297,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn assert_err(p: &str, msg: &str, src: [usize; 2]) {
|
fn assert_err(p: &str, msg: &str, src: [usize; 2]) {
|
||||||
let result = crate::parser::top_level_parse(p);
|
let result = crate::parsing::top_level_parse(p);
|
||||||
let err = &result.unwrap_errs()[0];
|
let err = &result.unwrap_errs()[0];
|
||||||
assert_eq!(err.message, msg);
|
assert_eq!(err.message, msg);
|
||||||
assert_eq!(err.source_range.start(), src[0]);
|
assert_eq!(err.source_range.start(), src[0]);
|
||||||
@ -3304,7 +3306,7 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn assert_err_contains(p: &str, expected: &str) {
|
fn assert_err_contains(p: &str, expected: &str) {
|
||||||
let result = crate::parser::top_level_parse(p);
|
let result = crate::parsing::top_level_parse(p);
|
||||||
let err = &result.unwrap_errs()[0].message;
|
let err = &result.unwrap_errs()[0].message;
|
||||||
assert!(err.contains(expected), "actual='{err}'");
|
assert!(err.contains(expected), "actual='{err}'");
|
||||||
}
|
}
|
||||||
@ -3322,14 +3324,14 @@ const mySk1 = startSketchAt([0, 0])"#;
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_parse_member_expression_double_nested_braces() {
|
fn test_parse_member_expression_double_nested_braces() {
|
||||||
let code = r#"const prop = yo["one"][two]"#;
|
let code = r#"const prop = yo["one"][two]"#;
|
||||||
crate::parser::top_level_parse(code).unwrap();
|
crate::parsing::top_level_parse(code).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_member_expression_binary_expression_period_number_first() {
|
fn test_parse_member_expression_binary_expression_period_number_first() {
|
||||||
let code = r#"const obj = { a: 1, b: 2 }
|
let code = r#"const obj = { a: 1, b: 2 }
|
||||||
const height = 1 - obj.a"#;
|
const height = 1 - obj.a"#;
|
||||||
crate::parser::top_level_parse(code).unwrap();
|
crate::parsing::top_level_parse(code).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -3337,47 +3339,47 @@ const height = 1 - obj.a"#;
|
|||||||
let code = r#"const obj = { thing: 1 }
|
let code = r#"const obj = { thing: 1 }
|
||||||
startSketchOn(obj.sketch)"#;
|
startSketchOn(obj.sketch)"#;
|
||||||
|
|
||||||
crate::parser::top_level_parse(code).unwrap();
|
crate::parsing::top_level_parse(code).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_member_expression_binary_expression_brace_number_first() {
|
fn test_parse_member_expression_binary_expression_brace_number_first() {
|
||||||
let code = r#"const obj = { a: 1, b: 2 }
|
let code = r#"const obj = { a: 1, b: 2 }
|
||||||
const height = 1 - obj["a"]"#;
|
const height = 1 - obj["a"]"#;
|
||||||
crate::parser::top_level_parse(code).unwrap();
|
crate::parsing::top_level_parse(code).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_member_expression_binary_expression_brace_number_second() {
|
fn test_parse_member_expression_binary_expression_brace_number_second() {
|
||||||
let code = r#"const obj = { a: 1, b: 2 }
|
let code = r#"const obj = { a: 1, b: 2 }
|
||||||
const height = obj["a"] - 1"#;
|
const height = obj["a"] - 1"#;
|
||||||
crate::parser::top_level_parse(code).unwrap();
|
crate::parsing::top_level_parse(code).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_member_expression_binary_expression_in_array_number_first() {
|
fn test_parse_member_expression_binary_expression_in_array_number_first() {
|
||||||
let code = r#"const obj = { a: 1, b: 2 }
|
let code = r#"const obj = { a: 1, b: 2 }
|
||||||
const height = [1 - obj["a"], 0]"#;
|
const height = [1 - obj["a"], 0]"#;
|
||||||
crate::parser::top_level_parse(code).unwrap();
|
crate::parsing::top_level_parse(code).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_member_expression_binary_expression_in_array_number_second() {
|
fn test_parse_member_expression_binary_expression_in_array_number_second() {
|
||||||
let code = r#"const obj = { a: 1, b: 2 }
|
let code = r#"const obj = { a: 1, b: 2 }
|
||||||
const height = [obj["a"] - 1, 0]"#;
|
const height = [obj["a"] - 1, 0]"#;
|
||||||
crate::parser::top_level_parse(code).unwrap();
|
crate::parsing::top_level_parse(code).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_member_expression_binary_expression_in_array_number_second_missing_space() {
|
fn test_parse_member_expression_binary_expression_in_array_number_second_missing_space() {
|
||||||
let code = r#"const obj = { a: 1, b: 2 }
|
let code = r#"const obj = { a: 1, b: 2 }
|
||||||
const height = [obj["a"] -1, 0]"#;
|
const height = [obj["a"] -1, 0]"#;
|
||||||
crate::parser::top_level_parse(code).unwrap();
|
crate::parsing::top_level_parse(code).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_anon_fn() {
|
fn test_anon_fn() {
|
||||||
crate::parser::top_level_parse("foo(42, fn(x) { return x + 1 })").unwrap();
|
crate::parsing::top_level_parse("foo(42, fn(x) { return x + 1 })").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -3415,7 +3417,7 @@ const secondExtrude = startSketchOn('XY')
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_parens_unicode() {
|
fn test_parse_parens_unicode() {
|
||||||
let result = crate::parser::top_level_parse("(ޜ");
|
let result = crate::parsing::top_level_parse("(ޜ");
|
||||||
let KclError::Lexical(details) = result.0.unwrap_err() else {
|
let KclError::Lexical(details) = result.0.unwrap_err() else {
|
||||||
panic!();
|
panic!();
|
||||||
};
|
};
|
||||||
@ -3433,12 +3435,12 @@ const thickness = 0.56
|
|||||||
|
|
||||||
const bracket = [-leg2 + thickness, 0]
|
const bracket = [-leg2 + thickness, 0]
|
||||||
"#;
|
"#;
|
||||||
crate::parser::top_level_parse(code).unwrap();
|
crate::parsing::top_level_parse(code).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_nested_open_brackets() {
|
fn test_parse_nested_open_brackets() {
|
||||||
crate::parser::top_level_parse(
|
crate::parsing::top_level_parse(
|
||||||
r#"
|
r#"
|
||||||
z(-[["#,
|
z(-[["#,
|
||||||
)
|
)
|
||||||
@ -3625,14 +3627,14 @@ e
|
|||||||
}
|
}
|
||||||
firstPrimeNumber()
|
firstPrimeNumber()
|
||||||
"#;
|
"#;
|
||||||
let _ast = crate::parser::top_level_parse(code).unwrap();
|
let _ast = crate::parsing::top_level_parse(code).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn array() {
|
fn array() {
|
||||||
let program = r#"[1, 2, 3]"#;
|
let program = r#"[1, 2, 3]"#;
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let tokens = crate::token::lexer(program, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer(program, module_id).unwrap();
|
||||||
let mut sl: &[Token] = &tokens;
|
let mut sl: &[Token] = &tokens;
|
||||||
let _arr = array_elem_by_elem(&mut sl).unwrap();
|
let _arr = array_elem_by_elem(&mut sl).unwrap();
|
||||||
}
|
}
|
||||||
@ -3645,7 +3647,7 @@ e
|
|||||||
3,
|
3,
|
||||||
]"#;
|
]"#;
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let tokens = crate::token::lexer(program, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer(program, module_id).unwrap();
|
||||||
let mut sl: &[Token] = &tokens;
|
let mut sl: &[Token] = &tokens;
|
||||||
let _arr = array_elem_by_elem(&mut sl).unwrap();
|
let _arr = array_elem_by_elem(&mut sl).unwrap();
|
||||||
}
|
}
|
||||||
@ -3659,7 +3661,7 @@ e
|
|||||||
3
|
3
|
||||||
]"#;
|
]"#;
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let tokens = crate::token::lexer(program, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer(program, module_id).unwrap();
|
||||||
let mut sl: &[Token] = &tokens;
|
let mut sl: &[Token] = &tokens;
|
||||||
let _arr = array_elem_by_elem(&mut sl).unwrap();
|
let _arr = array_elem_by_elem(&mut sl).unwrap();
|
||||||
}
|
}
|
||||||
@ -3672,7 +3674,7 @@ e
|
|||||||
4
|
4
|
||||||
}";
|
}";
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let tokens = crate::token::lexer(some_program_string, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer(some_program_string, module_id).unwrap();
|
||||||
let mut sl: &[Token] = &tokens;
|
let mut sl: &[Token] = &tokens;
|
||||||
let _res = if_expr(&mut sl).unwrap();
|
let _res = if_expr(&mut sl).unwrap();
|
||||||
}
|
}
|
||||||
@ -3683,7 +3685,7 @@ e
|
|||||||
4
|
4
|
||||||
}";
|
}";
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let tokens = crate::token::lexer(some_program_string, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer(some_program_string, module_id).unwrap();
|
||||||
let mut sl: &[Token] = &tokens;
|
let mut sl: &[Token] = &tokens;
|
||||||
let _res = else_if(&mut sl).unwrap();
|
let _res = else_if(&mut sl).unwrap();
|
||||||
}
|
}
|
||||||
@ -3698,7 +3700,7 @@ e
|
|||||||
5
|
5
|
||||||
}";
|
}";
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let tokens = crate::token::lexer(some_program_string, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer(some_program_string, module_id).unwrap();
|
||||||
let mut sl: &[Token] = &tokens;
|
let mut sl: &[Token] = &tokens;
|
||||||
let _res = if_expr(&mut sl).unwrap();
|
let _res = if_expr(&mut sl).unwrap();
|
||||||
}
|
}
|
||||||
@ -3711,7 +3713,7 @@ e
|
|||||||
|
|
||||||
thing(false)
|
thing(false)
|
||||||
"#;
|
"#;
|
||||||
crate::parser::top_level_parse(some_program_string).unwrap();
|
crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -3752,7 +3754,7 @@ thing(false)
|
|||||||
|> line([-5.09, 12.33], %)
|
|> line([-5.09, 12.33], %)
|
||||||
asdasd
|
asdasd
|
||||||
"#;
|
"#;
|
||||||
crate::parser::top_level_parse(test_program).unwrap_errs();
|
crate::parsing::top_level_parse(test_program).unwrap_errs();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -3773,14 +3775,14 @@ const b2 = cube([3,3], 4)
|
|||||||
const pt1 = b1[0]
|
const pt1 = b1[0]
|
||||||
const pt2 = b2[0]
|
const pt2 = b2[0]
|
||||||
"#;
|
"#;
|
||||||
crate::parser::top_level_parse(some_program_string).unwrap();
|
crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_math_with_stdlib() {
|
fn test_math_with_stdlib() {
|
||||||
let some_program_string = r#"const d2r = pi() / 2
|
let some_program_string = r#"const d2r = pi() / 2
|
||||||
let other_thing = 2 * cos(3)"#;
|
let other_thing = 2 * cos(3)"#;
|
||||||
crate::parser::top_level_parse(some_program_string).unwrap();
|
crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -3798,7 +3800,7 @@ let other_thing = 2 * cos(3)"#;
|
|||||||
}
|
}
|
||||||
let myBox = box([0,0], -3, -16, -10)
|
let myBox = box([0,0], -3, -16, -10)
|
||||||
"#;
|
"#;
|
||||||
crate::parser::top_level_parse(some_program_string).unwrap();
|
crate::parsing::top_level_parse(some_program_string).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -3818,7 +3820,7 @@ let myBox = box([0,0], -3, -16, -10)
|
|||||||
fn arg_labels() {
|
fn arg_labels() {
|
||||||
let input = r#"length: 3"#;
|
let input = r#"length: 3"#;
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let tokens = crate::token::lexer(input, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer(input, module_id).unwrap();
|
||||||
let mut sl: &[Token] = &tokens;
|
let mut sl: &[Token] = &tokens;
|
||||||
super::labeled_arguments(&mut sl).unwrap();
|
super::labeled_arguments(&mut sl).unwrap();
|
||||||
}
|
}
|
||||||
@ -3827,7 +3829,7 @@ let myBox = box([0,0], -3, -16, -10)
|
|||||||
fn kw_fn() {
|
fn kw_fn() {
|
||||||
for input in ["val = foo(x, y: z)", "val = foo(y: z)"] {
|
for input in ["val = foo(x, y: z)", "val = foo(y: z)"] {
|
||||||
let module_id = ModuleId::default();
|
let module_id = ModuleId::default();
|
||||||
let tokens = crate::token::lexer(input, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer(input, module_id).unwrap();
|
||||||
let sl = &tokens;
|
let sl = &tokens;
|
||||||
super::program.parse(sl).unwrap();
|
super::program.parse(sl).unwrap();
|
||||||
}
|
}
|
||||||
@ -3900,7 +3902,6 @@ int(42.3)"#;
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod snapshot_math_tests {
|
mod snapshot_math_tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::ModuleId;
|
|
||||||
|
|
||||||
// This macro generates a test function with the given function name.
|
// This macro generates a test function with the given function name.
|
||||||
// The macro takes a KCL program, ensures it tokenizes and parses, then compares
|
// The macro takes a KCL program, ensures it tokenizes and parses, then compares
|
||||||
@ -3909,8 +3910,8 @@ mod snapshot_math_tests {
|
|||||||
($func_name:ident, $test_kcl_program:expr) => {
|
($func_name:ident, $test_kcl_program:expr) => {
|
||||||
#[test]
|
#[test]
|
||||||
fn $func_name() {
|
fn $func_name() {
|
||||||
let module_id = ModuleId::default();
|
let module_id = crate::ModuleId::default();
|
||||||
let tokens = crate::token::lexer($test_kcl_program, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer($test_kcl_program, module_id).unwrap();
|
||||||
ParseContext::init();
|
ParseContext::init();
|
||||||
|
|
||||||
let actual = match binary_expression.parse(&tokens) {
|
let actual = match binary_expression.parse(&tokens) {
|
||||||
@ -3939,7 +3940,6 @@ mod snapshot_math_tests {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod snapshot_tests {
|
mod snapshot_tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::ModuleId;
|
|
||||||
|
|
||||||
// This macro generates a test function with the given function name.
|
// This macro generates a test function with the given function name.
|
||||||
// The macro takes a KCL program, ensures it tokenizes and parses, then compares
|
// The macro takes a KCL program, ensures it tokenizes and parses, then compares
|
||||||
@ -3948,8 +3948,8 @@ mod snapshot_tests {
|
|||||||
($func_name:ident, $test_kcl_program:expr) => {
|
($func_name:ident, $test_kcl_program:expr) => {
|
||||||
#[test]
|
#[test]
|
||||||
fn $func_name() {
|
fn $func_name() {
|
||||||
let module_id = ModuleId::default();
|
let module_id = crate::ModuleId::default();
|
||||||
let tokens = crate::token::lexer($test_kcl_program, module_id).unwrap();
|
let tokens = crate::parsing::token::lexer($test_kcl_program, module_id).unwrap();
|
||||||
print_tokens(&tokens);
|
print_tokens(&tokens);
|
||||||
ParseContext::init();
|
ParseContext::init();
|
||||||
let actual = match program.parse(&tokens) {
|
let actual = match program.parse(&tokens) {
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3609
|
assertion_line: 3851
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3610
|
assertion_line: 3852
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3611
|
assertion_line: 3853
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3612
|
assertion_line: 3854
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3613
|
assertion_line: 3855
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3614
|
assertion_line: 3856
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3615
|
assertion_line: 3857
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3616
|
assertion_line: 3858
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3617
|
assertion_line: 3859
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3618
|
assertion_line: 3860
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3619
|
assertion_line: 3861
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3893
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3963
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3964
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3721
|
assertion_line: 3965
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3966
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3974
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3981
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3989
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3993
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3994
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3995
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3996
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3997
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3998
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3999
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 4000
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 4001
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 4002
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3759
|
assertion_line: 4003
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 4004
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 4005
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 4006
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3763
|
assertion_line: 4007
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3772
|
assertion_line: 4016
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3781
|
assertion_line: 4025
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3789
|
assertion_line: 4033
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3902
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 4041
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3808
|
assertion_line: 4052
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3814
|
assertion_line: 4058
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 4066
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3832
|
assertion_line: 4076
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3833
|
assertion_line: 4077
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3834
|
assertion_line: 4078
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3835
|
assertion_line: 4079
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3836
|
assertion_line: 4080
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3904
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3905
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3915
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3662
|
assertion_line: 3906
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3663
|
assertion_line: 3907
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
|
assertion_line: 3908
|
||||||
expression: actual
|
expression: actual
|
||||||
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
"body": [
|
"body": [
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3672
|
assertion_line: 3916
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3677
|
assertion_line: 3921
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3682
|
assertion_line: 3926
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
assertion_line: 3687
|
assertion_line: 3931
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
@ -1,7 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
"body": [
|
"body": [
|
@ -1,7 +1,6 @@
|
|||||||
---
|
---
|
||||||
source: kcl/src/parser/parser_impl.rs
|
source: kcl/src/parsing/parser.rs
|
||||||
expression: actual
|
expression: actual
|
||||||
snapshot_kind: text
|
|
||||||
---
|
---
|
||||||
{
|
{
|
||||||
"body": [
|
"body": [
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user