diff --git a/schala-lang/language/src/parsing/new.rs b/schala-lang/language/src/parsing/new.rs index 8f516ae..c830b72 100644 --- a/schala-lang/language/src/parsing/new.rs +++ b/schala-lang/language/src/parsing/new.rs @@ -1,11 +1,38 @@ use std::rc::Rc; -use crate::ast::*; +//TODO make use of the format_parse_error function +//use crate::error::{SchalaError, format_parse_error}; +use crate::parsing::ParseError; +use crate::{ast::*, identifier::IdStore, schala::SourceReference}; fn rc_string(s: &str) -> Rc { Rc::new(s.to_string()) } +pub struct Parser { + id_store: IdStore, +} + +impl Parser { + pub(crate) fn new() -> Self { + Self { id_store: IdStore::new() } + } + + pub(crate) fn parse(input: &str, _source_reference: &SourceReference) -> Result { + schala_parser::program(input).map_err(|err: peg::error::ParseError<_>| { + let msg = err.to_string(); + ParseError { + production_name: Some("some-production".to_string()), + msg, + token: crate::tokenizing::Token { + kind: crate::tokenizing::TokenKind::Semicolon, + location: Default::default(), + }, + } + }) + } +} + enum ExtendedPart<'a> { Index(Vec), Accessor(&'a str),