aboutsummaryrefslogtreecommitdiff
path: root/src/parser/mod.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-02-11 10:19:32 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-02-11 10:19:32 +0000
commit7a0ada860b57acd44b1d53e944ae621e438652da (patch)
tree206edfb15c0eec57c1872a2acc435d7f38df1c88 /src/parser/mod.rs
parent7176029803fe2e00f29ab7d20a384e3ee6f53ba3 (diff)
parent65ebfd9a34554b8139d5c4673bc3b5daa5ab0df5 (diff)
Merge #49
49: Simplify r=matklad a=matklad bors r+
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}