unlogic
Loading...
Searching...
No Matches
Parser.cpp File Reference
#include "Parser.h"

Go to the source code of this file.

Typedefs

using G = ParserGrammarType
 
using ValueType = ParserValueType
 

Functions

bf::DefineTerminal< G, R"(given)"> KW_GIVEN (SyntaxKeyword)
 
bf::DefineTerminal< G, R"(calc)"> KW_CALC (SyntaxKeyword)
 
bf::DefineTerminal< G, R"(plot)"> KW_PLOT (SyntaxKeyword)
 
bf::DefineTerminal< G, R"(on)"> KW_ON (SyntaxKeyword)
 
bf::DefineTerminal< G, R"(as)"> KW_AS (SyntaxKeyword)
 
bf::DefineTerminal< G, R"(\d+(\.\d+)?)", double > NUMBER (SyntaxLiteral, [](auto const &tok) -> ValueType { return std::stod(std::string(tok.raw));})
 
bf::DefineTerminal< G, R"([a-zA-Z]+)", std::string > IDENTIFIER (SyntaxIdentifier, [](auto const &tok) -> ValueType { return std::string(tok.raw);})
 
bf::DefineTerminal< G, R"(\^)"> OP_EXP (bf::Right, SyntaxOperator)
 
bf::DefineTerminal< G, R"(\*)"> OP_MUL (bf::Left, SyntaxOperator)
 
bf::DefineTerminal< G, R"(\/)"> OP_DIV (bf::Left, SyntaxOperator)
 
bf::DefineTerminal< G, R"(\+)"> OP_ADD (bf::Left, SyntaxOperator)
 
bf::DefineTerminal< G, R"(\-)"> OP_SUB (bf::Left, SyntaxOperator)
 
bf::DefineTerminal< G, R"(=)"> OP_ASN (bf::Left, SyntaxOperator)
 
bf::DefineTerminal< G, R"(\‍()"> PAR_OPEN(SyntaxGrouper);bf::DefineTerminal< G, R"(\‍))"> PAR_CLOSE (SyntaxGrouper)
 
bf::DefineTerminal< G, R"(\[)"> BRK_OPEN (SyntaxGrouper)
 
bf::DefineTerminal< G, R"(\])"> BRK_CLOSE (SyntaxGrouper)
 
bf::DefineTerminal< G, R"(;)"> STMT_DELIMITER (SyntaxOperator)
 
bf::DefineTerminal< G, R"(,)"> SEPARATOR (SyntaxOperator)
 

Variables

bf::DefineNonTerminal< G, std::vector< std::string > > identifier_list
 
bf::DefineNonTerminal< G, std::unique_ptr< Node > > expression
 
bf::DefineNonTerminal< G, std::vector< std::unique_ptr< Node > > > expression_list
 
bf::DefineNonTerminal< G, std::unique_ptr< Node > > function_call
 
bf::DefineNonTerminal< G, std::unique_ptr< Node > > function_definition
 
bf::DefineNonTerminal< Gvariable_definition = (KW_GIVEN + IDENTIFIER + OP_ASN + expression)
 
bf::DefineNonTerminal< G, std::unique_ptr< Node > > plot_command
 
bf::DefineNonTerminal< G, std::unique_ptr< Node > > statement
 
bf::DefineNonTerminal< G, std::vector< std::unique_ptr< Node > > > statement_list
 
bf::DefineNonTerminal< G, std::unique_ptr< Node > > scoped_block
 
bf::DefineNonTerminal< G, std::unique_ptr< Node > > program
 

Typedef Documentation

◆ G

Definition at line 5 of file Parser.cpp.

◆ ValueType

Definition at line 6 of file Parser.cpp.

Function Documentation

◆ BRK_CLOSE()

bf::DefineTerminal< G, R"(\])"> BRK_CLOSE ( SyntaxGrouper  )

◆ BRK_OPEN()

bf::DefineTerminal< G, R"(\[)"> BRK_OPEN ( SyntaxGrouper  )

◆ IDENTIFIER()

bf::DefineTerminal< G, R"([a-zA-Z]+)", std::string > IDENTIFIER ( SyntaxIdentifier  ,
[] (auto const &tok) -> ValueType { return std::string(tok.raw);}   
)

◆ KW_AS()

bf::DefineTerminal< G, R"(as)"> KW_AS ( SyntaxKeyword  )

◆ KW_CALC()

bf::DefineTerminal< G, R"(calc)"> KW_CALC ( SyntaxKeyword  )

◆ KW_GIVEN()

bf::DefineTerminal< G, R"(given)"> KW_GIVEN ( SyntaxKeyword  )

◆ KW_ON()

bf::DefineTerminal< G, R"(on)"> KW_ON ( SyntaxKeyword  )

◆ KW_PLOT()

bf::DefineTerminal< G, R"(plot)"> KW_PLOT ( SyntaxKeyword  )

◆ NUMBER()

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

◆ OP_ADD()

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

◆ OP_ASN()

bf::DefineTerminal< G, R"(=)"> OP_ASN ( bf::Left  ,
SyntaxOperator   
)

◆ OP_DIV()

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

◆ OP_EXP()

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

◆ OP_MUL()

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

◆ OP_SUB()

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

◆ PAR_CLOSE()

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

◆ SEPARATOR()

bf::DefineTerminal< G, R"(,)"> SEPARATOR ( SyntaxOperator  )

◆ STMT_DELIMITER()

