diff options
Diffstat (limited to 'src/parser/event_parser')
-rw-r--r-- | src/parser/event_parser/grammar/mod.rs | 33 | ||||
-rw-r--r-- | src/parser/event_parser/parser.rs | 7 |
2 files changed, 0 insertions, 40 deletions
diff --git a/src/parser/event_parser/grammar/mod.rs b/src/parser/event_parser/grammar/mod.rs index 67773453b..6e4f72096 100644 --- a/src/parser/event_parser/grammar/mod.rs +++ b/src/parser/event_parser/grammar/mod.rs | |||
@@ -46,39 +46,6 @@ fn alias(p: &mut Parser) -> bool { | |||
46 | true //FIXME: return false if three are errors | 46 | true //FIXME: return false if three are errors |
47 | } | 47 | } |
48 | 48 | ||
49 | fn repeat<F: FnMut(&mut Parser) -> bool>(p: &mut Parser, mut f: F) { | ||
50 | loop { | ||
51 | let pos = p.pos(); | ||
52 | if !f(p) { | ||
53 | return | ||
54 | } | ||
55 | if pos == p.pos() { | ||
56 | panic!("Infinite loop in parser") | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | |||
61 | fn comma_list<F: Fn(&mut Parser) -> bool>(p: &mut Parser, end: SyntaxKind, f: F) { | ||
62 | repeat(p, |p| { | ||
63 | if p.current() == end { | ||
64 | return false | ||
65 | } | ||
66 | let pos = p.pos(); | ||
67 | f(p); | ||
68 | if p.pos() == pos { | ||
69 | return false | ||
70 | } | ||
71 | |||
72 | if p.current() == end { | ||
73 | p.eat(COMMA); | ||
74 | } else { | ||
75 | p.expect(COMMA); | ||
76 | } | ||
77 | true | ||
78 | }) | ||
79 | } | ||
80 | |||
81 | |||
82 | impl<'p> Parser<'p> { | 49 | impl<'p> Parser<'p> { |
83 | fn at<L: Lookahead>(&self, l: L) -> bool { | 50 | fn at<L: Lookahead>(&self, l: L) -> bool { |
84 | l.is_ahead(self) | 51 | l.is_ahead(self) |
diff --git a/src/parser/event_parser/parser.rs b/src/parser/event_parser/parser.rs index 2cbe370be..18231e493 100644 --- a/src/parser/event_parser/parser.rs +++ b/src/parser/event_parser/parser.rs | |||
@@ -105,9 +105,6 @@ pub(crate) struct Parser<'t> { | |||
105 | curly_limit: Option<i32>, | 105 | curly_limit: Option<i32>, |
106 | } | 106 | } |
107 | 107 | ||
108 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
109 | pub(crate) struct Pos(u32); | ||
110 | |||
111 | impl<'t> Parser<'t> { | 108 | impl<'t> Parser<'t> { |
112 | pub(crate) fn new(text: &'t str, raw_tokens: &'t [Token]) -> Parser<'t> { | 109 | pub(crate) fn new(text: &'t str, raw_tokens: &'t [Token]) -> Parser<'t> { |
113 | let mut tokens = Vec::new(); | 110 | let mut tokens = Vec::new(); |
@@ -133,10 +130,6 @@ impl<'t> Parser<'t> { | |||
133 | } | 130 | } |
134 | } | 131 | } |
135 | 132 | ||
136 | pub(crate) fn pos(&self) -> Pos { | ||
137 | Pos(self.pos as u32) | ||
138 | } | ||
139 | |||
140 | pub(crate) fn into_events(self) -> Vec<Event> { | 133 | pub(crate) fn into_events(self) -> Vec<Event> { |
141 | assert!(self.curly_limit.is_none()); | 134 | assert!(self.curly_limit.is_none()); |
142 | assert_eq!(self.current(), EOF); | 135 | assert_eq!(self.current(), EOF); |