minor decorator lexing improvements

This commit is contained in:
PgBiel 2024-06-25 20:39:38 -03:00
parent 14dfb3f630
commit 65dc277fc5
2 changed files with 6 additions and 6 deletions

View File

@ -265,7 +265,7 @@ impl Lexer<'_> {
let mut current_start = self.s.cursor(); let mut current_start = self.s.cursor();
let mut expecting_comma = false; let mut expecting_comma = false;
let mut finished = false; let mut finished = false;
while !self.s.peek().is_some_and(is_newline) { while !self.s.at(is_newline) {
let token = match self.s.eat() { let token = match self.s.eat() {
Some(c) if c.is_whitespace() => { Some(c) if c.is_whitespace() => {
self.s.eat_while(is_inline_whitespace); self.s.eat_while(is_inline_whitespace);
@ -277,10 +277,10 @@ impl Lexer<'_> {
// After we finished specifying arguments, there must only // After we finished specifying arguments, there must only
// be whitespaces until the line ends. // be whitespaces until the line ends.
self.s.eat_until(char::is_whitespace); self.s.eat_until(char::is_whitespace);
self.error("expected whitespace") self.error("expected end of decorator")
} }
Some('"') if expecting_comma => { Some('"') if expecting_comma => {
self.s.eat_until(|c| c == ',' || is_newline(c)); self.s.eat_until(|c| c == ',' || c == ')' || is_newline(c));
self.error("expected comma") self.error("expected comma")
} }
Some('"') => { Some('"') => {

View File

@ -57,11 +57,11 @@ this is ok
// Error: 14 expected closing paren // Error: 14 expected closing paren
/! allow("abc /! allow("abc
// Error: 17-20 expected whitespace // Error: 17-20 expected end of decorator
/! allow("abc") abc /! allow("abc") abc
// Error: 16-26 expected comma // Error: 16-21 expected comma
// Error: 26 expected closing paren // Error: 23-26 expected end of decorator
/! allow("abc" "abc") abc /! allow("abc" "abc") abc
// Error: 16-21 expected comma // Error: 16-21 expected comma