1#![doc = include_str!("../docs/README.md")]
2#![deny(rustdoc::broken_intra_doc_links)]
3
4#[macro_use]
5extern crate dsntk_macros;
6
7mod ast;
8mod closure;
9mod context;
10mod errors;
11mod lalr;
12mod lexer;
13mod parser;
14mod scope;
15
16#[cfg(test)]
17mod tests;
18
19pub use ast::AstNode;
20pub use closure::ClosureBuilder;
21pub use scope::ParsingScope;
22
23use crate::errors::*;
24use crate::lalr::TokenType;
25use crate::parser::Parser;
26use dsntk_common::Result;
27use dsntk_feel::{FeelScope, Name};
28
29pub fn parse_expression(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
31 Parser::new(&scope.into(), TokenType::StartExpression, input, trace).parse()
32}
33
34pub fn parse_textual_expression(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
36 Parser::new(&scope.into(), TokenType::StartTextualExpression, input, trace).parse()
37}
38
39pub fn parse_textual_expressions(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
41 Parser::new(&scope.into(), TokenType::StartTextualExpressions, input, trace).parse()
42}
43
44pub fn parse_simple_expression(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
46 Parser::new(&scope.into(), TokenType::StartSimpleExpression, input, trace).parse()
47}
48
49pub fn parse_simple_expressions(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
51 Parser::new(&scope.into(), TokenType::StartSimpleExpressions, input, trace).parse()
52}
53
54pub fn parse_unary_tests(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
56 Parser::new(&scope.into(), TokenType::StartUnaryTests, input, trace).parse()
57}
58
59pub fn parse_simple_value(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
61 Parser::new(&scope.into(), TokenType::StartSimpleValue, input, trace).parse()
62}
63
64pub fn parse_name(scope: &FeelScope, input: &str, trace: bool) -> Result<Name> {
66 if let AstNode::Name(name) = Parser::new(&scope.into(), TokenType::StartTextualExpression, input, trace).parse()? {
67 Ok(name)
68 } else {
69 Err(err_not_a_feel_name(input))
70 }
71}
72
73pub fn parse_longest_name(input: &str) -> Result<Name> {
75 parse_name(&Default::default(), input, false)
76}
77
78pub fn parse_boxed_expression(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
80 Parser::new(&scope.into(), TokenType::StartBoxedExpression, input, trace).parse()
81}
82
83pub fn parse_context(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
85 Parser::new(&scope.into(), TokenType::StartBoxedExpression, input, trace).parse()
86}
87
88pub fn parse_range_literal(scope: &FeelScope, input: &str, trace: bool) -> Result<AstNode> {
90 Parser::new(&scope.into(), TokenType::StartRangeLiteral, input, trace).parse()
91}