aboutsummaryrefslogtreecommitdiff
path: root/src/parser/event_parser/grammar/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/event_parser/grammar/mod.rs')
-rw-r--r--src/parser/event_parser/grammar/mod.rs25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/parser/event_parser/grammar/mod.rs b/src/parser/event_parser/grammar/mod.rs
index 6e4f72096..c6ab1fbe2 100644
--- a/src/parser/event_parser/grammar/mod.rs
+++ b/src/parser/event_parser/grammar/mod.rs
@@ -1,5 +1,5 @@
1use super::parser::{Parser, TokenSet}; 1use super::parser::{Parser, TokenSet};
2use {SyntaxKind}; 2use SyntaxKind;
3use tree::EOF; 3use tree::EOF;
4use syntax_kinds::*; 4use syntax_kinds::*;
5 5
@@ -29,7 +29,7 @@ fn visibility(p: &mut Parser) {
29 } 29 }
30 p.expect(R_PAREN); 30 p.expect(R_PAREN);
31 } 31 }
32 _ => () 32 _ => (),
33 } 33 }
34 } 34 }
35 vis.complete(p, VISIBILITY); 35 vis.complete(p, VISIBILITY);
@@ -53,9 +53,7 @@ impl<'p> Parser<'p> {
53 53
54 fn err_and_bump(&mut self, message: &str) { 54 fn err_and_bump(&mut self, message: &str) {
55 let err = self.start(); 55 let err = self.start();
56 self.error() 56 self.error().message(message).emit();
57 .message(message)
58 .emit();
59 self.bump(); 57 self.bump();
60 err.complete(self, ERROR); 58 err.complete(self, ERROR);
61 } 59 }
@@ -65,15 +63,16 @@ impl<'p> Parser<'p> {
65 self.bump(); 63 self.bump();
66 true 64 true
67 } else { 65 } else {
68 self.error() 66 self.error().message(format!("expected {:?}", kind)).emit();
69 .message(format!("expected {:?}", kind))
70 .emit();
71 false 67 false
72 } 68 }
73 } 69 }
74 70
75 fn eat(&mut self, kind: SyntaxKind) -> bool { 71 fn eat(&mut self, kind: SyntaxKind) -> bool {
76 self.current() == kind && { self.bump(); true } 72 self.current() == kind && {
73 self.bump();
74 true
75 }
77 } 76 }
78} 77}
79 78
@@ -94,8 +93,7 @@ impl Lookahead for SyntaxKind {
94 93
95impl Lookahead for [SyntaxKind; 2] { 94impl Lookahead for [SyntaxKind; 2] {
96 fn is_ahead(self, p: &Parser) -> bool { 95 fn is_ahead(self, p: &Parser) -> bool {
97 p.current() == self[0] 96 p.current() == self[0] && p.raw_lookahead(1) == self[1]
98 && p.raw_lookahead(1) == self[1]
99 } 97 }
100 98
101 fn consume(p: &mut Parser) { 99 fn consume(p: &mut Parser) {
@@ -106,9 +104,7 @@ impl Lookahead for [SyntaxKind; 2] {
106 104
107impl Lookahead for [SyntaxKind; 3] { 105impl Lookahead for [SyntaxKind; 3] {
108 fn is_ahead(self, p: &Parser) -> bool { 106 fn is_ahead(self, p: &Parser) -> bool {
109 p.current() == self[0] 107 p.current() == self[0] && p.raw_lookahead(1) == self[1] && p.raw_lookahead(2) == self[2]
110 && p.raw_lookahead(1) == self[1]
111 && p.raw_lookahead(2) == self[2]
112 } 108 }
113 109
114 fn consume(p: &mut Parser) { 110 fn consume(p: &mut Parser) {
@@ -130,5 +126,4 @@ impl<'a> Lookahead for AnyOf<'a> {
130 fn consume(p: &mut Parser) { 126 fn consume(p: &mut Parser) {
131 p.bump(); 127 p.bump();
132 } 128 }
133
134} 129}