Rename ast to parser
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
f87f4a0262
commit
705c6a8818
18 changed files with 32 additions and 32 deletions
|
|
@ -20,7 +20,7 @@ fn asting_benchmark(c: &mut Criterion) {
|
||||||
parsing.bench_with_input(BenchmarkId::from_parameter(size), &input, |b, input| {
|
parsing.bench_with_input(BenchmarkId::from_parameter(size), &input, |b, input| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let tokens = nomo::lexer::parse(input.clone()).unwrap();
|
let tokens = nomo::lexer::parse(input.clone()).unwrap();
|
||||||
let _ast = nomo::ast::parse(tokens.tokens()).unwrap();
|
let _ast = nomo::parser::parse(tokens.tokens()).unwrap();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -44,7 +44,7 @@ fn asting_nested(c: &mut Criterion) {
|
||||||
parsing.bench_with_input(BenchmarkId::from_parameter(size), &input, |b, input| {
|
parsing.bench_with_input(BenchmarkId::from_parameter(size), &input, |b, input| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let tokens = nomo::lexer::parse(input.clone()).unwrap();
|
let tokens = nomo::lexer::parse(input.clone()).unwrap();
|
||||||
let _ast = nomo::ast::parse(tokens.tokens()).unwrap();
|
let _ast = nomo::parser::parse(tokens.tokens()).unwrap();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ fuzz_target!(|data: String| -> Corpus {
|
||||||
return Corpus::Reject;
|
return Corpus::Reject;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Ok(ast) = nomo::ast::parse(parsed.tokens()) else {
|
let Ok(ast) = nomo::parser::parse(parsed.tokens()) else {
|
||||||
return Corpus::Keep;
|
return Corpus::Keep;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use crate::ast::TemplateAstExpr;
|
use crate::parser::TemplateAstExpr;
|
||||||
use crate::input::NomoInput;
|
use crate::input::NomoInput;
|
||||||
use crate::lexer::TemplateToken;
|
use crate::lexer::TemplateToken;
|
||||||
use crate::lexer::TokenOperator;
|
use crate::lexer::TokenOperator;
|
||||||
|
|
@ -115,7 +115,7 @@ pub struct VMInstructions {
|
||||||
pub instructions: Vec<Instruction>,
|
pub instructions: Vec<Instruction>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn emit_machine(input: crate::ast::TemplateAst<'_>) -> VMInstructions {
|
pub fn emit_machine(input: crate::parser::TemplateAst<'_>) -> VMInstructions {
|
||||||
let mut eval = vec![];
|
let mut eval = vec![];
|
||||||
|
|
||||||
let mut machine = EmitMachine {
|
let mut machine = EmitMachine {
|
||||||
|
|
@ -502,7 +502,7 @@ mod tests {
|
||||||
|
|
||||||
let parsed = crate::lexer::parse(input.into()).unwrap();
|
let parsed = crate::lexer::parse(input.into()).unwrap();
|
||||||
|
|
||||||
let ast = crate::ast::parse(parsed.tokens()).unwrap();
|
let ast = crate::parser::parse(parsed.tokens()).unwrap();
|
||||||
|
|
||||||
let emit = emit_machine(ast);
|
let emit = emit_machine(ast);
|
||||||
|
|
||||||
|
|
@ -538,7 +538,7 @@ mod tests {
|
||||||
|
|
||||||
let parsed = crate::lexer::parse(input.into()).unwrap();
|
let parsed = crate::lexer::parse(input.into()).unwrap();
|
||||||
|
|
||||||
let ast = crate::ast::parse(parsed.tokens()).unwrap();
|
let ast = crate::parser::parse(parsed.tokens()).unwrap();
|
||||||
|
|
||||||
let emit = emit_machine(ast);
|
let emit = emit_machine(ast);
|
||||||
|
|
||||||
|
|
@ -551,7 +551,7 @@ mod tests {
|
||||||
|
|
||||||
let parsed = crate::lexer::parse(input.into()).unwrap();
|
let parsed = crate::lexer::parse(input.into()).unwrap();
|
||||||
|
|
||||||
let ast = crate::ast::parse(parsed.tokens()).unwrap();
|
let ast = crate::parser::parse(parsed.tokens()).unwrap();
|
||||||
|
|
||||||
let emit = emit_machine(ast);
|
let emit = emit_machine(ast);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ mod tests {
|
||||||
|
|
||||||
let parsed = crate::lexer::parse(input.into()).unwrap();
|
let parsed = crate::lexer::parse(input.into()).unwrap();
|
||||||
|
|
||||||
let ast = crate::ast::parse(parsed.tokens()).unwrap();
|
let ast = crate::parser::parse(parsed.tokens()).unwrap();
|
||||||
|
|
||||||
let emit = crate::emit::emit_machine(ast);
|
let emit = crate::emit::emit_machine(ast);
|
||||||
|
|
||||||
|
|
@ -266,7 +266,7 @@ mod tests {
|
||||||
|
|
||||||
let parsed = crate::lexer::parse(input.into()).unwrap();
|
let parsed = crate::lexer::parse(input.into()).unwrap();
|
||||||
|
|
||||||
let ast = crate::ast::parse(parsed.tokens()).unwrap();
|
let ast = crate::parser::parse(parsed.tokens()).unwrap();
|
||||||
|
|
||||||
let emit = crate::emit::emit_machine(ast);
|
let emit = crate::emit::emit_machine(ast);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use crate::input::NomoInput;
|
||||||
use crate::value::NomoValue;
|
use crate::value::NomoValue;
|
||||||
use crate::value::NomoValueError;
|
use crate::value::NomoValueError;
|
||||||
|
|
||||||
pub mod ast;
|
pub mod parser;
|
||||||
pub mod emit;
|
pub mod emit;
|
||||||
pub mod eval;
|
pub mod eval;
|
||||||
pub mod functions;
|
pub mod functions;
|
||||||
|
|
@ -27,7 +27,7 @@ pub enum NomoError {
|
||||||
/// Invalid Template
|
/// Invalid Template
|
||||||
AstError {
|
AstError {
|
||||||
#[from]
|
#[from]
|
||||||
source: ast::AstFailure,
|
source: parser::AstFailure,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// An error occurred while evaluating
|
/// An error occurred while evaluating
|
||||||
|
|
@ -66,7 +66,7 @@ impl Nomo {
|
||||||
) -> Result<(), NomoError> {
|
) -> Result<(), NomoError> {
|
||||||
let source = value.into();
|
let source = value.into();
|
||||||
let parse = lexer::parse(source.clone())?;
|
let parse = lexer::parse(source.clone())?;
|
||||||
let ast = ast::parse(parse.tokens())?;
|
let ast = parser::parse(parse.tokens())?;
|
||||||
|
|
||||||
let instructions = emit::emit_machine(ast);
|
let instructions = emit::emit_machine(ast);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -737,13 +737,13 @@ mod tests {
|
||||||
use winnow::combinator::fail;
|
use winnow::combinator::fail;
|
||||||
use winnow::stream::TokenSlice;
|
use winnow::stream::TokenSlice;
|
||||||
|
|
||||||
use crate::ast::AstError;
|
use crate::parser::AstError;
|
||||||
use crate::ast::AstFailure;
|
use crate::parser::AstFailure;
|
||||||
use crate::ast::TemplateAst;
|
use crate::parser::TemplateAst;
|
||||||
use crate::ast::TemplateAstExpr;
|
use crate::parser::TemplateAstExpr;
|
||||||
use crate::ast::parse;
|
use crate::parser::parse;
|
||||||
use crate::ast::parse_block;
|
use crate::parser::parse_block;
|
||||||
use crate::ast::parse_end;
|
use crate::parser::parse_end;
|
||||||
use crate::lexer::TokenKind;
|
use crate::lexer::TokenKind;
|
||||||
|
|
||||||
fn panic_pretty<'a>(
|
fn panic_pretty<'a>(
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/ast/mod.rs
|
source: src/parser/mod.rs
|
||||||
expression: ast
|
expression: ast
|
||||||
---
|
---
|
||||||
TemplateAst {
|
TemplateAst {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/ast/mod.rs
|
source: src/parser/mod.rs
|
||||||
expression: ast
|
expression: ast
|
||||||
---
|
---
|
||||||
TemplateAst {
|
TemplateAst {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/ast/mod.rs
|
source: src/parser/mod.rs
|
||||||
expression: ast
|
expression: ast
|
||||||
---
|
---
|
||||||
TemplateAst {
|
TemplateAst {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/ast/mod.rs
|
source: src/parser/mod.rs
|
||||||
expression: ast
|
expression: ast
|
||||||
---
|
---
|
||||||
TemplateAst {
|
TemplateAst {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/ast/mod.rs
|
source: src/parser/mod.rs
|
||||||
expression: ast.to_report(input)
|
expression: ast.to_report(input)
|
||||||
---
|
---
|
||||||
[1m[91merror[0m[1m: Standlone action block[0m
|
[1m[91merror[0m[1m: Standlone action block[0m
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/ast/mod.rs
|
source: src/parser/mod.rs
|
||||||
expression: ast
|
expression: ast
|
||||||
---
|
---
|
||||||
TemplateAst {
|
TemplateAst {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/ast/mod.rs
|
source: src/parser/mod.rs
|
||||||
expression: ast
|
expression: ast
|
||||||
---
|
---
|
||||||
TemplateAst {
|
TemplateAst {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/ast/mod.rs
|
source: src/parser/mod.rs
|
||||||
expression: ast
|
expression: ast
|
||||||
---
|
---
|
||||||
TemplateAst {
|
TemplateAst {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/ast/mod.rs
|
source: src/parser/mod.rs
|
||||||
expression: ast
|
expression: ast
|
||||||
---
|
---
|
||||||
TemplateAst {
|
TemplateAst {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/ast/mod.rs
|
source: src/parser/mod.rs
|
||||||
expression: parsed
|
expression: parsed
|
||||||
---
|
---
|
||||||
ParsedTemplate {
|
ParsedTemplate {
|
||||||
|
|
@ -9,7 +9,7 @@ fn check_files() {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Ok(ast) = nomo::ast::parse(parsed.tokens()) else {
|
let Ok(ast) = nomo::parser::parse(parsed.tokens()) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ fn check_for_input([path]: [&Path; 1]) {
|
||||||
|
|
||||||
insta::assert_debug_snapshot!(format!("{basename}.1-parsed"), parsed);
|
insta::assert_debug_snapshot!(format!("{basename}.1-parsed"), parsed);
|
||||||
|
|
||||||
let ast = match nomo::ast::parse(parsed.tokens()) {
|
let ast = match nomo::parser::parse(parsed.tokens()) {
|
||||||
Ok(ast) => ast,
|
Ok(ast) => ast,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("{}", err.to_report(input));
|
eprintln!("{}", err.to_report(input));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue