Crossfire Server, Trunk
inja::Parser Class Reference

Class for parsing an inja Template. More...

#include <inja.hpp>

+ Collaboration diagram for inja::Parser:

Public Member Functions

std::string load_file (nonstd::string_view filename)
 
Template parse (nonstd::string_view input)
 
Template parse (nonstd::string_view input, nonstd::string_view path)
 
void parse_into_template (Template &tmpl, nonstd::string_view filename)
 
 Parser (const ParserConfig &parser_config, const LexerConfig &lexer_config, TemplateStorage &template_storage, const FunctionStorage &function_storage)
 

Private Member Functions

void add_json_literal (const char *content_ptr)
 
void add_operator ()
 
void add_to_template_storage (nonstd::string_view path, std::string &template_name)
 
void get_next_token ()
 
void get_peek_token ()
 
bool parse_expression (Template &tmpl, Token::Kind closing)
 
void parse_into (Template &tmpl, nonstd::string_view path)
 
bool parse_statement (Template &tmpl, Token::Kind closing, nonstd::string_view path)
 
void throw_parser_error (const std::string &message)
 

Private Attributes

std::vector< std::shared_ptr< ExpressionNode > > arguments
 
std::stack< BlockStatementNode * > block_statement_stack
 
const ParserConfig & config
 
BlockNodecurrent_block {nullptr}
 
size_t current_brace_level {0}
 
size_t current_bracket_level {0}
 
ExpressionListNodecurrent_expression_list {nullptr}
 
size_t current_paren_level {0}
 
std::stack< ForStatementNode * > for_statement_stack
 
std::stack< std::pair< FunctionNode *, size_t > > function_stack
 
const FunctionStoragefunction_storage
 
bool have_peek_tok {false}
 
std::stack< IfStatementNode * > if_statement_stack
 
nonstd::string_view json_literal_start
 
Lexer lexer
 
std::stack< std::shared_ptr< FunctionNode > > operator_stack
 
Token peek_tok
 
TemplateStoragetemplate_storage
 
Token tok
 

Detailed Description

Class for parsing an inja Template.

Definition at line 2870 of file inja.hpp.

Constructor & Destructor Documentation

◆ Parser()

inja::Parser::Parser ( const ParserConfig &  parser_config,
const LexerConfig &  lexer_config,
TemplateStorage template_storage,
const FunctionStorage function_storage 
)
inlineexplicit

Definition at line 3457 of file inja.hpp.

Member Function Documentation

◆ add_json_literal()

void inja::Parser::add_json_literal ( const char *  content_ptr)
inlineprivate

Definition at line 2916 of file inja.hpp.

References inja::Token::text.

◆ add_operator()

void inja::Parser::add_operator ( )
inlineprivate

Definition at line 2921 of file inja.hpp.

◆ add_to_template_storage()

void inja::Parser::add_to_template_storage ( nonstd::string_view  path,
std::string &  template_name 
)
inlineprivate

Definition at line 2932 of file inja.hpp.

References python_init::path.

◆ get_next_token()

void inja::Parser::get_next_token ( )
inlineprivate

Definition at line 2900 of file inja.hpp.

References inja::Lexer::scan().

+ Here is the call graph for this function:

◆ get_peek_token()

void inja::Parser::get_peek_token ( )
inlineprivate

Definition at line 2909 of file inja.hpp.

References inja::Lexer::scan().

+ Here is the call graph for this function:

◆ load_file()

std::string inja::Parser::load_file ( nonstd::string_view  filename)
inline

Definition at line 3479 of file inja.hpp.

References mad_mage_user::file, npc_dialog::filename, inja::open_file_or_throw(), and guild_entry::text.

+ Here is the call graph for this function:

◆ parse() [1/2]

Template inja::Parser::parse ( nonstd::string_view  input)
inline

Definition at line 3467 of file inja.hpp.

◆ parse() [2/2]

Template inja::Parser::parse ( nonstd::string_view  input,
nonstd::string_view  path 
)
inline

Definition at line 3461 of file inja.hpp.

References python_init::path, and rotate-tower::result.

