forked from katzen-cafe/iowo
implement multiple members, member_values and trailing commata
This commit is contained in:
parent
c564d0f24c
commit
3164328568
4 changed files with 24 additions and 28 deletions
|
@ -33,9 +33,23 @@ mod object {
|
|||
}
|
||||
|
||||
member(p);
|
||||
while p.at(SyntaxKind::COMMA) {
|
||||
// not always an error, later configurable
|
||||
let potential_unexpected_comma = p.start("potential_unexpected_comma");
|
||||
p.eat(SyntaxKind::COMMA);
|
||||
|
||||
p.eat(SyntaxKind::BRACE_CLOSE);
|
||||
Some(obj_start.complete(p, SyntaxKind::OBJECT))
|
||||
if member(p).is_none() {
|
||||
potential_unexpected_comma.complete(p, SyntaxKind::TRAILING_COMMA);
|
||||
} else {
|
||||
potential_unexpected_comma.abandon(p);
|
||||
}
|
||||
}
|
||||
|
||||
Some(if !p.eat(SyntaxKind::BRACE_CLOSE) {
|
||||
obj_start.error(p, SyntaxError::UnclosedObject)
|
||||
} else {
|
||||
obj_start.complete(p, SyntaxKind::OBJECT)
|
||||
})
|
||||
}
|
||||
|
||||
fn member(p: &mut Parser) -> Option<CompletedMarker> {
|
||||
|
@ -56,9 +70,12 @@ mod object {
|
|||
todo!("handle wrong tokens")
|
||||
}
|
||||
|
||||
let member_value_start = p.start("member_value_start");
|
||||
if value(p) {
|
||||
member_value_start.complete(p, SyntaxKind::MEMBER_VALUE);
|
||||
Some(member_start.complete(p, SyntaxKind::MEMBER))
|
||||
} else {
|
||||
member_value_start.abandon(p);
|
||||
let e = member_start.error(p, SyntaxError::MemberMissingValue);
|
||||
Some(
|
||||
e.precede(p, "member but failed already")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue