Compare commits

..

No commits in common. "9510d9254cf4b9a4d57a2a12fa15dfdbee641bc7" and "2bea3994c29c9802eef50b166963f4aad15a46a0" have entirely different histories.

7 changed files with 18 additions and 20 deletions

View file

@ -47,10 +47,10 @@ impl<'src, 'toks> Parser<'src, 'toks> {
self.input.kind(self.pos)
}
pub(crate) fn start(&mut self, name: &str) -> Marker {
pub(crate) fn start(&mut self) -> Marker {
let pos = self.events.len();
self.push_ev(Event::tombstone());
Marker::new(pos, name)
Marker::new(pos)
}
pub(crate) fn at(&self, kind: SyntaxKind) -> bool {
@ -88,10 +88,10 @@ pub(crate) struct Marker {
}
impl Marker {
pub(crate) fn new(pos: usize, name: &str) -> Self {
pub(crate) fn new(pos: usize) -> Self {
Self {
pos,
bomb: DropBomb::new(format!("Marker {name} must be completed or abandoned")),
bomb: DropBomb::new("Marker 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("new_pos");
let new_pos = p.start();
match &mut p.events[self.pos] {
Event::Start { forward_parent, .. } => {

View file

@ -5,7 +5,7 @@ use super::Parser;
mod expression;
pub fn source_file(p: &mut Parser) {
let root = p.start("root");
let root = p.start();
expression::expression(p);
p.eat_succeeding_ws();

View file

@ -47,7 +47,7 @@ mod collection {
}
pub fn expression(p: &mut Parser) -> Option<CompletedMarker> {
let expr = p.start("expr");
let expr = p.start();
if atom(p).or_else(|| instr(p)).is_none() {
expr.abandon(p);

View file

@ -6,7 +6,7 @@ use crate::parser::{
};
pub fn matrix(p: &mut Parser) -> CompletedMarker {
let matrix = p.start("matrix");
let matrix = p.start();
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("mat_body");
let mat_body = p.start();
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("mat_row");
let mut mat_row = p.start();
let mut row_items = 0;
while going {
let mat_item = p.start("mat_item");
let mat_item = p.start();
if expression(p).is_some() {
mat_item.complete(p, MAT_ITEM);
row_items += 1;
@ -39,24 +39,22 @@ fn matrix_body(p: &mut Parser) {
COMMA => p.do_bump(),
SEMICOLON => {
mat_row.complete(p, MAT_ROW);
mat_row = p.start("mat_row");
mat_row = p.start();
p.do_bump();
row_items = 0;
}
R_BRACK => going = false,
_ => {
let err = p.start("err");
let err = p.start();
p.do_bump();
err.complete_err(p, SyntaxError::Expected(vec![COMMA, SEMICOLON, R_BRACK]));
}
};
} else if p.at(R_BRACK) {
mat_item.abandon(p);
going = false;
} else {
mat_item.abandon(p);
let err = p.start("err");
let err = p.start();
p.do_bump();
err.complete_err(p, SyntaxError::Expected(vec![EXPR, R_BRACK]));
}

View file

@ -7,7 +7,7 @@ pub fn instr(p: &mut Parser) -> Option<CompletedMarker> {
return None;
}
let instr = p.start("instr");
let instr = p.start();
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("instr_name");
let instr_name = p.start();
while p.at(IDENT) {
p.do_bump();

View file

@ -12,7 +12,7 @@ pub fn literal(p: &mut Parser) -> Option<CompletedMarker> {
return None;
}
let lit = p.start("lit");
let lit = p.start();
p.do_bump();

View file

@ -1,4 +1,4 @@
mat 2x2 [
1 2, 2;
1, 2;
3, 4
]