Class for lexing an inja Template. More...
#include <inja.hpp>
Public Member Functions | |
| Lexer (const LexerConfig &config) | |
| SourceLocation | current_position () const |
| void | start (std::string_view input) |
| Token | scan () |
| const LexerConfig & | get_config () const |
Private Types | |
| enum class | State { Text , ExpressionStart , ExpressionStartForceLstrip , ExpressionBody , LineStart , LineBody , StatementStart , StatementStartNoLstrip , StatementStartForceLstrip , StatementBody , CommentStart , CommentStartForceLstrip , CommentBody } |
| enum class | MinusState { Operator , Number } |
Private Member Functions | |
| Token | scan_body (std::string_view close, Token::Kind closeKind, std::string_view close_trim=std::string_view(), bool trim=false) |
| Token | scan_id () |
| Token | scan_number () |
| Token | scan_string () |
| Token | make_token (Token::Kind kind) const |
| void | skip_whitespaces_and_newlines () |
| void | skip_whitespaces_and_first_newline () |
Static Private Member Functions | |
| static std::string_view | clear_final_line_if_whitespace (std::string_view text) |
Private Attributes | |
| const LexerConfig & | config |
| State | state |
| MinusState | minus_state |
| std::string_view | m_in |
| size_t | tok_start |
| size_t | pos |
|
strongprivate |
|
strongprivate |
Definition at line 1098 of file inja.hpp.
|
inlineexplicit |
Definition at line 1358 of file inja.hpp.
References config, minus_state, Number, state, and Text.
Referenced by inja::Parser::Parser().
|
inlinestaticprivate |
Definition at line 1342 of file inja.hpp.
Referenced by scan().
|
inline |
Definition at line 1364 of file inja.hpp.
References inja::get_source_location(), m_in, and tok_start.
Referenced by inja::Parser::throw_parser_error().
|
inline |
Definition at line 1517 of file inja.hpp.
References config.
Referenced by inja::Parser::parse_into_template().
|
inlineprivate |
Definition at line 1310 of file inja.hpp.
References m_in, pos, inja::string_view::slice(), tok_start, and inja::Token::Token().
Referenced by scan(), scan_body(), scan_id(), scan_number(), and scan_string().
|
inline |
Definition at line 1381 of file inja.hpp.
References clear_final_line_if_whitespace(), inja::LexerConfig::comment_close, inja::LexerConfig::comment_close_force_rstrip, inja::LexerConfig::comment_open, inja::LexerConfig::comment_open_force_lstrip, CommentBody, inja::Token::CommentClose, inja::Token::CommentOpen, CommentStart, CommentStartForceLstrip, config, inja::Token::Eof, inja::LexerConfig::expression_close, inja::LexerConfig::expression_close_force_rstrip, inja::LexerConfig::expression_open, inja::LexerConfig::expression_open_force_lstrip, ExpressionBody, inja::Token::ExpressionClose, inja::Token::ExpressionOpen, ExpressionStart, ExpressionStartForceLstrip, inja::LexerConfig::line_statement, LineBody, LineStart, inja::Token::LineStatementClose, inja::Token::LineStatementOpen, inja::LexerConfig::lstrip_blocks, m_in, make_token(), inja::LexerConfig::open_chars, pos, scan_body(), skip_whitespaces_and_first_newline(), inja::string_view::slice(), inja::string_view::starts_with(), state, inja::LexerConfig::statement_close, inja::LexerConfig::statement_close_force_rstrip, inja::LexerConfig::statement_open, inja::LexerConfig::statement_open_force_lstrip, inja::LexerConfig::statement_open_no_lstrip, StatementBody, inja::Token::StatementClose, inja::Token::StatementOpen, StatementStart, StatementStartForceLstrip, StatementStartNoLstrip, Text, inja::Token::Text, tok_start, inja::Token::Token(), and inja::LexerConfig::trim_blocks.
Referenced by inja::Parser::get_next_token(), and inja::Parser::get_peek_token().
|
inlineprivate |
Definition at line 1128 of file inja.hpp.
References inja::Token::Colon, inja::Token::Comma, inja::Token::Dot, inja::Token::Eof, inja::Token::Equal, inja::Token::GreaterEqual, inja::Token::GreaterThan, inja::Token::LeftBrace, inja::Token::LeftBracket, inja::Token::LeftParen, inja::Token::LessEqual, inja::Token::LessThan, m_in, make_token(), inja::Token::Minus, minus_state, inja::Token::NotEqual, Number, Operator, inja::Token::Percent, inja::Token::Plus, pos, inja::Token::Power, inja::Token::RightBrace, inja::Token::RightBracket, inja::Token::RightParen, scan_id(), scan_number(), scan_string(), skip_whitespaces_and_first_newline(), skip_whitespaces_and_newlines(), inja::Token::Slash, inja::string_view::starts_with(), state, Text, inja::Token::Times, tok_start, and inja::Token::Unknown.
Referenced by scan().
|
inlineprivate |
Definition at line 1261 of file inja.hpp.
References inja::Token::Id, m_in, make_token(), and pos.
Referenced by scan_body().
|
inlineprivate |
Definition at line 1275 of file inja.hpp.
References m_in, make_token(), inja::Token::Number, and pos.
Referenced by scan_body().
|
inlineprivate |
Definition at line 1292 of file inja.hpp.
References m_in, make_token(), pos, inja::Token::String, and tok_start.
Referenced by scan_body().
|
inlineprivate |
|
inlineprivate |
|
inline |
Definition at line 1368 of file inja.hpp.
References m_in, minus_state, Number, pos, inja::string_view::starts_with(), state, Text, and tok_start.
Referenced by inja::Parser::parse_into().
|
private |
Definition at line 1119 of file inja.hpp.
Referenced by get_config(), Lexer(), and scan().
|
private |
Definition at line 1123 of file inja.hpp.
Referenced by current_position(), make_token(), scan(), scan_body(), scan_id(), scan_number(), scan_string(), skip_whitespaces_and_first_newline(), skip_whitespaces_and_newlines(), and start().
|
private |
Definition at line 1122 of file inja.hpp.
Referenced by Lexer(), scan_body(), and start().
|
private |
Definition at line 1125 of file inja.hpp.
Referenced by make_token(), scan(), scan_body(), scan_id(), scan_number(), scan_string(), skip_whitespaces_and_first_newline(), skip_whitespaces_and_newlines(), and start().
|
private |
|
private |
Definition at line 1124 of file inja.hpp.
Referenced by current_position(), make_token(), scan(), scan_body(), scan_string(), and start().