Cadabra
Computer algebra system for field theory problems
Loading...
Searching...
No Matches
preprocessor Class Reference

Description

Preprocessing class which takes infix mathematical notation with all sorts of maths shortcuts and transforms it into a string which is properly formatted in prefix notation.

The Parser class then uses this result to turn the string into an Ex expression tree.

#include <PreProcessor.hh>

Classes

class  accu_t
 

Public Types

enum  order_labels {
  order_factorial =0 , order_pow , order_frac , order_prod ,
  order_wedge , order_minus , order_plus , order_dot ,
  order_equals , order_unequals , order_less_than , order_greater_than ,
  order_conditions , order_arrow , order_set_option , order_colon ,
  order_comma , order_tilde
}
 

Public Member Functions

 preprocessor ()
 
void erase ()
 
void strip_outer_brackets () const
 

Static Public Attributes

static const char32_t orders []
 
static const char32_t *const order_names []
 

Private Member Functions

void parse_ (const std::u32string &)
 
void parse_internal_ ()
 
bool unwind_ (unsigned int tolevel, unsigned int bracketgoal=0, bool usebracket=true) const
 
char32_t get_token_ (char32_t prev_token)
 
void show_and_throw_ (const std::string &str) const
 
void bracket_strings_ (char32_t cb, std::u32string &obrack, std::u32string &cbrack) const
 
bool is_infix_operator_ (char32_t c) const
 
bool is_link_ (char32_t c) const
 
unsigned int is_opening_bracket_ (char32_t c) const
 
unsigned int is_closing_bracket_ (char32_t c) const
 
unsigned int is_bracket_ (char32_t c) const
 
bool is_already_bracketed_ (const std::u32string &str) const
 
bool is_digits_ (const std::u32string &str) const
 
unsigned int current_bracket_ (bool deep=false) const
 
void print_stack () const
 
bool default_is_product_ () const
 

Private Attributes

bool verbatim_
 
bool next_is_product_
 
bool eat_initial_whitespace_
 
unsigned int cur_pos
 
std::u32string cur_str
 
accu_t cur
 
std::vector< accu_taccus
 

Static Private Attributes

static const char32_t open_brackets [] = { '{', '(', '[' }
 
static const char32_t close_brackets [] = { '}', ')', ']' }
 

Friends

std::istream & operator>> (std::istream &s, preprocessor &p)
 
std::ostream & operator<< (std::ostream &s, const preprocessor &p)
 

Member Enumeration Documentation

◆ order_labels

Enumerator
order_factorial 
order_pow 
order_frac 
order_prod 
order_wedge 
order_minus 
order_plus 
order_dot 
order_equals 
order_unequals 
order_less_than 
order_greater_than 
order_conditions 
order_arrow 
order_set_option 
order_colon 
order_comma 
order_tilde 

Constructor & Destructor Documentation

◆ preprocessor()

preprocessor::preprocessor ( )

Member Function Documentation

◆ bracket_strings_()

void preprocessor::bracket_strings_ ( char32_t cb,
std::u32string & obrack,
std::u32string & cbrack ) const
private

◆ current_bracket_()

unsigned int preprocessor::current_bracket_ ( bool deep = false) const
private

◆ default_is_product_()

bool preprocessor::default_is_product_ ( ) const
private

◆ erase()

void preprocessor::erase ( )

◆ get_token_()

char32_t preprocessor::get_token_ ( char32_t prev_token)
private

◆ is_already_bracketed_()

bool preprocessor::is_already_bracketed_ ( const std::u32string & str) const
private

◆ is_bracket_()

unsigned int preprocessor::is_bracket_ ( char32_t c) const
private

◆ is_closing_bracket_()

unsigned int preprocessor::is_closing_bracket_ ( char32_t c) const
private

◆ is_digits_()

bool preprocessor::is_digits_ ( const std::u32string & str) const
private

◆ is_infix_operator_()

bool preprocessor::is_infix_operator_ ( char32_t c) const
private

◆ is_link_()

bool preprocessor::is_link_ ( char32_t c) const
private

◆ is_opening_bracket_()

unsigned int preprocessor::is_opening_bracket_ ( char32_t c) const
private

◆ parse_()

void preprocessor::parse_ ( const std::u32string & str)
private

◆ parse_internal_()

void preprocessor::parse_internal_ ( )
private

◆ print_stack()

void preprocessor::print_stack ( ) const
private

◆ show_and_throw_()

void preprocessor::show_and_throw_ ( const std::string & str) const
private

◆ strip_outer_brackets()

void preprocessor::strip_outer_brackets ( ) const

◆ unwind_()

bool preprocessor::unwind_ ( unsigned int tolevel,
unsigned int bracketgoal = 0,
bool usebracket = true ) const
private

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & s,
const preprocessor & p )
friend

◆ operator>>

std::istream & operator>> ( std::istream & s,
preprocessor & p )
friend

Member Data Documentation

◆ accus

std::vector<accu_t> preprocessor::accus
mutableprivate

◆ close_brackets

const char32_t preprocessor::close_brackets = { '}', ')', ']' }
staticprivate

◆ cur

accu_t preprocessor::cur
mutableprivate

◆ cur_pos

unsigned int preprocessor::cur_pos
private

◆ cur_str

std::u32string preprocessor::cur_str
private

◆ eat_initial_whitespace_

bool preprocessor::eat_initial_whitespace_
private

◆ next_is_product_

bool preprocessor::next_is_product_
private

◆ open_brackets

const char32_t preprocessor::open_brackets = { '{', '(', '[' }
staticprivate

◆ order_names

const char32_t *const preprocessor::order_names
static
Initial value:
= { U"\\factorial",
U"\\pow", U"\\frac", U"\\prod", U"\\wedge",
U"\\sub", U"\\sum", U"\\sequence",
U"\\equals", U"\\unequals", U"\\less",
U"\\greater", U"\\conditional",
U"\\arrow", U"\\setoption", U"\\declare",
U"\\comma", U"\\tie", 0
}

◆ orders

const char32_t preprocessor::orders
static
Initial value:
= { '!', tok_pow, '/', '*', tok_wedge,
'-', '+', tok_sequence, '=', tok_unequals,
'<', '>', '|', tok_arrow, tok_set_option,
tok_declare, ',', '~', 0
}
@ tok_wedge
Definition PreProcessor.hh:27
@ tok_unequals
Definition PreProcessor.hh:27
@ tok_pow
Definition PreProcessor.hh:27
@ tok_arrow
Definition PreProcessor.hh:27
@ tok_sequence
Definition PreProcessor.hh:27
@ tok_set_option
Definition PreProcessor.hh:27
@ tok_declare
Definition PreProcessor.hh:27

◆ verbatim_

bool preprocessor::verbatim_
private

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