Class for parsing an inja Template. More...
#include <inja.hpp>
Public Member Functions | |
| Parser (const ParserConfig &parser_config, const LexerConfig &lexer_config, TemplateStorage &template_storage, const FunctionStorage &function_storage) | |
| Template | parse (std::string_view input, std::string_view path) |
| void | parse_into_template (Template &tmpl, std::string_view filename) |
| std::string | load_file (const std::string &filename) |
Private Types | |
| using | Arguments = std::vector<std::shared_ptr<ExpressionNode>> |
| using | OperatorStack = std::stack<std::shared_ptr<FunctionNode>> |
Private Member Functions | |
| void | throw_parser_error (const std::string &message) const |
| void | get_next_token () |
| void | get_peek_token () |
| void | add_literal (Arguments &arguments, const char *content_ptr) |
| void | add_operator (Arguments &arguments, OperatorStack &operator_stack) |
| void | add_to_template_storage (std::string_view path, std::string &template_name) |
| std::string | parse_filename () const |
| bool | parse_expression (Template &tmpl, Token::Kind closing) |
| std::shared_ptr< ExpressionNode > | parse_expression (Template &tmpl) |
| bool | parse_statement (Template &tmpl, Token::Kind closing, std::string_view path) |
| void | parse_into (Template &tmpl, std::string_view path) |
Private Attributes | |
| const ParserConfig & | config |
| Lexer | lexer |
| TemplateStorage & | template_storage |
| const FunctionStorage & | function_storage |
| Token | tok |
| Token | peek_tok |
| bool | have_peek_tok {false} |
| std::string_view | literal_start |
| BlockNode * | current_block {nullptr} |
| ExpressionListNode * | current_expression_list {nullptr} |
| std::stack< IfStatementNode * > | if_statement_stack |
| std::stack< ForStatementNode * > | for_statement_stack |
| std::stack< BlockStatementNode * > | block_statement_stack |
|
private |
|
private |
|
inlineexplicit |
Definition at line 2141 of file inja.hpp.
References config, function_storage, inja::Lexer::Lexer(), lexer, and template_storage.
|
inlineprivate |
Definition at line 1581 of file inja.hpp.
References literal_start, inja::Token::text, and tok.
|
inlineprivate |
Definition at line 1587 of file inja.hpp.
References inja::FunctionNode::arguments, inja::FunctionNode::number_args, and throw_parser_error().
|
inlineprivate |
Definition at line 1602 of file inja.hpp.
References config, inja::FileError::FileError(), inja::ParserConfig::include_callback, parse_into_template(), inja::ParserConfig::search_included_templates_in_files, inja::Template::Template(), and template_storage.
Referenced by parse_statement().
|
inlineprivate |
Definition at line 1565 of file inja.hpp.
References have_peek_tok, lexer, peek_tok, inja::Lexer::scan(), and tok.
Referenced by parse_expression(), parse_into(), and parse_statement().
|
inlineprivate |
Definition at line 1574 of file inja.hpp.
References have_peek_tok, lexer, peek_tok, and inja::Lexer::scan().
Referenced by parse_expression().
|
inline |
Definition at line 2165 of file inja.hpp.
References inja::FileError::FileError().
Referenced by inja::Environment::load_file(), and inja::Environment::parse_template().
|
inline |
Definition at line 2151 of file inja.hpp.
References parse_into(), and inja::Template::Template().
Referenced by inja::Environment::parse().
|
inlineprivate |
Definition at line 1659 of file inja.hpp.
References inja::FunctionStorage::Add, inja::FunctionStorage::And, inja::FunctionNode::arguments, inja::FunctionNode::associativity, inja::FunctionStorage::AtId, inja::FunctionStorage::Callback, inja::FunctionNode::callback, inja::FunctionStorage::FunctionData::callback, inja::Token::Colon, inja::Token::Comma, inja::Template::content, inja::Token::describe(), inja::FunctionStorage::Division, inja::Token::Dot, inja::Token::Eof, inja::FunctionStorage::Equal, inja::Token::Equal, inja::FunctionStorage::find_function(), function_storage, get_next_token(), get_peek_token(), inja::FunctionStorage::Greater, inja::FunctionStorage::GreaterEqual, inja::Token::GreaterEqual, inja::Token::GreaterThan, inja::Token::Id, inja::FunctionStorage::In, inja::Token::kind, inja::FunctionNode::Left, inja::Token::LeftBrace, inja::Token::LeftBracket, inja::Token::LeftParen, inja::FunctionStorage::Less, inja::FunctionStorage::LessEqual, inja::Token::LessEqual, inja::Token::LessThan, literal_start, inja::Token::Minus, inja::FunctionStorage::Modulo, inja::FunctionStorage::Multiplication, inja::FunctionNode::name, inja::FunctionStorage::None, inja::FunctionStorage::Not, inja::FunctionStorage::NotEqual, inja::Token::NotEqual, inja::Token::Number, inja::FunctionNode::number_args, inja::FunctionNode::operation, inja::FunctionStorage::FunctionData::operation, inja::FunctionStorage::Or, parse_expression(), peek_tok, inja::Token::Percent, inja::Token::Plus, inja::FunctionStorage::Power, inja::Token::Power, inja::FunctionNode::precedence, inja::Token::RightBrace, inja::Token::RightBracket, inja::Token::RightParen, inja::Token::Slash, inja::Token::String, inja::FunctionStorage::Subtract, inja::Token::text, throw_parser_error(), inja::Token::Times, and tok.
Referenced by parse_expression(), and parse_expression().
|
inlineprivate |
Definition at line 1654 of file inja.hpp.
References current_expression_list, inja::Token::kind, parse_expression(), inja::ExpressionListNode::root, and tok.
Referenced by parse_into(), and parse_statement().
|
inlineprivate |
Definition at line 1641 of file inja.hpp.
References inja::Token::describe(), inja::Token::kind, inja::Token::String, inja::Token::text, throw_parser_error(), and tok.
Referenced by parse_statement().
|
inlineprivate |
Definition at line 2078 of file inja.hpp.
References inja::Token::CommentClose, inja::Token::CommentOpen, inja::Template::content, current_block, current_expression_list, inja::Token::describe(), inja::Token::Eof, inja::Token::ExpressionClose, inja::Token::ExpressionOpen, for_statement_stack, get_next_token(), if_statement_stack, inja::Token::kind, lexer, inja::Token::LineStatementClose, inja::Token::LineStatementOpen, inja::BlockNode::nodes, parse_expression(), parse_statement(), inja::Template::root, inja::Lexer::start(), inja::Token::StatementClose, inja::Token::StatementOpen, inja::Token::Text, inja::Token::text, throw_parser_error(), and tok.
Referenced by parse(), and parse_into_template().
|
inline |
Definition at line 2157 of file inja.hpp.
References config, function_storage, inja::Lexer::get_config(), lexer, parse_into(), and template_storage.
Referenced by add_to_template_storage(), and inja::Environment::parse_template().
|
inlineprivate |
Definition at line 1887 of file inja.hpp.
References add_to_template_storage(), inja::BlockStatementNode::block, block_statement_stack, inja::Template::block_storage, inja::ForStatementNode::body, inja::Token::Comma, inja::ForStatementNode::condition, inja::IfStatementNode::condition, inja::Template::content, current_block, current_expression_list, inja::Token::describe(), inja::SetStatementNode::expression, inja::IfStatementNode::false_statement, for_statement_stack, get_next_token(), inja::IfStatementNode::has_false_statement, inja::Token::Id, if_statement_stack, inja::IfStatementNode::is_nested, inja::Token::kind, inja::BlockNode::nodes, inja::BlockStatementNode::parent, inja::ForStatementNode::parent, inja::IfStatementNode::parent, parse_expression(), parse_filename(), inja::Token::text, throw_parser_error(), tok, and inja::IfStatementNode::true_statement.
Referenced by parse_into().
|
inlineprivate |
Definition at line 1561 of file inja.hpp.
References inja::Lexer::current_position(), lexer, and inja::ParserError::ParserError().
Referenced by add_operator(), parse_expression(), parse_filename(), parse_into(), and parse_statement().
|
private |
Definition at line 1559 of file inja.hpp.
Referenced by parse_statement().
|
private |
Definition at line 1543 of file inja.hpp.
Referenced by add_to_template_storage(), parse_into_template(), and Parser().
|
private |
Definition at line 1554 of file inja.hpp.
Referenced by parse_into(), and parse_statement().
|
private |
Definition at line 1555 of file inja.hpp.
Referenced by parse_expression(), parse_into(), and parse_statement().
|
private |
Definition at line 1558 of file inja.hpp.
Referenced by parse_into(), and parse_statement().
|
private |
Definition at line 1547 of file inja.hpp.
Referenced by parse_expression(), parse_into_template(), and Parser().
|
private |
Definition at line 1550 of file inja.hpp.
Referenced by get_next_token(), and get_peek_token().
|
private |
Definition at line 1557 of file inja.hpp.
Referenced by parse_into(), and parse_statement().
|
private |
Definition at line 1545 of file inja.hpp.
Referenced by get_next_token(), get_peek_token(), parse_into(), parse_into_template(), Parser(), and throw_parser_error().
|
private |
Definition at line 1552 of file inja.hpp.
Referenced by add_literal(), and parse_expression().
|
private |
Definition at line 1549 of file inja.hpp.
Referenced by get_next_token(), get_peek_token(), and parse_expression().
|
private |
Definition at line 1546 of file inja.hpp.
Referenced by add_to_template_storage(), parse_into_template(), and Parser().
|
private |
Definition at line 1549 of file inja.hpp.
Referenced by add_literal(), get_next_token(), parse_expression(), parse_expression(), parse_filename(), parse_into(), and parse_statement().