diff options
author | Aleksey Kladov <[email protected]> | 2018-08-27 22:42:13 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-27 22:42:13 +0100 |
commit | 13110f48e948d7554500aefc336e72f96041386b (patch) | |
tree | 60796fe2a4de16e37ff844c3360726e526c9b506 /crates/libsyntax2/src | |
parent | 8f5330cb0796670a93089107c8b15cdef3fa7c94 (diff) |
Log errors
Diffstat (limited to 'crates/libsyntax2/src')
-rw-r--r-- | crates/libsyntax2/src/parser_impl/mod.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/libsyntax2/src/parser_impl/mod.rs b/crates/libsyntax2/src/parser_impl/mod.rs index f60ef80f0..b343b404f 100644 --- a/crates/libsyntax2/src/parser_impl/mod.rs +++ b/crates/libsyntax2/src/parser_impl/mod.rs | |||
@@ -1,6 +1,8 @@ | |||
1 | mod event; | 1 | mod event; |
2 | mod input; | 2 | mod input; |
3 | 3 | ||
4 | use std::cell::Cell; | ||
5 | |||
4 | use { | 6 | use { |
5 | lexer::Token, | 7 | lexer::Token, |
6 | parser_api::Parser, | 8 | parser_api::Parser, |
@@ -51,6 +53,7 @@ pub(crate) struct ParserImpl<'t> { | |||
51 | 53 | ||
52 | pos: InputPosition, | 54 | pos: InputPosition, |
53 | events: Vec<Event>, | 55 | events: Vec<Event>, |
56 | steps: Cell<u32>, | ||
54 | } | 57 | } |
55 | 58 | ||
56 | impl<'t> ParserImpl<'t> { | 59 | impl<'t> ParserImpl<'t> { |
@@ -60,6 +63,7 @@ impl<'t> ParserImpl<'t> { | |||
60 | 63 | ||
61 | pos: InputPosition::new(), | 64 | pos: InputPosition::new(), |
62 | events: Vec::new(), | 65 | events: Vec::new(), |
66 | steps: Cell::new(0), | ||
63 | } | 67 | } |
64 | } | 68 | } |
65 | 69 | ||
@@ -91,6 +95,12 @@ impl<'t> ParserImpl<'t> { | |||
91 | } | 95 | } |
92 | 96 | ||
93 | pub(super) fn nth(&self, n: u32) -> SyntaxKind { | 97 | pub(super) fn nth(&self, n: u32) -> SyntaxKind { |
98 | let steps = self.steps.get(); | ||
99 | if steps > 10_000_000 { | ||
100 | panic!("the parser seems stuck"); | ||
101 | } | ||
102 | self.steps.set(steps + 1); | ||
103 | |||
94 | self.inp.kind(self.pos + n) | 104 | self.inp.kind(self.pos + n) |
95 | } | 105 | } |
96 | 106 | ||