Parse ident

This commit is contained in:
Joscha 2022-11-18 12:24:01 +01:00
parent e9d2602cd6
commit 932af88c84

View file

@ -1,19 +1,22 @@
use chumsky::prelude::*;
use chumsky::text::whitespace;
use crate::ast::Space;
use crate::ast::{Ident, Space};
use crate::span::Span;
type Error = Simple<char, Span>;
fn space() -> impl Parser<char, Space, Error = Error> {
// TODO Parse comments
whitespace().map_with_span(|(), span| Space {
text::whitespace().map_with_span(|(), span| Space {
comment: vec![],
span,
})
}
pub fn parser() -> impl Parser<char, Space, Error = Error> {
space().then_ignore(end())
fn ident() -> impl Parser<char, Ident, Error = Error> {
text::ident().map_with_span(|name, span| Ident { name, span })
}
pub fn parser() -> impl Parser<char, Ident, Error = Error> {
ident().padded().then_ignore(end())
}