@@ -102,8 +102,8 @@ def __rich__(self) -> RenderableType:
102102 return Group (* errors )
103103
104104
105- class EOFError (TokenError ):
106- """Indicates that the CSS ended prematurely."""
105+ class UnexpectedEnd (TokenError ):
106+ """Indicates that the text being tokenized ended prematurely."""
107107
108108
109109@rich .repr .auto
@@ -231,7 +231,7 @@ def get_token(self, expect: Expect) -> Token:
231231 expect: Expect object which describes which tokens may be read.
232232
233233 Raises:
234- EOFError : If there is an unexpected end of file.
234+ UnexpectedEnd : If there is an unexpected end of file.
235235 TokenError: If there is an error with the token.
236236
237237 Returns:
@@ -251,11 +251,15 @@ def get_token(self, expect: Expect) -> Token:
251251 None ,
252252 )
253253 else :
254- raise EOFError (
254+ raise UnexpectedEnd (
255255 self .read_from ,
256256 self .code ,
257257 (line_no + 1 , col_no + 1 ),
258- "Unexpected end of file; did you forget a '}' ?" ,
258+ (
259+ "Unexpected end of file; did you forget a '}' ?"
260+ if expect ._expect_semicolon
261+ else "Unexpected end of text"
262+ ),
259263 )
260264 line = self .lines [line_no ]
261265 preceding_text : str = ""
@@ -348,7 +352,7 @@ def skip_to(self, expect: Expect) -> Token:
348352 expect: Expect object describing the expected token.
349353
350354 Raises:
351- EOFError : If end of file is reached.
355+ UnexpectedEndOfText : If end of file is reached.
352356
353357 Returns:
354358 A new token.
@@ -358,11 +362,15 @@ def skip_to(self, expect: Expect) -> Token:
358362
359363 while True :
360364 if line_no >= len (self .lines ):
361- raise EOFError (
365+ raise UnexpectedEnd (
362366 self .read_from ,
363367 self .code ,
364368 (line_no , col_no ),
365- "Unexpected end of file; did you forget a '}' ?" ,
369+ (
370+ "Unexpected end of file; did you forget a '}' ?"
371+ if expect ._expect_semicolon
372+ else "Unexpected end of markup"
373+ ),
366374 )
367375 line = self .lines [line_no ]
368376 match = expect .search (line , col_no )
0 commit comments