summaryrefslogtreecommitdiff
path: root/src/parse/parser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse/parser.rs')
-rw-r--r--src/parse/parser.rs27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/parse/parser.rs b/src/parse/parser.rs
index a64e39dd..7c660182 100644
--- a/src/parse/parser.rs
+++ b/src/parse/parser.rs
@@ -1,12 +1,13 @@
use std::fmt::{self, Debug, Formatter};
use super::{Scanner, TokenMode, Tokens};
-use crate::diag::Diag;
-use crate::diag::{Deco, Feedback};
-use crate::syntax::{Pos, Span, Spanned, Token};
+use crate::diag::{Diag, DiagSet};
+use crate::syntax::{Pos, Span, Token};
/// A convenient token-based parser.
pub struct Parser<'s> {
+ /// Parsing diagnostics.
+ pub diags: DiagSet,
/// An iterator over the source tokens.
tokens: Tokens<'s>,
/// The next token.
@@ -20,8 +21,6 @@ pub struct Parser<'s> {
last_end: Pos,
/// The stack of open groups.
groups: Vec<GroupEntry>,
- /// Accumulated feedback.
- feedback: Feedback,
}
/// A logical group of tokens, e.g. `[...]`.
@@ -67,18 +66,13 @@ impl<'s> Parser<'s> {
next_start: Pos::ZERO,
last_end: Pos::ZERO,
groups: vec![],
- feedback: Feedback::new(),
+ diags: DiagSet::new(),
}
}
- /// Finish parsing and return the accumulated feedback.
- pub fn finish(self) -> Feedback {
- self.feedback
- }
-
- /// Add a diagnostic to the feedback.
- pub fn diag(&mut self, diag: Spanned<Diag>) {
- self.feedback.diags.push(diag);
+ /// Add a diagnostic.
+ pub fn diag(&mut self, diag: Diag) {
+ self.diags.insert(diag);
}
/// Eat the next token and add a diagnostic that it is not the expected
@@ -112,11 +106,6 @@ impl<'s> Parser<'s> {
}
}
- /// Add a decoration to the feedback.
- pub fn deco(&mut self, deco: Spanned<Deco>) {
- self.feedback.decos.push(deco);
- }
-
/// Continue parsing in a group.
///
/// When the end delimiter of the group is reached, all subsequent calls to