mirror of
https://github.com/typst/typst
synced 2025-05-18 11:05:28 +08:00
minor decorator lexing improvements
This commit is contained in:
parent
14dfb3f630
commit
65dc277fc5
@ -265,7 +265,7 @@ impl Lexer<'_> {
|
||||
let mut current_start = self.s.cursor();
|
||||
let mut expecting_comma = 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() {
|
||||
Some(c) if c.is_whitespace() => {
|
||||
self.s.eat_while(is_inline_whitespace);
|
||||
@ -277,10 +277,10 @@ impl Lexer<'_> {
|
||||
// After we finished specifying arguments, there must only
|
||||
// be whitespaces until the line ends.
|
||||
self.s.eat_until(char::is_whitespace);
|
||||
self.error("expected whitespace")
|
||||
self.error("expected end of decorator")
|
||||
}
|
||||
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")
|
||||
}
|
||||
Some('"') => {
|
||||
|
@ -57,11 +57,11 @@ this is ok
|
||||
// Error: 14 expected closing paren
|
||||
/! allow("abc
|
||||
|
||||
// Error: 17-20 expected whitespace
|
||||
// Error: 17-20 expected end of decorator
|
||||
/! allow("abc") abc
|
||||
|
||||
// Error: 16-26 expected comma
|
||||
// Error: 26 expected closing paren
|
||||
// Error: 16-21 expected comma
|
||||
// Error: 23-26 expected end of decorator
|
||||
/! allow("abc" "abc") abc
|
||||
|
||||
// Error: 16-21 expected comma
|
||||
|
Loading…
x
Reference in New Issue
Block a user