diff options
author | Christopher Durham <[email protected]> | 2018-01-27 23:51:12 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2018-01-27 23:51:12 +0000 |
commit | e6e61251abb68b3e6a47fd3708f4dea6059a9ec3 (patch) | |
tree | c22cfa06a26add11f3aefca3806f0009dd25d923 /src/parser/event_parser/grammar/mod.rs | |
parent | 357cd3358167daa38f3ff34d225e1501faff6015 (diff) | |
parent | 9140b3e7286efae57ee8c49c7bfcad8737f9c6fc (diff) |
Merge pull request #12 from CAD97/enforce-fmt
Enforce rustfmt format
Diffstat (limited to 'src/parser/event_parser/grammar/mod.rs')
-rw-r--r-- | src/parser/event_parser/grammar/mod.rs | 25 |
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 @@ | |||
1 | use super::parser::{Parser, TokenSet}; | 1 | use super::parser::{Parser, TokenSet}; |
2 | use {SyntaxKind}; | 2 | use SyntaxKind; |
3 | use tree::EOF; | 3 | use tree::EOF; |
4 | use syntax_kinds::*; | 4 | use 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 | ||
95 | impl Lookahead for [SyntaxKind; 2] { | 94 | impl 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 | ||
107 | impl Lookahead for [SyntaxKind; 3] { | 105 | impl 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 | } |