mod tree;
pub use tree::{Tree, EndOfFile};
mod stream;
pub use stream::{Location, Loc, Token, Stream, Characters};
mod parser;
pub use parser::{Context, Parse};
pub mod lexer;
pub mod word;
pub mod bracket;
pub mod expr;
pub mod stmt;
mod buffer;
pub use buffer::{Buffer};
pub mod welly {
use super::*;
pub type Comment = lexer::Comment;
pub type CharacterLiteral = lexer::CharacterLiteral;
pub type StringLiteral = lexer::StringLiteral;
pub type Whitespace = word::Whitespace;
pub type Symbol = word::Symbol;
pub type Alphanumeric = word::Alphanumeric;
pub type Round = bracket::Round;
pub type Square = bracket::Square;
pub type Brace = bracket::Brace;
pub type Op = expr::Op;
pub type Expr = expr::Expr;
pub type MaybeExpr = expr::MaybeExpr;
pub type AssignOp = stmt::AssignOp;
pub type Stmt = stmt::Stmt;
}
pub mod parsers {
use super::*;
use welly::{Round, Brace};
pub const LEXER: lexer::Parser = lexer::Parser;
pub type Word = word::Parser;
pub fn word() -> Word {
let mut ret = Word::default();
ret.add_keywords::<expr::Operator>();
ret.add_keywords::<expr::Keyword>();
ret.add_keywords::<stmt::Keyword>();
ret.add_keywords::<stmt::AssignOp>();
ret
}
pub type Brackets<I, F> = bracket::Brackets<I, F>;
pub fn round(input: impl Stream) -> impl Stream {
STMT.parse_stream(EXPR.parse_stream(Brackets::new('(', ')', |contents| {
let contents = EXPR.parse_stream(contents.into_iter()).read_all();
Round::new(contents)
}, input)))
}
pub fn brace(input: impl Stream) -> impl Stream {
round(Brackets::new('{', '}', |contents| {
let contents = round(contents.into_iter()).read_all();
Brace::new(contents)
}, input))
}
pub const EXPR: expr::Parser = expr::Parser;
pub const STMT: stmt::Parser = stmt::Parser;
}
#[cfg(test)]
mod tests {}