#ifndef __SCANNERS_MATH_PARSER_H
#define __SCANNERS_MATH_PARSER_H
/*
5D programming language
Copyright (C) 2011 Danny Milosavljevic
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see .
*/
#include
#include "Scanners/Scanner"
#include "Values/Values"
#include "Scanners/ShuntingYardParser"
namespace Scanners {
#ifndef OLD_PARSER
typedef ShuntingYardParser MathParser;
#else
class MathParser : public Scanner {
protected:
bool B_process_macros;
OperatorPrecedenceList* operator_precedence_list;
private:
AST::Cons* bound_symbols;
Values::NodeT parse_value(void);
Values::NodeT parse_application(void);
Values::NodeT parse_argument(void);
Values::NodeT parse_binary_operation(bool B_allow_args, int precedence_level);
Values::NodeT parse_abstraction(void);
Values::NodeT operation(Values::NodeT operator_, Values::NodeT operand_1, Values::NodeT operand_2);
Values::NodeT parse_macro(Values::NodeT operand_1);
Values::NodeT parse_define(Values::NodeT operand_1);
Values::NodeT parse_defrec(Values::NodeT operand_1);
Values::NodeT parse_quote(Values::NodeT operand_1);
Values::NodeT parse_list(void);
Values::NodeT parse_let_form(void);
protected:
Values::NodeT parse_expression(void);
AST::Cons* parse_S_list_body(void);
public:
void parseClosingBrace(void);
Values::NodeT parse(OperatorPrecedenceList* operator_precedence_list);
AST::Cons* parseSList(bool B_consume_closing_brace);
Values::NodeT parseSExpression(void);
static Values::NodeT parse_simple(const char* text, OperatorPrecedenceList* operator_precedence_list); // TODO remove
MathParser(void);
void push(FILE* input_file, int line_number);
protected:
void enter_abstraction(AST::Symbol* name);
void leave_abstraction(AST::Symbol* name);
public:
std::set get_bound_symbols(const char* prefix);
};
bool macro_operator_P(Values::NodeT operator_);
#endif
}; /* end namespace Scanners */
#endif /* ndef __SCANNERS_MATH_PARSER_H */