[parser] Add parsers field to Parser
This will be a stack of node-specific parsers. As you descend the tree, a new parser will be created for each node we visit.
This commit is contained in:
parent
52ede10d5e
commit
d7bffdc432
1 changed files with 10 additions and 1 deletions
|
|
@ -9,17 +9,25 @@ use std::iter::Peekable;
|
||||||
use sibillexer::Result as LexerResult;
|
use sibillexer::Result as LexerResult;
|
||||||
use sibiltypes::Object;
|
use sibiltypes::Object;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct ParseError;
|
pub struct ParseError;
|
||||||
|
|
||||||
pub type Result = std::result::Result<Object, ParseError>;
|
pub type Result = std::result::Result<Object, ParseError>;
|
||||||
|
|
||||||
|
trait NodeParser {
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Parser<T> where T: Iterator<Item=LexerResult> {
|
pub struct Parser<T> where T: Iterator<Item=LexerResult> {
|
||||||
input: Peekable<T>,
|
input: Peekable<T>,
|
||||||
|
parsers: Vec<Box<NodeParser>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Parser<T> where T: Iterator<Item=LexerResult> {
|
impl<T> Parser<T> where T: Iterator<Item=LexerResult> {
|
||||||
pub fn new(input: T) -> Parser<T> {
|
pub fn new(input: T) -> Parser<T> {
|
||||||
Parser { input: input.peekable() }
|
Parser {
|
||||||
|
input: input.peekable(),
|
||||||
|
parsers: Vec::new(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -35,6 +43,7 @@ impl<T> Iterator for Parser<T> where T: Iterator<Item=LexerResult> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert_eq!(self.parsers.len(), 0);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue