mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2024-11-21 21:24:41 +01:00
lang: basic attrset parser
This commit is contained in:
parent
9af71ed3f4
commit
db2643359c
|
@ -1,5 +1,45 @@
|
|||
use crate::parser::{CompletedMarker, Parser};
|
||||
use crate::parser::{
|
||||
error::SyntaxError,
|
||||
grammar::expression::{atom, expression},
|
||||
CompletedMarker, Marker, Parser,
|
||||
SyntaxKind::*,
|
||||
};
|
||||
|
||||
pub fn attr_set(p: &mut Parser) -> CompletedMarker {
|
||||
todo!()
|
||||
let start = p.start("attr_set_start");
|
||||
assert!(p.eat(L_BRACE));
|
||||
|
||||
loop {
|
||||
if attr(p).is_some() {
|
||||
// TODO: handle others
|
||||
if p.eat(COMMA) {
|
||||
continue;
|
||||
} else if p.eat(R_BRACE) {
|
||||
return start.complete(p, ATTR_SET);
|
||||
}
|
||||
// TODO: check for newline and stuff following that for recov of others
|
||||
} else if p.eat(R_BRACE) {
|
||||
return start.complete(p, ATTR_SET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn attr(p: &mut Parser) -> Option<CompletedMarker> {
|
||||
if p.at(IDENT) {
|
||||
let attr_start = p.start("attr");
|
||||
let attr_name_start = p.start("attr_name");
|
||||
p.do_bump();
|
||||
attr_name_start.complete(p, ATTR_NAME);
|
||||
|
||||
// TODO: handle comma, expr/atom, other
|
||||
p.eat(COLON);
|
||||
|
||||
// TODO: handle failed expr parser too
|
||||
let attr_value = p.start("attr_value");
|
||||
let _ = expression(p);
|
||||
attr_value.complete(p, ATTR_VALUE);
|
||||
Some(attr_start.complete(p, ATTR))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue