Crossfire Server, Trunk
inja::Lexer Class Reference

Class for lexing an inja Template. More...

#include <inja.hpp>

+ Collaboration diagram for inja::Lexer:

Public Member Functions

SourceLocation current_position () const
 
const LexerConfig & get_config () const
 
 Lexer (const LexerConfig &config)
 
Token scan ()
 
void start (nonstd::string_view input)
 

Private Types

enum  MinusState { MinusState::Operator, MinusState::Number }
 
enum  State {
  State::Text, State::ExpressionStart, State::ExpressionStartForceLstrip, State::ExpressionBody,
  State::LineStart, State::LineBody, State::StatementStart, State::StatementStartNoLstrip,
  State::StatementStartForceLstrip, State::StatementBody, State::CommentStart, State::CommentStartForceLstrip,
  State::CommentBody
}
 

Private Member Functions

Token make_token (Token::Kind kind) const
 
Token scan_body (nonstd::string_view close, Token::Kind closeKind, nonstd::string_view close_trim=nonstd::string_view(), bool trim=false)
 
Token scan_id ()
 
Token scan_number ()
 
Token scan_string ()
 
void skip_whitespaces_and_first_newline ()
 
void skip_whitespaces_and_newlines ()
 

Static Private Member Functions

static nonstd::string_view clear_final_line_if_whitespace (nonstd::string_view text)
 

Private Attributes

const LexerConfig & config
 
nonstd::string_view m_in
 
MinusState minus_state
 
size_t pos
 
State state
 
size_t tok_start
 

Detailed Description

Class for lexing an inja Template.

Definition at line 1943 of file inja.hpp.

Member Enumeration Documentation

◆ MinusState

enum inja::Lexer::MinusState
strongprivate
Enumerator
Operator 
Number 

Definition at line 1960 of file inja.hpp.

◆ State

enum inja::Lexer::State
strongprivate
Enumerator
Text 
ExpressionStart 
ExpressionStartForceLstrip 
ExpressionBody 
LineStart 
LineBody 
StatementStart 
StatementStartNoLstrip 
StatementStartForceLstrip 
StatementBody 
CommentStart 
CommentStartForceLstrip 
CommentBody 

Definition at line 1944 of file inja.hpp.

Constructor & Destructor Documentation

◆ Lexer()

inja::Lexer::Lexer ( const LexerConfig &  config)
inlineexplicit

Definition at line 2200 of file inja.hpp.

Member Function Documentation

◆ clear_final_line_if_whitespace()

static nonstd::string_view inja::Lexer::clear_final_line_if_whitespace ( nonstd::string_view  text)
inlinestaticprivate

Definition at line 2184 of file inja.hpp.

References rotate-tower::result, and guild_entry::text.

◆ current_position()

SourceLocation inja::Lexer::current_position ( ) const
inline

Definition at line 2202 of file inja.hpp.

References inja::get_source_location().

Referenced by inja::Parser::throw_parser_error().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_config()

const LexerConfig& inja::Lexer::get_config ( ) const
inline

Definition at line 2354 of file inja.hpp.

Referenced by inja::Parser::parse_into_template().

+ Here is the caller graph for this function:

◆ make_token()

Token inja::Lexer::make_token ( Token::Kind  kind) const
inlineprivate

Definition at line 2154 of file inja.hpp.

References inja::string_view::slice().

+ Here is the call graph for this function:

◆ scan()

Token inja::Lexer::scan ( )
inline

Definition at line 2219 of file inja.hpp.

References inja::string_view::slice(), inja::string_view::starts_with(), dragon::state, and guild_entry::text.

Referenced by inja::Parser::get_next_token(), and inja::Parser::get_peek_token().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scan_body()

Token inja::Lexer::scan_body ( nonstd::string_view  close,
Token::Kind  closeKind,
nonstd::string_view  close_trim = nonstd::string_view(),
bool  trim = false 
)
inlineprivate

Definition at line 1974 of file inja.hpp.

References inja::string_view::starts_with(), dragon::state, and trim().

+ Here is the call graph for this function:

◆ scan_id()

Token inja::Lexer::scan_id ( )
inlineprivate

Definition at line 2107 of file inja.hpp.

◆ scan_number()

Token inja::Lexer::scan_number ( )
inlineprivate

Definition at line 2121 of file inja.hpp.

◆ scan_string()

Token inja::Lexer::scan_string ( )
inlineprivate

Definition at line 2136 of file inja.hpp.

References arch2xml::escape().

+ Here is the call graph for this function:

◆ skip_whitespaces_and_first_newline()

void inja::Lexer::skip_whitespaces_and_first_newline ( )
inlineprivate

Definition at line 2164 of file inja.hpp.

◆ skip_whitespaces_and_newlines()

void inja::Lexer::skip_whitespaces_and_newlines ( )
inlineprivate

Definition at line 2156 of file inja.hpp.

◆ start()

void inja::Lexer::start ( nonstd::string_view  input)
inline

Definition at line 2206 of file inja.hpp.

References inja::string_view::starts_with(), and dragon::state.

Referenced by inja::Parser::parse_into().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ config

const LexerConfig& inja::Lexer::config
private

Definition at line 1965 of file inja.hpp.

◆ m_in

nonstd::string_view inja::Lexer::m_in
private

Definition at line 1969 of file inja.hpp.

◆ minus_state

MinusState inja::Lexer::minus_state
private

Definition at line 1968 of file inja.hpp.

◆ pos

size_t inja::Lexer::pos
private

Definition at line 1971 of file inja.hpp.

◆ state

State inja::Lexer::state
private

Definition at line 1967 of file inja.hpp.

◆ tok_start

size_t inja::Lexer::tok_start
private

Definition at line 1970 of file inja.hpp.


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