en/src/syntax/content.rs
2026-01-12 14:45:37 -03:00

24 lines
563 B
Rust

use parser::{Token, Lexeme};
use crate::graph::Graph;
pub mod parser;
pub trait Parseable: std::fmt::Display {
fn probe(lexeme: &Lexeme) -> bool;
fn lex(lexeme: &Lexeme) -> Self;
fn render(&self) -> String;
fn flatten(&self) -> String;
}
type Probe = fn(&Lexeme) -> bool;
type Lexer = fn(&Lexeme) -> Token;
type LexMap<'lm> = &'lm [(Probe, Lexer)];
pub fn parse(text: &str, graph: &Graph) -> String {
parser::read(text, graph)
}
pub fn rich_parse(text: &str, graph: &Graph) -> (String, Vec<Token>) {
parser::rich_read(text, graph)
}