Implement elsif do
This commit is contained in:
@ -617,6 +617,7 @@ namespace boot
|
||||
conditional_statements *m_body;
|
||||
|
||||
public:
|
||||
std::vector<conditional_statements *> branches;
|
||||
while_statement(const struct position position, conditional_statements *body);
|
||||
virtual void accept(parser_visitor *visitor) override;
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace boot
|
||||
/**
|
||||
* Symbol table.
|
||||
*/
|
||||
template<typename T>
|
||||
template<typename T, T nothing>
|
||||
class symbol_table
|
||||
{
|
||||
public:
|
||||
@ -73,7 +73,7 @@ namespace boot
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for symbol in the table by name. Returns nullptr if the symbol
|
||||
* Looks for symbol in the table by name. Returns nothing if the symbol
|
||||
* can not be found.
|
||||
*
|
||||
* \param name Symbol name.
|
||||
@ -91,7 +91,7 @@ namespace boot
|
||||
{
|
||||
return this->outer_scope->lookup(name);
|
||||
}
|
||||
return nullptr;
|
||||
return nothing;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,7 +104,14 @@ namespace boot
|
||||
*/
|
||||
bool enter(const std::string& name, symbol_ptr entry)
|
||||
{
|
||||
return entries.insert({ name, entry }).second;
|
||||
if (lookup(name) == nothing)
|
||||
{
|
||||
return entries.insert({ name, entry }).second;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nothing;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ namespace gcc
|
||||
class generic_visitor final : public boot::empty_visitor
|
||||
{
|
||||
tree current_expression{ NULL_TREE };
|
||||
std::shared_ptr<boot::symbol_table<tree>> symbol_map;
|
||||
std::shared_ptr<symbol_table> symbol_map;
|
||||
|
||||
tree build_label_decl(const char *name, location_t loc);
|
||||
tree build_type(boot::top_type& type);
|
||||
@ -61,7 +61,7 @@ namespace gcc
|
||||
tree symbol, const std::vector<boot::expression *>& arguments);
|
||||
|
||||
public:
|
||||
generic_visitor(std::shared_ptr<boot::symbol_table<tree>> symbol_table);
|
||||
generic_visitor(std::shared_ptr<symbol_table> symbol_table);
|
||||
|
||||
void visit(boot::program *program) override;
|
||||
void visit(boot::procedure_definition *definition) override;
|
||||
|
@ -33,6 +33,8 @@ namespace elna
|
||||
{
|
||||
namespace gcc
|
||||
{
|
||||
using symbol_table = boot::symbol_table<tree, NULL_TREE>;
|
||||
|
||||
bool is_pointer_type(tree type);
|
||||
bool is_integral_type(tree type);
|
||||
bool is_numeric_type(tree type);
|
||||
|
Reference in New Issue
Block a user