type checking !?!?
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
use super::{MaybeParsable, Node, NodeParseResult, Parsable, ParserMsg, ParserOutput, TokenCursor};
|
||||
use super::{
|
||||
MaybeParsable, Node, NodeParseResult, Parsable, ParsableWith, CompilerMsg, CompilerOutput,
|
||||
TokenCursor,
|
||||
};
|
||||
|
||||
pub struct ParserCtx<'a> {
|
||||
pub cursor: TokenCursor<'a>,
|
||||
pub output: ParserOutput,
|
||||
pub output: CompilerOutput,
|
||||
}
|
||||
|
||||
impl<'a> Deref for ParserCtx<'a> {
|
||||
@@ -22,15 +25,18 @@ impl DerefMut for ParserCtx<'_> {
|
||||
}
|
||||
|
||||
impl<'a> ParserCtx<'a> {
|
||||
pub fn err(&mut self, msg: ParserMsg) {
|
||||
pub fn err(&mut self, msg: CompilerMsg) {
|
||||
self.output.err(msg);
|
||||
}
|
||||
pub fn hint(&mut self, msg: ParserMsg) {
|
||||
pub fn hint(&mut self, msg: CompilerMsg) {
|
||||
self.output.hint(msg);
|
||||
}
|
||||
pub fn parse<T: Parsable>(&mut self) -> NodeParseResult<T> {
|
||||
Node::parse(self)
|
||||
}
|
||||
pub fn parse_with<T: ParsableWith>(&mut self, data: T::Data) -> NodeParseResult<T> {
|
||||
Node::parse_with(self, data)
|
||||
}
|
||||
pub fn maybe_parse<T: MaybeParsable>(&mut self) -> Option<Node<T>> {
|
||||
Node::maybe_parse(self)
|
||||
}
|
||||
@@ -40,7 +46,7 @@ impl<'a> From<TokenCursor<'a>> for ParserCtx<'a> {
|
||||
fn from(cursor: TokenCursor<'a>) -> Self {
|
||||
Self {
|
||||
cursor,
|
||||
output: ParserOutput::new(),
|
||||
output: CompilerOutput::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +55,7 @@ impl<'a> From<&'a str> for ParserCtx<'a> {
|
||||
fn from(string: &'a str) -> Self {
|
||||
Self {
|
||||
cursor: TokenCursor::from(string),
|
||||
output: ParserOutput::new(),
|
||||
output: CompilerOutput::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user