1#[macro_use]
4extern crate dsntk_macros;
5
6mod ast;
7mod closure;
8mod context;
9mod errors;
10mod lalr;
11mod lexer;
12mod parser;
13mod scope;
14
15#[cfg(test)]
16mod tests;
17
18pub use ast::AstNode;
19pub use closure::ClosureBuilder;
20pub use scope::ParsingScope;
21
22use crate::errors::*;
23use crate::lalr::TokenType;
24use crate::parser::Parser;
25use dsntk_common::Result;
26use dsntk_feel::{FeelScope, Name};
27
28pub fn parse_expression(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
30 Parser::new(&scope.into(), TokenType::StartExpression, input, trace).parse()
31}
32
33pub fn parse_textual_expression(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
35 Parser::new(&scope.into(), TokenType::StartTextualExpression, input, trace).parse()
36}
37
38pub fn parse_textual_expressions(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
40 Parser::new(&scope.into(), TokenType::StartTextualExpressions, input, trace).parse()
41}
42
43pub fn parse_simple_expression(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
45 Parser::new(&scope.into(), TokenType::StartSimpleExpression, input, trace).parse()
46}
47
48pub fn parse_simple_expressions(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
50 Parser::new(&scope.into(), TokenType::StartSimpleExpressions, input, trace).parse()
51}
52
53pub fn parse_unary_tests(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
55 Parser::new(&scope.into(), TokenType::StartUnaryTests, input, trace).parse()
56}
57
58pub fn parse_simple_value(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
60 Parser::new(&scope.into(), TokenType::StartSimpleValue, input, trace).parse()
61}
62
63pub fn parse_name(scope: &FeelScope, input: &str, trace: bool) -> Result<Name> {
65 if let AstNode::Name(name) = Parser::new(&scope.into(), TokenType::StartTextualExpression, input, trace).parse()? {
66 Ok(name)
67 } else {
68 Err(err_not_a_feel_name(input))
69 }
70}
71
72pub fn parse_longest_name(input: &str) -> Result<Name> {
74 parse_name(&Default::default(), input, false)
75}
76
77pub fn parse_boxed_expression(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
79 Parser::new(&scope.into(), TokenType::StartBoxedExpression, input, trace).parse()
80}
81
82pub fn parse_context(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
84 Parser::new(&scope.into(), TokenType::StartBoxedExpression, input, trace).parse()
85}
86
87pub fn parse_range_literal(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
89 Parser::new(&scope.into(), TokenType::StartRangeLiteral, input, trace).parse()
90}