mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2024-12-22 10:05:52 +01:00
lang: make Marker
s debuggable
This commit is contained in:
parent
2bea3994c2
commit
e62b50a51a
7 changed files with 18 additions and 18 deletions
|
@ -47,10 +47,10 @@ impl<'src, 'toks> Parser<'src, 'toks> {
|
|||
self.input.kind(self.pos)
|
||||
}
|
||||
|
||||
pub(crate) fn start(&mut self) -> Marker {
|
||||
pub(crate) fn start(&mut self, name: &str) -> Marker {
|
||||
let pos = self.events.len();
|
||||
self.push_ev(Event::tombstone());
|
||||
Marker::new(pos)
|
||||
Marker::new(pos, name)
|
||||
}
|
||||
|
||||
pub(crate) fn at(&self, kind: SyntaxKind) -> bool {
|
||||
|
@ -88,10 +88,10 @@ pub(crate) struct Marker {
|
|||
}
|
||||
|
||||
impl Marker {
|
||||
pub(crate) fn new(pos: usize) -> Self {
|
||||
pub(crate) fn new(pos: usize, name: &str) -> Self {
|
||||
Self {
|
||||
pos,
|
||||
bomb: DropBomb::new("Marker must be completed or abandoned"),
|
||||
bomb: DropBomb::new(format!("Marker {name} must be completed or abandoned")),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ pub(crate) struct CompletedMarker {
|
|||
|
||||
impl CompletedMarker {
|
||||
pub(crate) fn precede(self, p: &mut Parser<'_, '_>) -> Marker {
|
||||
let new_pos = p.start();
|
||||
let new_pos = p.start("new_pos");
|
||||
|
||||
match &mut p.events[self.pos] {
|
||||
Event::Start { forward_parent, .. } => {
|
||||
|
|
|
@ -5,7 +5,7 @@ use super::Parser;
|
|||
mod expression;
|
||||
|
||||
pub fn source_file(p: &mut Parser) {
|
||||
let root = p.start();
|
||||
let root = p.start("root");
|
||||
|
||||
expression::expression(p);
|
||||
p.eat_succeeding_ws();
|
||||
|
|
|
@ -47,7 +47,7 @@ mod collection {
|
|||
}
|
||||
|
||||
pub fn expression(p: &mut Parser) -> Option<CompletedMarker> {
|
||||
let expr = p.start();
|
||||
let expr = p.start("expr");
|
||||
|
||||
if atom(p).or_else(|| instr(p)).is_none() {
|
||||
expr.abandon(p);
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::parser::{
|
|||
};
|
||||
|
||||
pub fn matrix(p: &mut Parser) -> CompletedMarker {
|
||||
let matrix = p.start();
|
||||
let matrix = p.start("matrix");
|
||||
p.eat(MAT_KW);
|
||||
|
||||
if !p.eat(PAT_DIMENSIONS) {
|
||||
|
@ -20,7 +20,7 @@ pub fn matrix(p: &mut Parser) -> CompletedMarker {
|
|||
}
|
||||
|
||||
fn matrix_body(p: &mut Parser) {
|
||||
let mat_body = p.start();
|
||||
let mat_body = p.start("mat_body");
|
||||
if !p.eat(L_BRACK) {
|
||||
mat_body.complete_err(p, SyntaxError::Expected(vec![MAT_BODY]));
|
||||
return ();
|
||||
|
@ -28,10 +28,10 @@ fn matrix_body(p: &mut Parser) {
|
|||
|
||||
let mut going = true;
|
||||
|
||||
let mut mat_row = p.start();
|
||||
let mut mat_row = p.start("mat_row");
|
||||
let mut row_items = 0;
|
||||
while going {
|
||||
let mat_item = p.start();
|
||||
let mat_item = p.start("mat_item");
|
||||
if expression(p).is_some() {
|
||||
mat_item.complete(p, MAT_ITEM);
|
||||
row_items += 1;
|
||||
|
@ -39,13 +39,13 @@ fn matrix_body(p: &mut Parser) {
|
|||
COMMA => p.do_bump(),
|
||||
SEMICOLON => {
|
||||
mat_row.complete(p, MAT_ROW);
|
||||
mat_row = p.start();
|
||||
mat_row = p.start("mat_row");
|
||||
p.do_bump();
|
||||
row_items = 0;
|
||||
}
|
||||
R_BRACK => going = false,
|
||||
_ => {
|
||||
let err = p.start();
|
||||
let err = p.start("err");
|
||||
p.do_bump();
|
||||
|
||||
err.complete_err(p, SyntaxError::Expected(vec![COMMA, SEMICOLON, R_BRACK]));
|
||||
|
@ -54,7 +54,7 @@ fn matrix_body(p: &mut Parser) {
|
|||
} else if p.at(R_BRACK) {
|
||||
going = false;
|
||||
} else {
|
||||
let err = p.start();
|
||||
let err = p.start("err");
|
||||
p.do_bump();
|
||||
err.complete_err(p, SyntaxError::Expected(vec![EXPR, R_BRACK]));
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ pub fn instr(p: &mut Parser) -> Option<CompletedMarker> {
|
|||
return None;
|
||||
}
|
||||
|
||||
let instr = p.start();
|
||||
let instr = p.start("instr");
|
||||
|
||||
instr_name(p);
|
||||
instr_params(p);
|
||||
|
@ -16,7 +16,7 @@ pub fn instr(p: &mut Parser) -> Option<CompletedMarker> {
|
|||
}
|
||||
|
||||
fn instr_name(p: &mut Parser) {
|
||||
let instr_name = p.start();
|
||||
let instr_name = p.start("instr_name");
|
||||
|
||||
while p.at(IDENT) {
|
||||
p.do_bump();
|
||||
|
|
|
@ -12,7 +12,7 @@ pub fn literal(p: &mut Parser) -> Option<CompletedMarker> {
|
|||
return None;
|
||||
}
|
||||
|
||||
let lit = p.start();
|
||||
let lit = p.start("lit");
|
||||
|
||||
p.do_bump();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
mat 2x2 [
|
||||
1, 2;
|
||||
1 2, 2;
|
||||
3, 4
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue