Create new Parser wrapper type

This commit is contained in:
Greg Shuflin 2021-11-13 14:22:34 -08:00
parent a00125d4a5
commit ba8fb86e3f
1 changed files with 28 additions and 1 deletions

View File

@ -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<String> {
Rc::new(s.to_string())
}
pub struct Parser {
id_store: IdStore<ASTItem>,
}
impl Parser {
pub(crate) fn new() -> Self {
Self { id_store: IdStore::new() }
}
pub(crate) fn parse(input: &str, _source_reference: &SourceReference) -> Result<AST, ParseError> {
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<Expression>),
Accessor(&'a str),