◆ parse_expression()

bool inja::Parser::parse_expression ( Template tmpl,
Token::Kind  closing 
)
inlineprivate

Definition at line 2948 of file inja.hpp.

References inja::Template::content, inja::FunctionStorage::find_function(), inja::Token::kind, None, guild_entry::text, and inja::Token::text.

+ Here is the call graph for this function:

◆ parse_into()

void inja::Parser::parse_into ( Template tmpl,
nonstd::string_view  path 
)
inlineprivate

Definition at line 3391 of file inja.hpp.

References inja::Template::content, inja::Token::describe(), inja::Token::kind, python_init::path, inja::Template::root, inja::Lexer::start(), and inja::Token::text.

+ Here is the call graph for this function:

◆ parse_into_template()

void inja::Parser::parse_into_template ( Template tmpl,
nonstd::string_view  filename 
)
inline

Definition at line 3471 of file inja.hpp.

References npc_dialog::filename, inja::Lexer::get_config(), and python_init::path.

+ Here is the call graph for this function:

◆ parse_statement()

bool inja::Parser::parse_statement ( Template tmpl,
Token::Kind  closing,
nonstd::string_view  path 
)
inlineprivate

◆ throw_parser_error()

void inja::Parser::throw_parser_error ( const std::string &  message)
inlineprivate

Definition at line 2896 of file inja.hpp.

References inja::Lexer::current_position(), INJA_THROW, and diamondslots::message.

+ Here is the call graph for this function:

Field Documentation

◆ arguments

std::vector<std::shared_ptr<ExpressionNode> > inja::Parser::arguments
private

Definition at line 2889 of file inja.hpp.

◆ block_statement_stack

std::stack<BlockStatementNode*> inja::Parser::block_statement_stack
private

Definition at line 2894 of file inja.hpp.

◆ config

const ParserConfig& inja::Parser::config
private

Definition at line 2871 of file inja.hpp.

◆ current_block

BlockNode* inja::Parser::current_block {nullptr}
private

Definition at line 2886 of file inja.hpp.

◆ current_brace_level

size_t inja::Parser::current_brace_level {0}
private

Definition at line 2882 of file inja.hpp.

◆ current_bracket_level

size_t inja::Parser::current_bracket_level {0}
private

Definition at line 2881 of file inja.hpp.

◆ current_expression_list

ExpressionListNode* inja::Parser::current_expression_list {nullptr}
private

Definition at line 2887 of file inja.hpp.

◆ current_paren_level

size_t inja::Parser::current_paren_level {0}
private

Definition at line 2880 of file inja.hpp.

◆ for_statement_stack

std::stack<ForStatementNode*> inja::Parser::for_statement_stack
private

Definition at line 2893 of file inja.hpp.

◆ function_stack

std::stack<std::pair<FunctionNode*, size_t> > inja::Parser::function_stack
private

Definition at line 2888 of file inja.hpp.

◆ function_storage

const FunctionStorage& inja::Parser::function_storage
private

Definition at line 2875 of file inja.hpp.

◆ have_peek_tok

bool inja::Parser::have_peek_tok {false}
private

Definition at line 2878 of file inja.hpp.

◆ if_statement_stack

std::stack<IfStatementNode*> inja::Parser::if_statement_stack
private

Definition at line 2892 of file inja.hpp.

◆ json_literal_start

nonstd::string_view inja::Parser::json_literal_start
private

Definition at line 2884 of file inja.hpp.

◆ lexer

Lexer inja::Parser::lexer
private

Definition at line 2873 of file inja.hpp.

◆ operator_stack

std::stack<std::shared_ptr<FunctionNode> > inja::Parser::operator_stack
private

Definition at line 2891 of file inja.hpp.

◆ peek_tok

Token inja::Parser::peek_tok
private

Definition at line 2877 of file inja.hpp.

◆ template_storage

TemplateStorage& inja::Parser::template_storage
private

Definition at line 2874 of file inja.hpp.

◆ tok

Token inja::Parser::tok
private

Definition at line 2877 of file inja.hpp.


The documentation for this class was generated from the following file: