[parser] Determine when to parse a new list and when to prepare to parse the current list
This commit is contained in:
parent
8e9fde7a9f
commit
9c06b293f9
1 changed files with 12 additions and 2 deletions
|
@ -24,8 +24,18 @@ impl NodeParser for ListParser {
|
|||
fn parse(&mut self, lex: Lex) -> NodeParseResult {
|
||||
match lex.token() {
|
||||
Token::LeftParen => {
|
||||
self.list = Obj::new(Pair::empty());
|
||||
NodeParseResult::Continue
|
||||
match self.list {
|
||||
Obj::Null => {
|
||||
// Create our empty pair and proceed parsing this list.
|
||||
self.list = Obj::new(Pair::empty());
|
||||
NodeParseResult::Continue
|
||||
},
|
||||
Obj::Ptr(_) => {
|
||||
// This is an embedded list. Create a new parser for it.
|
||||
let parser = ListParser::new();
|
||||
NodeParseResult::Push { next: Box::new(parser) }
|
||||
}
|
||||
}
|
||||
},
|
||||
Token::Id => {
|
||||
let parser = SymParser{};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue