lang: start implementing parser combinators (i have no idea what i'm doing)

also, the current test.owo crashes for some reason. this is a headache.
manual/imperative parsers are a nightmare.
This commit is contained in:
Schrottkatze 2024-04-12 01:02:07 +02:00
parent 9da157ff4a
commit 2d59a7f560
No known key found for this signature in database
2 changed files with 18 additions and 2 deletions

View file

@ -1,6 +1,5 @@
use std::borrow::Borrow; use std::borrow::Borrow;
use chumsky::container::Container;
use rowan::{ use rowan::{
Checkpoint, GreenNode, GreenNodeBuilder, GreenNodeData, GreenTokenData, Language, NodeOrToken, Checkpoint, GreenNode, GreenNodeBuilder, GreenNodeData, GreenTokenData, Language, NodeOrToken,
}; };
@ -12,6 +11,23 @@ use crate::parser::{
use super::lex::{self, SyntaxKind}; use super::lex::{self, SyntaxKind};
mod parsers {
use rowan::GreenNode;
use crate::parser::ast::lossless::lex::SyntaxKind;
use super::SyntaxError;
struct ParseResult {
green_node: GreenNode,
errors: Vec<SyntaxError>,
}
trait Parser {
fn parse<'src>(input: &[(SyntaxKind, &'src str)]) -> ParseResult;
}
}
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]
pub struct Parse { pub struct Parse {
pub green_node: GreenNode, pub green_node: GreenNode,

View file

@ -46,7 +46,7 @@
}; };
pre-commit.hooks = { pre-commit.hooks = {
clippy.enable = true; clippy.enable = false;
rustfmt.enable = true; rustfmt.enable = true;
}; };