chore: reorganize directories

This commit is contained in:
PoiScript 2024-03-06 15:20:40 +08:00
parent 42cb1d21bd
commit 14d1555fc1
No known key found for this signature in database
GPG key ID: 22C2B1249D99985E
88 changed files with 114 additions and 144 deletions

24
src/tests.rs Normal file
View file

@ -0,0 +1,24 @@
//! test utils
use nom::IResult;
use rowan::{ast::AstNode, SyntaxNode};
use crate::{
syntax::{combinator::GreenElement, input::Input},
ParseConfig,
};
pub fn to_ast<N: AstNode>(
parser: impl Fn(Input) -> IResult<Input, GreenElement, ()>,
) -> impl Fn(&str) -> N {
move |s: &str| {
let input = Input {
s,
c: &ParseConfig::default(),
};
let element = parser(input).unwrap().1;
let node = element.into_node().unwrap();
let node = SyntaxNode::<N::Language>::new_root(node);
AstNode::cast(node).unwrap()
}
}