aboutsummaryrefslogtreecommitdiff
path: root/src/parser/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/mod.rs')
-rw-r--r--src/parser/mod.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 49a69900f..c23ed3349 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -26,3 +26,33 @@ fn is_insignificant(kind: SyntaxKind) -> bool {
26 _ => false, 26 _ => false,
27 } 27 }
28} 28}
29
30impl<'p> parser::Parser<'p> {
31 fn at(&self, kind: SyntaxKind) -> bool {
32 self.current() == kind
33 }
34
35 fn err_and_bump(&mut self, message: &str) {
36 let err = self.start();
37 self.error(message);
38 self.bump();
39 err.complete(self, ERROR);
40 }
41
42 fn expect(&mut self, kind: SyntaxKind) -> bool {
43 if self.at(kind) {
44 self.bump();
45 true
46 } else {
47 self.error(format!("expected {:?}", kind));
48 false
49 }
50 }
51
52 fn eat(&mut self, kind: SyntaxKind) -> bool {
53 self.at(kind) && {
54 self.bump();
55 true
56 }
57 }
58}