.
This commit is contained in:
parent
de63467730
commit
92db6f7f6e
4 changed files with 51 additions and 30 deletions
20
src/main.rs
20
src/main.rs
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue