forked from KPGPMC/furlang
Add unary expression parsing
Signed-off-by: CHatingPython <chatingpython@gmail.com>
This commit is contained in:
@@ -33,7 +33,8 @@ private:
|
||||
ast::literal_node_h parse_literal();
|
||||
|
||||
ast::expression_node_h parse_expression_primary();
|
||||
ast::expression_node_h parse_expression_rhs(const ast::expression_node_h& init, std::uint32_t precedence);
|
||||
ast::expression_node_h parse_expression_unary(std::uint32_t precedence);
|
||||
ast::expression_node_h parse_expression_rhs(ast::expression_node_h&& init, std::uint32_t precedence);
|
||||
|
||||
ast::function_body_h parse_body();
|
||||
private:
|
||||
|
||||
@@ -32,6 +32,8 @@ enum class token_t {
|
||||
Star,
|
||||
Slash,
|
||||
Percent,
|
||||
DPlus,
|
||||
DMinus,
|
||||
};
|
||||
|
||||
static inline std::ostream& operator<<(std::ostream& os, token_t type) {
|
||||
@@ -56,6 +58,8 @@ static inline std::ostream& operator<<(std::ostream& os, token_t type) {
|
||||
case token_t::Star: return os << "'*'";
|
||||
case token_t::Slash: return os << "'/'";
|
||||
case token_t::Percent: return os << "'%'";
|
||||
case token_t::DPlus: return os << "++";
|
||||
case token_t::DMinus: return os << "--";
|
||||
}
|
||||
return os;
|
||||
}
|
||||
@@ -82,6 +86,8 @@ static inline std::string operator+(const std::string& str, token_t type) {
|
||||
case token_t::Star: return str + "'*'";
|
||||
case token_t::Slash: return str + "'/'";
|
||||
case token_t::Percent: return str + "'%'";
|
||||
case token_t::DPlus: return str + "++";
|
||||
case token_t::DMinus: return str + "--";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
@@ -167,7 +173,9 @@ struct token {
|
||||
case token_t::Minus:
|
||||
case token_t::Star:
|
||||
case token_t::Slash:
|
||||
case token_t::Percent: return true;
|
||||
case token_t::Percent:
|
||||
case token_t::DPlus:
|
||||
case token_t::DMinus: return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user