Split up parser
The structure mostly follows the ast structure, with some slight changes. Each parser submodule documents which ast submodule it corresponds to. This parser is not yet complete, and I have yet to go through its modules one-by-one to fix and complete them.
This commit is contained in:
parent
037a0f69a3
commit
a559966c1d
7 changed files with 511 additions and 419 deletions
23
src/parser/basic.rs
Normal file
23
src/parser/basic.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//! Corresponds to `ast::basic`.
|
||||
|
||||
use chumsky::prelude::*;
|
||||
|
||||
use crate::ast::{Ident, Space};
|
||||
use crate::span::Span;
|
||||
|
||||
pub type Error = Simple<char, Span>;
|
||||
|
||||
// TODO https://github.com/rust-lang/rust/issues/63063
|
||||
|
||||
pub fn space() -> impl Parser<char, Space, Error = Error> {
|
||||
// TODO Parse comments
|
||||
text::whitespace().map_with_span(|(), span| Space {
|
||||
comment: vec![],
|
||||
span,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn ident() -> impl Parser<char, Ident, Error = Error> {
|
||||
// TODO Forbid keywords
|
||||
text::ident().map_with_span(|name, span| Ident { name, span })
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue