Small parser changes.
This commit is contained in:
parent
f95d504f88
commit
64526a0b1c
@ -96,7 +96,7 @@ struct Parser<'a> {
|
|||||||
lexer: Lexer<'a>,
|
lexer: Lexer<'a>,
|
||||||
current: Option<Token>,
|
current: Option<Token>,
|
||||||
lookahead: Option<Token>,
|
lookahead: Option<Token>,
|
||||||
node_index: usize,
|
node_id: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Parser<'a> {
|
impl<'a> Parser<'a> {
|
||||||
@ -106,7 +106,7 @@ impl<'a> Parser<'a> {
|
|||||||
lexer: Lexer::new(input),
|
lexer: Lexer::new(input),
|
||||||
current: None,
|
current: None,
|
||||||
lookahead: None,
|
lookahead: None,
|
||||||
node_index: 0,
|
node_id: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,6 +212,7 @@ impl<'a> Parser<'a> {
|
|||||||
.with_primary_label_message(&format!("Expected {}.", Self::join_kinds(kinds)))
|
.with_primary_label_message(&format!("Expected {}.", Self::join_kinds(kinds)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
fn expect_advance(&mut self, token_kind: TokenKind) -> (Option<Token>, Diagnostics) {
|
fn expect_advance(&mut self, token_kind: TokenKind) -> (Option<Token>, Diagnostics) {
|
||||||
match self.current.take() {
|
match self.current.take() {
|
||||||
None => (
|
None => (
|
||||||
@ -290,6 +291,12 @@ impl<'a> Parser<'a> {
|
|||||||
self.sample_input(token.start(), token.end())
|
self.sample_input(token.start(), token.end())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn next_node_id(&mut self) -> usize {
|
||||||
|
let node_id = self.node_id;
|
||||||
|
self.node_id += 1;
|
||||||
|
node_id
|
||||||
|
}
|
||||||
|
|
||||||
fn compilation_unit(&mut self) -> ParseResult<CompilationUnit> {
|
fn compilation_unit(&mut self) -> ParseResult<CompilationUnit> {
|
||||||
let mut functions: Vec<Function> = vec![];
|
let mut functions: Vec<Function> = vec![];
|
||||||
let mut extern_functions: Vec<ExternFunction> = vec![];
|
let mut extern_functions: Vec<ExternFunction> = vec![];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user