macha 0.2.0

A fast minimal embedded scripting language.
Documentation
use std::fmt::Display;

#[derive(Debug, Clone, PartialEq)]
pub struct SrcLoc {
    pub line: usize,
    pub col: usize,
    mark: usize,
}

impl Default for SrcLoc {
    fn default() -> Self {
        Self { line: 1, col: 1, mark: 0 }
    }
}

impl SrcLoc {
    pub fn new(line: usize, col: usize) -> Self {
        Self { line, col, mark: 0 }
    }

    pub fn next_col(&mut self) {
        self.col += 1;
    }

    pub fn advance_col(&mut self, n: usize) {
        self.col += n;
    }

    pub fn next_line(&mut self) {
        self.line += 1;
        self.col = 1;
    }
}

impl Display for SrcLoc {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}:{}", self.line, self.col)
    }
}