procman 0.23.6

A process supervisor with a dependency DAG and a typed .pman language
/// Source location for error reporting.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Span {
    pub start: usize, // byte offset
    pub end: usize,   // byte offset
    pub line: usize,  // 1-based line number
    pub col: usize,   // 1-based column (byte offset within line)
}

impl Span {
    /// Format an error message with file location.
    pub fn fmt_error(&self, path: &str, msg: &str) -> String {
        format!("{path}:{}:{}: error: {msg}", self.line, self.col)
    }

    /// Format a warning message with file location.
    pub fn fmt_warning(&self, path: &str, msg: &str) -> String {
        format!("{path}:{}:{}: warning: {msg}", self.line, self.col)
    }
}

#[derive(Clone, Debug, PartialEq)]
pub enum TokenKind {
    // Keywords
    Config,        // config
    Job,           // job
    Service,       // service
    Event,         // event
    Task,          // task
    If,            // if
    For,           // for
    In,            // in
    Env,           // env
    Run,           // run
    Wait,          // wait
    Watch,         // watch
    After,         // after
    OnFail,        // on_fail
    Spawn,         // spawn
    Http,          // http
    Connect,       // connect
    Exists,        // exists
    Contains,      // contains
    OutputMatches, // output_matches
    Running,       // running
    Glob,          // glob
    Arg,           // arg
    Import,        // import
    As,            // as
    True,          // true
    False,         // false
    None,          // none
    Module,        // module
    Procman,       // procman

    // Literals
    String(String),       // "..." (contents, escapes resolved)
    Number(f64),          // 42, 3.14
    Duration(f64),        // 5.0 (seconds) — suffix parsed into seconds
    FencedString(String), // """ ... """ (raw contents)

    // Identifiers and references
    Ident(String), // bare identifier (e.g., job name, var name)
    At,            // @
    Dot,           // .
    Args,          // args (keyword for args namespace)

    // Operators
    Eq,   // ==
    Ne,   // !=
    Lt,   // <
    Gt,   // >
    Le,   // <=
    Ge,   // >=
    And,  // &&
    Or,   // ||
    Not,  // !
    Plus, // +

    // Punctuation
    Assign,     // =
    LBrace,     // {
    RBrace,     // }
    LBracket,   // [
    RBracket,   // ]
    LParen,     // (
    RParen,     // )
    Comma,      // ,
    DotDot,     // ..
    DotDotEq,   // ..=
    ColonColon, // ::
}

#[derive(Clone, Debug)]
pub struct Token {
    pub kind: TokenKind,
    pub span: Span,
}