#[macro_use]
extern crate dmntk_macros;
mod ast;
mod closure;
mod context;
mod errors;
mod lalr;
mod lexer;
mod parser;
mod scope;
#[cfg(test)]
mod tests;
pub use ast::{ast_tree, AstNode};
pub use closure::ClosureBuilder;
pub use scope::ParsingScope;
use crate::errors::*;
use crate::lalr::TokenType;
use crate::parser::Parser;
use dmntk_common::Result;
use dmntk_feel::{FeelScope, Name};
pub fn parse_expression(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
Parser::new(&scope.into(), TokenType::StartExpression, input, trace).parse()
}
pub fn parse_textual_expression(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
Parser::new(&scope.into(), TokenType::StartTextualExpression, input, trace).parse()
}
pub fn parse_textual_expressions(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
Parser::new(&scope.into(), TokenType::StartTextualExpressions, input, trace).parse()
}
pub fn parse_unary_tests(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
Parser::new(&scope.into(), TokenType::StartUnaryTests, input, trace).parse()
}
pub fn parse_name(scope: &FeelScope, input: &str, trace: bool) -> Result<Name> {
if let AstNode::Name(name) = Parser::new(&scope.into(), TokenType::StartTextualExpression, input, trace).parse()? {
Ok(name)
} else {
Err(err_not_a_feel_name(input))
}
}
pub fn parse_longest_name(input: &str) -> Result<Name> {
parse_name(&Default::default(), input, false)
}
pub fn parse_boxed_expression(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
Parser::new(&scope.into(), TokenType::StartBoxedExpression, input, trace).parse()
}
pub fn parse_context(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
Parser::new(&scope.into(), TokenType::StartContext, input, trace).parse()
}