bf::DefineTerminal< G, R"(;)"> STMT_DELIMITER ( SyntaxOperator  )

Variable Documentation

◆ expression

bf::DefineNonTerminal< G, std::unique_ptr< Node > > expression

Definition at line 82 of file Parser.cpp.

◆ expression_list

bf::DefineNonTerminal<G, std::vector<std::unique_ptr<Node> > > expression_list
Initial value:
= bf::PR<G>(expression)<=>[](auto &$) -> ValueType
{
std::vector<UniqueNode> list;
list.push_back(std::move(expression($[0])));
return std::move(list);
}
{
auto list = expression_list($[0]);
list.push_back(std::move(expression($[2])));
return std::move(list);
}
bf::DefineTerminal< G, R"(,)"> SEPARATOR(SyntaxOperator)
bf::DefineNonTerminal< G, std::vector< std::unique_ptr< Node > > > expression_list
Definition Parser.cpp:59
ParserValueType ValueType
Definition Parser.cpp:6
bf::DefineNonTerminal< G, std::unique_ptr< Node > > expression
Definition Parser.cpp:83
UniqueNode unique_node(Args &&... args)
Definition Node.h:144

Definition at line 58 of file Parser.cpp.

◆ function_call

bf::DefineNonTerminal<G, std::unique_ptr<Node> > function_call
Initial value:
{
}
bf::DefineTerminal< G, R"(\‍()"> PAR_OPEN(SyntaxGrouper);bf::DefineTerminal< G, R"(\‍))"> PAR_CLOSE(SyntaxGrouper)
bf::DefineTerminal< G, R"([a-zA-Z]+)", std::string > IDENTIFIER(SyntaxIdentifier, [](auto const &tok) -> ValueType { return std::string(tok.raw);})

Definition at line 75 of file Parser.cpp.

◆ function_definition

bf::DefineNonTerminal<G, std::unique_ptr<Node> > function_definition
Initial value:
{
);
}
{
std::vector<std::string>{},
);
}
bf::DefineNonTerminal< G, std::vector< std::string > > identifier_list
Definition Parser.cpp:43
bf::DefineTerminal< G, R"(given)"> KW_GIVEN(SyntaxKeyword)
bf::DefineTerminal< G, R"(=)"> OP_ASN(bf::Left, SyntaxOperator)

Definition at line 125 of file Parser.cpp.

◆ identifier_list

bf::DefineNonTerminal<G, std::vector<std::string> > identifier_list
Initial value:
= bf::PR<G>(IDENTIFIER)<=>[](auto &$) -> ValueType
{
return std::vector<std::string>{ IDENTIFIER($[0]) };
}
{
auto list = identifier_list($[0]);
list.push_back(IDENTIFIER($[2]));
return std::move(list);
}

Definition at line 42 of file Parser.cpp.

◆ plot_command

bf::DefineNonTerminal<G, std::unique_ptr<Node> > plot_command
Initial value:
= (KW_PLOT + IDENTIFIER)<=>[](auto &$) -> ValueType
{
}
bf::DefineTerminal< G, R"(plot)"> KW_PLOT(SyntaxKeyword)

Definition at line 148 of file Parser.cpp.

◆ program

bf::DefineNonTerminal<G, std::unique_ptr<Node> > program
Initial value:
= bf::PR<G>(scoped_block)<=>[](auto &$) -> ValueType
{
}
bf::DefineNonTerminal< G, std::unique_ptr< Node > > scoped_block
Definition Parser.cpp:184

Definition at line 190 of file Parser.cpp.

◆ scoped_block

bf::DefineNonTerminal<G, std::unique_ptr<Node> > scoped_block
Initial value:
= bf::PR<G>(statement_list)<=>[](auto &$) -> ValueType
{
}
bf::DefineNonTerminal< G, std::vector< std::unique_ptr< Node > > > statement_list
Definition Parser.cpp:167

Definition at line 183 of file Parser.cpp.

◆ statement

bf::DefineNonTerminal<G, std::unique_ptr<Node> > statement
Initial value:
{
return std::move($[0]);
}
| (plot_command + STMT_DELIMITER)<=>[](auto &$) -> ValueType
{
return std::move($[0]);
}
bf::DefineTerminal< G, R"(;)"> STMT_DELIMITER(SyntaxOperator)
bf::DefineNonTerminal< G, std::unique_ptr< Node > > plot_command
Definition Parser.cpp:149
bf::DefineNonTerminal< G, std::unique_ptr< Node > > function_definition
Definition Parser.cpp:126

Definition at line 155 of file Parser.cpp.

◆ statement_list

bf::DefineNonTerminal<G, std::vector<std::unique_ptr<Node> > > statement_list
Initial value:
= bf::PR<G>(statement)<=>[](auto &$) -> ValueType
{
std::vector<std::unique_ptr<Node>> list;
list.push_back(std::move(statement($[0])));
return std::move(list);
}
| (statement_list + statement)<=>[](auto &$) -> ValueType
{
auto list = statement_list($[0]);
list.push_back(std::move(statement($[1])));
return std::move(list);
}
bf::DefineNonTerminal< G, std::unique_ptr< Node > > statement
Definition Parser.cpp:156

Definition at line 166 of file Parser.cpp.

◆ variable_definition

bf::DefineNonTerminal<G> variable_definition = (KW_GIVEN + IDENTIFIER + OP_ASN + expression)

Definition at line 144 of file Parser.cpp.