Tensorium
Loading...
Searching...
No Matches
Lexer Class Reference

#include <Latex.hpp>

Collaboration diagram for Lexer:

Public Member Functions

 Lexer (const std::string &input)
 
std::vector< Tokentokenize ()
 

Private Member Functions

char peek () const
 
char get ()
 
bool eof () const
 
void skipWhitespace ()
 
Token parseNumber ()
 
Token parseCommandOrSymbol ()
 

Private Attributes

std::string input
 
size_t pos
 

Static Private Attributes

static const std::unordered_map< std::string, TokenTypeSyntaxTable
 
static const std::unordered_map< std::string, GreekSymbolminusGreekMapLower
 
static const std::unordered_map< std::string, GreekSymbolplusGreekMapUpper
 

Constructor & Destructor Documentation

◆ Lexer()

Lexer::Lexer ( const std::string & input)
inlineexplicit

Member Function Documentation

◆ eof()

bool Lexer::eof ( ) const
inlineprivate

References input, and pos.

Referenced by parseCommandOrSymbol(), parseNumber(), skipWhitespace(), and tokenize().

Here is the caller graph for this function:

◆ get()

char Lexer::get ( )
inlineprivate

References input, and pos.

Referenced by parseCommandOrSymbol(), parseNumber(), skipWhitespace(), and tokenize().

Here is the caller graph for this function:

◆ parseCommandOrSymbol()

Token Lexer::parseCommandOrSymbol ( )
inlineprivate

References alpha, Alpha, eof(), get(), GreekMapLower, GreekMapUpper, peek(), symbol, and SyntaxTable.

Referenced by tokenize().

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

◆ parseNumber()

Token Lexer::parseNumber ( )
inlineprivate

References eof(), get(), integer, peek(), and real.

Referenced by tokenize().

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

◆ peek()

char Lexer::peek ( ) const
inlineprivate

References input, and pos.

Referenced by parseCommandOrSymbol(), parseNumber(), skipWhitespace(), and tokenize().

Here is the caller graph for this function:

◆ skipWhitespace()

void Lexer::skipWhitespace ( )
inlineprivate

References eof(), get(), and peek().

Referenced by tokenize().

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

◆ tokenize()

std::vector< Token > Lexer::tokenize ( )
inline

References end, eof(), get(), parseCommandOrSymbol(), parseNumber(), peek(), skipWhitespace(), SyntaxTable, and unknown.

Here is the call graph for this function:

Member Data Documentation

◆ GreekMapLower

const std::unordered_map<std::string, GreekSymbolminus> Lexer::GreekMapLower
inlinestaticprivate
Initial value:
= {
}

Referenced by parseCommandOrSymbol().

◆ GreekMapUpper

const std::unordered_map<std::string, GreekSymbolplus> Lexer::GreekMapUpper
inlinestaticprivate
Initial value:
= {
{"\\Alpha", GreekSymbolplus::Alpha}, {"\\Beta", GreekSymbolplus::Beta},
{"\\Gamma", GreekSymbolplus::Gamma}, {"\\Delta", GreekSymbolplus::Delta},
{"\\Epsilon", GreekSymbolplus::Epsilon}, {"\\Zeta", GreekSymbolplus::Zeta},
{"\\Eta", GreekSymbolplus::Eta}, {"\\Theta", GreekSymbolplus::Theta},
{"\\Iota", GreekSymbolplus::Iota}, {"\\Kappa", GreekSymbolplus::Kappa},
{"\\Lambda", GreekSymbolplus::Lambda}, {"\\Mu", GreekSymbolplus::Mu},
{"\\Omicron", GreekSymbolplus::Omicron}, {"\\Pi", GreekSymbolplus::Pi},
{"\\Rho", GreekSymbolplus::Rho}, {"\\Sigma", GreekSymbolplus::Sigma},
{"\\Tau", GreekSymbolplus::Tau}, {"\\Upsilon", GreekSymbolplus::Upsilon},
}

Referenced by parseCommandOrSymbol().

◆ input

std::string Lexer::input
private

Referenced by eof(), get(), and peek().

◆ pos

size_t Lexer::pos
private

Referenced by eof(), get(), and peek().

◆ SyntaxTable

const std::unordered_map<std::string, TokenType> Lexer::SyntaxTable
inlinestaticprivate

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