mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2025-09-24 23:41:30 +02:00
lang: rewrite parser
This commit is contained in:
parent
6d8b79e8f7
commit
381ab45edc
25 changed files with 524 additions and 1161 deletions
30
crates/lang/src/parser/grammar/expression/instruction.rs
Normal file
30
crates/lang/src/parser/grammar/expression/instruction.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
use crate::parser::{syntax_kind::SyntaxKind::*, Parser};
|
||||
|
||||
use super::lit::literal;
|
||||
|
||||
pub fn instr(p: &mut Parser) {
|
||||
let instr = p.start();
|
||||
|
||||
instr_name(p);
|
||||
instr_params(p);
|
||||
|
||||
instr.complete(p, INSTR);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue