buffalo
Loading...
Searching...
No Matches
buffalo.test.cpp File Reference
#include <gtest/gtest.h>
#include <buffalo/buffalo.h>
#include <cmath>

Go to the source code of this file.

Typedefs

using G = bf::GrammarDefinition< double >
 

Functions

bf::DefineTerminal< G, R"(\*)"> OP_MUL (bf::Left)
 
 TEST (Parser, Construction)
 
 TEST (Parser, Evaluation)
 
 TEST (Tokenization, Strict)
 
 TEST (Tokenization, Permissive)
 

Variables

bf::DefineTerminal< G, R"(\d+(\.\d+)?)", double > NUMBER ([](auto const &tok) { return std::stod(std::string(tok.raw));})
 
bf::DefineTerminal< G, R"(\^)"> OP_EXP (bf::Right)
 
bf::DefineTerminal< G, R"(\/)"> OP_DIV (bf::Left)
 
bf::DefineTerminal< G, R"(\+)"> OP_ADD (bf::Left)
 
bf::DefineTerminal< G, R"(\-)"> OP_SUB (bf::Left)
 
bf::DefineTerminal< G, R"(\‍()"> PAR_OPEN;bf::DefineTerminal< G, R"(\‍))"> PAR_CLOSE
 
bf::DefineNonTerminal< Gexpression
 
bf::DefineNonTerminal< Gstatement
 

Typedef Documentation

◆ G

using G = bf::GrammarDefinition<double>

Definition at line 8 of file buffalo.test.cpp.

Function Documentation

◆ OP_MUL()

bf::DefineTerminal< G, R"(\*)"> OP_MUL ( bf::Left  )

◆ TEST() [1/4]

TEST ( Parser  ,
Construction   
)

Definition at line 47 of file buffalo.test.cpp.

◆ TEST() [2/4]

TEST ( Parser  ,
Evaluation   
)

Definition at line 53 of file buffalo.test.cpp.

◆ TEST() [3/4]

TEST ( Tokenization  ,
Permissive   
)

Definition at line 90 of file buffalo.test.cpp.

◆ TEST() [4/4]

TEST ( Tokenization  ,
Strict   
)

Definition at line 63 of file buffalo.test.cpp.

Variable Documentation

◆ expression

bf::DefineNonTerminal<G> expression
Initial value:
= bf::PR<G>(NUMBER)<=>[](auto &$) { return $[0]; }
| (PAR_OPEN + expression + PAR_CLOSE)<=>[](auto &$) { return $[1]; }
| (expression + OP_EXP + expression)<=>[](auto &$) { return std::pow($[0], $[2]); }
| (expression + OP_MUL + expression)<=>[](auto &$) { return $[0] * $[2]; }
| (expression + OP_DIV + expression)<=>[](auto &$) { return $[0] / $[2]; }
| (expression + OP_ADD + expression)<=>[](auto &$) { return $[0] + $[2]; }
| (expression + OP_SUB + expression)<=>[](auto &$) { return $[0] - $[2]; }
bf::DefineNonTerminal< G > expression
bf::DefineTerminal< G, R"(\*)"> OP_MUL(bf::Left)
bf::DefineTerminal< G, R"(\‍()"> PAR_OPEN;bf::DefineTerminal< G, R"(\‍))"> PAR_CLOSE
bf::DefineTerminal< G, R"(\+)"> OP_ADD(bf::Left)
bf::DefineTerminal< G, R"(\^)"> OP_EXP(bf::Right)
bf::DefineTerminal< G, R"(\d+(\.\d+)?)", double > NUMBER([](auto const &tok) { return std::stod(std::string(tok.raw));})
bf::DefineTerminal< G, R"(\/)"> OP_DIV(bf::Left)
bf::DefineTerminal< G, R"(\-)"> OP_SUB(bf::Left)
ProductionRule< G > PR
Definition buffalo.h:438

Definition at line 30 of file buffalo.test.cpp.

◆ NUMBER

bf::DefineTerminal< G, R"(\d+(\.\d+)?)", double > NUMBER([](auto const &tok) { return std::stod(std::string(tok.raw));}) ( [] (auto const &tok) { return std::stod(std::string(tok.raw));}  )

◆ OP_ADD

bf::DefineTerminal< G, R"(\+)"> OP_ADD(bf::Left) ( bf::Left  )

◆ OP_DIV

bf::DefineTerminal< G, R"(\/)"> OP_DIV(bf::Left) ( bf::Left  )

◆ OP_EXP

bf::DefineTerminal< G, R"(\^)"> OP_EXP(bf::Right) ( bf::Right  )

◆ OP_SUB

bf::DefineTerminal< G, R"(\-)"> OP_SUB(bf::Left) ( bf::Left  )

◆ PAR_CLOSE

bf::DefineTerminal<G, R"(\‍()"> PAR_OPEN;bf::DefineTerminal<G, R"(\‍))"> PAR_CLOSE

Definition at line 25 of file buffalo.test.cpp.

◆ statement

Initial value:
= bf::PR<G>(expression)<=>[](auto &$)
{
return $[0];
}

Definition at line 40 of file buffalo.test.cpp.