@@ -140,13 +140,6 @@ class Lexer final {
140140 std::numeric_limits<int32_t >::max ()));
141141 }
142142
143- struct Position final {
144- int32_t position = 0 ;
145- bool at_end = false ;
146- bool done = false ;
147- LexerError error;
148- };
149-
150143 Lexer (const Lexer&) = delete ;
151144 Lexer (Lexer&&) = delete ;
152145 Lexer& operator =(const Lexer&) = delete ;
@@ -165,15 +158,13 @@ class Lexer final {
165158
166159 [[nodiscard]] int32_t GetPosition () const { return position_; }
167160
168- [[nodiscard]] Position SavePosition () const {
169- return Position{position_, at_end_, done_, error_};
170- }
161+ [[nodiscard]] int32_t SavePosition () const { return position_; }
171162
172- void RestorePosition (const Position& position) {
173- position_ = position. position ;
174- at_end_ = position. at_end ;
175- done_ = position. done ;
176- error_ = position. error ;
163+ void RestorePosition (int32_t position) {
164+ ABSL_DCHECK_GE ( position, 0 ) ;
165+ ABSL_DCHECK_LE ( position, static_cast < int32_t >(content_. size ())) ;
166+ position_ = position;
167+ error_ = LexerError{} ;
177168 }
178169
179170 private:
@@ -201,9 +192,6 @@ class Lexer final {
201192 }
202193
203194 [[nodiscard]] Token MakeToken (TokenType type, int32_t start, int32_t end) {
204- if (ABSL_PREDICT_FALSE (at_end_)) {
205- AtEndTokenCreated ();
206- }
207195 return Token{.type = type, .start = start, .end = end};
208196 }
209197
@@ -214,8 +202,6 @@ class Lexer final {
214202 return Token{.type = TokenType::kError , .start = start, .end = end};
215203 }
216204
217- void AtEndTokenCreated () { done_ = true ; }
218-
219205 // Consumes characters up to and including the first occurrence of character
220206 // `c` without interpreting backslashes as escapes. Returns true if `c` was
221207 // found and consumed; false if end of input was reached.
@@ -294,8 +280,6 @@ class Lexer final {
294280
295281 cel::SourceContentView content_;
296282 int32_t position_ = 0 ;
297- bool at_end_ = false ;
298- bool done_ = false ;
299283 LexerError error_;
300284};
301285
0 commit comments