This commit is contained in:
LunarAkai 2025-08-08 21:10:35 +02:00
commit 92db6f7f6e
4 changed files with 51 additions and 30 deletions

View file

@ -4,6 +4,7 @@ use logos::Logos;
mod language_frontend;
use crate::language_frontend::abstract_syntax_tree::parser::lex;
use crate::{
language_frontend::lexer::tokens::Token, language_frontend::abstract_syntax_tree::parser::parse};
@ -26,25 +27,8 @@ fn main() {
println!("{:?}", sourcecode);
let lexer = Token::lexer(&sourcecode)
.spanned()
.collect::<Vec<_>>();
for token in lexer {
println!("{:?}", token);
}
let token_iter = Token::lexer(&sourcecode).spanned().map(|(tok, span)| tok.map(|t| (t, span))).filter_map(Result::ok);
let token_stream = Stream::from_iter(token_iter)
// Tell chumsky to split the (Token, SimpleSpan) stream into its parts so that it can handle the spans for us
// This involves giving chumsky an 'end of input' span: we just use a zero-width span at the end of the string
.map((0..sourcecode.len()).into(), |(t, s): (_, _)| (t, s));
match parse(&sourcecode) {
Ok(res) => println!("{:?}", res),
Ok(res) => println!("{:#?}", res),
Err(e) => {
panic!("{:#?}", e)
}