iowo/crates/lang/src/parser/grammar/expression/instruction.rs

35 lines
647 B
Rust
Raw Normal View History

2024-04-24 19:37:52 +02:00
use crate::parser::{syntax_kind::SyntaxKind::*, CompletedMarker, Parser};
2024-04-24 11:07:38 +02:00
use super::lit::literal;
2024-04-24 19:37:52 +02:00
pub fn instr(p: &mut Parser) -> Option<CompletedMarker> {
if !p.at(IDENT) {
return None;
}
2024-04-24 11:07:38 +02:00
let instr = p.start();
instr_name(p);
instr_params(p);
2024-04-24 19:37:52 +02:00
Some(instr.complete(p, INSTR))
2024-04-24 11:07:38 +02:00
}
fn instr_name(p: &mut Parser) {
let instr_name = p.start();
while p.at(IDENT) {
p.do_bump();
}
instr_name.complete(p, INSTR_NAME);
}
fn instr_params(p: &mut Parser) {
if let Some(start) = literal(p) {
while literal(p).is_some() {}
start.precede(p).complete(p, INSTR_PARAMS);
}
}