Skip parameter names in procedure type expressions
This commit is contained in:
		
							
								
								
									
										70
									
								
								boot/ast.cc
									
									
									
									
									
								
							
							
						
						
									
										70
									
								
								boot/ast.cc
									
									
									
									
									
								
							@@ -17,9 +17,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
 | 
			
		||||
#include "elna/boot/ast.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace boot
 | 
			
		||||
namespace elna::boot
 | 
			
		||||
{
 | 
			
		||||
    void empty_visitor::visit(variable_declaration *)
 | 
			
		||||
    {
 | 
			
		||||
@@ -151,37 +149,37 @@ namespace boot
 | 
			
		||||
        __builtin_unreachable();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void empty_visitor::visit(number_literal<std::int32_t> *)
 | 
			
		||||
    void empty_visitor::visit(literal<std::int32_t> *)
 | 
			
		||||
    {
 | 
			
		||||
        __builtin_unreachable();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void empty_visitor::visit(number_literal<std::uint32_t> *)
 | 
			
		||||
    void empty_visitor::visit(literal<std::uint32_t> *)
 | 
			
		||||
    {
 | 
			
		||||
        __builtin_unreachable();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void empty_visitor::visit(number_literal<double> *)
 | 
			
		||||
    void empty_visitor::visit(literal<double> *)
 | 
			
		||||
    {
 | 
			
		||||
        __builtin_unreachable();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void empty_visitor::visit(number_literal<bool> *)
 | 
			
		||||
    void empty_visitor::visit(literal<bool> *)
 | 
			
		||||
    {
 | 
			
		||||
        __builtin_unreachable();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void empty_visitor::visit(number_literal<unsigned char> *)
 | 
			
		||||
    void empty_visitor::visit(literal<unsigned char> *)
 | 
			
		||||
    {
 | 
			
		||||
        __builtin_unreachable();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void empty_visitor::visit(number_literal<std::nullptr_t> *)
 | 
			
		||||
    void empty_visitor::visit(literal<std::nullptr_t> *)
 | 
			
		||||
    {
 | 
			
		||||
        __builtin_unreachable();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void empty_visitor::visit(number_literal<std::string> *)
 | 
			
		||||
    void empty_visitor::visit(literal<std::string> *)
 | 
			
		||||
    {
 | 
			
		||||
        __builtin_unreachable();
 | 
			
		||||
    }
 | 
			
		||||
@@ -305,7 +303,7 @@ namespace boot
 | 
			
		||||
        return nullptr;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    literal *expression::is_literal()
 | 
			
		||||
    literal_expression *expression::is_literal()
 | 
			
		||||
    {
 | 
			
		||||
        return nullptr;
 | 
			
		||||
    }
 | 
			
		||||
@@ -336,7 +334,7 @@ namespace boot
 | 
			
		||||
        {
 | 
			
		||||
            return node->accept(visitor);
 | 
			
		||||
        }
 | 
			
		||||
        else if (literal *node = is_literal())
 | 
			
		||||
        else if (literal_expression *node = is_literal())
 | 
			
		||||
        {
 | 
			
		||||
            return node->accept(visitor);
 | 
			
		||||
        }
 | 
			
		||||
@@ -518,7 +516,7 @@ namespace boot
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    constant_definition::constant_definition(const struct position position, const std::string& identifier,
 | 
			
		||||
            const bool exported, literal *body)
 | 
			
		||||
            const bool exported, literal_expression *body)
 | 
			
		||||
        : definition(position, identifier, exported), m_body(body)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
@@ -528,7 +526,7 @@ namespace boot
 | 
			
		||||
        visitor->visit(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    literal& constant_definition::body()
 | 
			
		||||
    literal_expression& constant_definition::body()
 | 
			
		||||
    {
 | 
			
		||||
        return *m_body;
 | 
			
		||||
    }
 | 
			
		||||
@@ -538,14 +536,19 @@ namespace boot
 | 
			
		||||
        delete m_body;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    procedure_type_expression::procedure_type_expression(const struct position position,
 | 
			
		||||
            std::shared_ptr<type_expression> return_type)
 | 
			
		||||
        : type_expression(position), return_type(return_type), no_return(false)
 | 
			
		||||
    return_declaration::return_declaration(std::shared_ptr<type_expression> type)
 | 
			
		||||
        : type(type)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    procedure_type_expression::procedure_type_expression(const struct position position, no_return_t)
 | 
			
		||||
        : type_expression(position), return_type(nullptr), no_return(true)
 | 
			
		||||
    return_declaration::return_declaration(std::monostate)
 | 
			
		||||
        : no_return(true)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    procedure_type_expression::procedure_type_expression(const struct position position,
 | 
			
		||||
            return_declaration return_type)
 | 
			
		||||
        : type_expression(position), return_type(return_type)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -554,14 +557,6 @@ namespace boot
 | 
			
		||||
        visitor->visit(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    procedure_type_expression::~procedure_type_expression()
 | 
			
		||||
    {
 | 
			
		||||
        for (auto parameter : this->parameters)
 | 
			
		||||
        {
 | 
			
		||||
            delete parameter;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    procedure_definition::procedure_definition(const struct position position, const std::string& identifier,
 | 
			
		||||
            const bool exported, std::shared_ptr<procedure_type_expression> heading, block *body)
 | 
			
		||||
        : definition(position, identifier, exported), m_heading(heading), body(body)
 | 
			
		||||
@@ -652,42 +647,42 @@ namespace boot
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    literal::literal()
 | 
			
		||||
    literal_expression::literal_expression()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    literal *literal::is_literal()
 | 
			
		||||
    literal_expression *literal_expression::is_literal()
 | 
			
		||||
    {
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void literal::accept(parser_visitor *visitor)
 | 
			
		||||
    void literal_expression::accept(parser_visitor *visitor)
 | 
			
		||||
    {
 | 
			
		||||
        if (number_literal<std::int32_t> *node = is_int())
 | 
			
		||||
        if (literal<std::int32_t> *node = is_int())
 | 
			
		||||
        {
 | 
			
		||||
            return node->accept(visitor);
 | 
			
		||||
        }
 | 
			
		||||
        else if (number_literal<std::uint32_t> *node = is_word())
 | 
			
		||||
        else if (literal<std::uint32_t> *node = is_word())
 | 
			
		||||
        {
 | 
			
		||||
            return node->accept(visitor);
 | 
			
		||||
        }
 | 
			
		||||
        else if (number_literal<double> *node = is_float())
 | 
			
		||||
        else if (literal<double> *node = is_float())
 | 
			
		||||
        {
 | 
			
		||||
            return node->accept(visitor);
 | 
			
		||||
        }
 | 
			
		||||
        else if (number_literal<bool> *node = is_bool())
 | 
			
		||||
        else if (literal<bool> *node = is_bool())
 | 
			
		||||
        {
 | 
			
		||||
            return node->accept(visitor);
 | 
			
		||||
        }
 | 
			
		||||
        else if (number_literal<unsigned char> *node = is_char())
 | 
			
		||||
        else if (literal<unsigned char> *node = is_char())
 | 
			
		||||
        {
 | 
			
		||||
            return node->accept(visitor);
 | 
			
		||||
        }
 | 
			
		||||
        else if (number_literal<std::nullptr_t> *node = is_nil())
 | 
			
		||||
        else if (literal<std::nullptr_t> *node = is_nil())
 | 
			
		||||
        {
 | 
			
		||||
            return node->accept(visitor);
 | 
			
		||||
        }
 | 
			
		||||
        else if (number_literal<std::string> *node = is_string())
 | 
			
		||||
        else if (literal<std::string> *node = is_string())
 | 
			
		||||
        {
 | 
			
		||||
            return node->accept(visitor);
 | 
			
		||||
        }
 | 
			
		||||
@@ -1212,4 +1207,3 @@ namespace boot
 | 
			
		||||
        __builtin_unreachable();
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,9 +17,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
 | 
			
		||||
#include "elna/boot/driver.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace boot
 | 
			
		||||
namespace elna::boot
 | 
			
		||||
{
 | 
			
		||||
    position make_position(const yy::location& location)
 | 
			
		||||
    {
 | 
			
		||||
@@ -79,4 +77,3 @@ namespace boot
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										111
									
								
								boot/parser.yy
									
									
									
									
									
								
							
							
						
						
									
										111
									
								
								boot/parser.yy
									
									
									
									
									
								
							@@ -87,7 +87,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
    ARROW "->" EXCLAMATION "!"
 | 
			
		||||
    AT "@" HAT "^"
 | 
			
		||||
    COLON ":" SEMICOLON ";" DOT "." COMMA ","
 | 
			
		||||
%token NOT "not"
 | 
			
		||||
%token NOT "~"
 | 
			
		||||
    CAST "cast"
 | 
			
		||||
    NIL "nil"
 | 
			
		||||
    CONST "const"
 | 
			
		||||
@@ -107,27 +107,26 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
    BEGIN_BLOCK "begin"
 | 
			
		||||
    END_BLOCK "end"
 | 
			
		||||
    DEFER "defer"
 | 
			
		||||
%token OR "or" AND "and" XOR "xor"
 | 
			
		||||
%token OR "|" AND "&" XOR "xor"
 | 
			
		||||
    EQUALS "=" NOT_EQUAL "<>" LESS_THAN "<" GREATER_THAN ">" LESS_EQUAL "<=" GREATER_EQUAL ">="
 | 
			
		||||
    SHIFT_LEFT "<<" SHIFT_RIGHT ">>"
 | 
			
		||||
    PLUS "+" MINUS "-"
 | 
			
		||||
    MULTIPLICATION "*" DIVISION "/" REMAINDER "%"
 | 
			
		||||
 | 
			
		||||
%left "or" "and" "xor"
 | 
			
		||||
%left "|" "&" "xor"
 | 
			
		||||
%left "=" "<>" "<" ">" "<=" ">="
 | 
			
		||||
%left "<<" ">>"
 | 
			
		||||
%left "+" "-"
 | 
			
		||||
%left "*" "/" "%"
 | 
			
		||||
 | 
			
		||||
%type <elna::boot::literal *> literal;
 | 
			
		||||
%type <elna::boot::literal_expression *> literal;
 | 
			
		||||
%type <elna::boot::constant_definition *> constant_definition;
 | 
			
		||||
%type <std::vector<elna::boot::constant_definition *>> constant_part constant_definitions;
 | 
			
		||||
%type <std::vector<elna::boot::variable_declaration *>> variable_declarations variable_part variable_declaration
 | 
			
		||||
    formal_parameters formal_parameter_list;
 | 
			
		||||
%type <elna::boot::variable_declaration *> formal_parameter
 | 
			
		||||
%type <std::vector<elna::boot::variable_declaration *>> variable_declarations variable_part variable_declaration;
 | 
			
		||||
%type <std::shared_ptr<elna::boot::type_expression>> type_expression;
 | 
			
		||||
%type <std::vector<std::shared_ptr<elna::boot::type_expression>>> type_expressions;
 | 
			
		||||
%type <elna::boot::traits_expression *> traits_expression;
 | 
			
		||||
%type <elna::boot::expression *> expression operand;
 | 
			
		||||
%type <elna::boot::expression *> expression operand qualident;
 | 
			
		||||
%type <elna::boot::unary_expression *> unary_expression;
 | 
			
		||||
%type <elna::boot::binary_expression *> binary_expression;
 | 
			
		||||
%type <std::vector<elna::boot::expression *>> expressions actual_parameter_list;
 | 
			
		||||
@@ -140,14 +139,15 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
%type <elna::boot::statement *> statement;
 | 
			
		||||
%type <std::vector<elna::boot::statement *>> statements;
 | 
			
		||||
%type <elna::boot::procedure_definition *> procedure_definition;
 | 
			
		||||
%type <std::shared_ptr<elna::boot::procedure_type_expression>> procedure_heading;
 | 
			
		||||
%type <std::pair<std::vector<std::string>, std::shared_ptr<elna::boot::procedure_type_expression>>> procedure_heading;
 | 
			
		||||
%type <elna::boot::return_declaration> return_declaration;
 | 
			
		||||
%type <std::vector<elna::boot::procedure_definition *>> procedure_definitions procedure_part;
 | 
			
		||||
%type <elna::boot::type_definition *> type_definition;
 | 
			
		||||
%type <std::vector<elna::boot::type_definition *>> type_definitions type_part;
 | 
			
		||||
%type <elna::boot::block *> block;
 | 
			
		||||
%type <elna::boot::field_declaration> field_declaration;
 | 
			
		||||
%type <elna::boot::field_declaration> field_declaration formal_parameter;
 | 
			
		||||
%type <std::vector<std::pair<std::string, std::shared_ptr<elna::boot::type_expression>>>>
 | 
			
		||||
    optional_fields required_fields;
 | 
			
		||||
    optional_fields required_fields formal_parameters;
 | 
			
		||||
%type <std::vector<elna::boot::conditional_statements *>> elsif_then_statements elsif_do_statements;
 | 
			
		||||
%type <elna::boot::cast_expression *> cast_expression;
 | 
			
		||||
%type <elna::boot::defer_statement *> defer_statement;
 | 
			
		||||
@@ -191,31 +191,32 @@ identifier_definitions:
 | 
			
		||||
            $$.emplace($$.cbegin(), $1);
 | 
			
		||||
        }
 | 
			
		||||
    | identifier_definition { $$.emplace_back(std::move($1)); }
 | 
			
		||||
return_declaration:
 | 
			
		||||
    /* proper procedure */ {}
 | 
			
		||||
    | "->" "!" { $$ = elna::boot::return_declaration(std::monostate{}); }
 | 
			
		||||
    | "->" type_expression { $$ = elna::boot::return_declaration($2); }
 | 
			
		||||
procedure_heading:
 | 
			
		||||
    formal_parameter_list
 | 
			
		||||
    "(" formal_parameters ")" return_declaration
 | 
			
		||||
        {
 | 
			
		||||
            $$ = std::make_shared<elna::boot::procedure_type_expression>(elna::boot::make_position(@1));
 | 
			
		||||
            std::swap($1, $$->parameters);
 | 
			
		||||
            $$.second = std::make_shared<elna::boot::procedure_type_expression>(elna::boot::make_position(@1),
 | 
			
		||||
                    std::move($4));
 | 
			
		||||
            for (auto& [name, type] : $2)
 | 
			
		||||
            {
 | 
			
		||||
                $$.first.emplace_back(std::move(name));
 | 
			
		||||
                $$.second->parameters.push_back(type);
 | 
			
		||||
            }
 | 
			
		||||
    | formal_parameter_list "->" "!"
 | 
			
		||||
        {
 | 
			
		||||
            $$ = std::make_shared<elna::boot::procedure_type_expression>(elna::boot::make_position(@1),
 | 
			
		||||
                elna::boot::no_return);
 | 
			
		||||
            std::swap($1, $$->parameters);
 | 
			
		||||
        }
 | 
			
		||||
    | formal_parameter_list "->" type_expression
 | 
			
		||||
        {
 | 
			
		||||
            $$ = std::make_shared<elna::boot::procedure_type_expression>(elna::boot::make_position(@1), $3);
 | 
			
		||||
            std::swap($1, $$->parameters);
 | 
			
		||||
        }
 | 
			
		||||
procedure_definition:
 | 
			
		||||
    "proc" identifier_definition procedure_heading ";" block
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::procedure_definition(elna::boot::make_position(@1), $2.first, $2.second, $3, $5);
 | 
			
		||||
            $$ = new elna::boot::procedure_definition(elna::boot::make_position(@1),
 | 
			
		||||
                    $2.first, $2.second, $3.second, $5);
 | 
			
		||||
            std::swap($3.first, $$->parameter_names);
 | 
			
		||||
        }
 | 
			
		||||
    | "proc" identifier_definition procedure_heading ";" "extern"
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::procedure_definition(elna::boot::make_position(@1), $2.first, $2.second, $3);
 | 
			
		||||
            $$ = new elna::boot::procedure_definition(elna::boot::make_position(@1), $2.first, $2.second, $3.second);
 | 
			
		||||
            std::swap($3.first, $$->parameter_names);
 | 
			
		||||
        }
 | 
			
		||||
procedure_definitions:
 | 
			
		||||
    procedure_definition procedure_definitions
 | 
			
		||||
@@ -293,47 +294,49 @@ defer_statement: DEFER statements "end"
 | 
			
		||||
literal:
 | 
			
		||||
    INTEGER
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::number_literal<std::int32_t>(elna::boot::make_position(@1), $1);
 | 
			
		||||
            $$ = new elna::boot::literal<std::int32_t>(elna::boot::make_position(@1), $1);
 | 
			
		||||
        }
 | 
			
		||||
    | WORD
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::number_literal<std::uint32_t>(elna::boot::make_position(@1), $1);
 | 
			
		||||
            $$ = new elna::boot::literal<std::uint32_t>(elna::boot::make_position(@1), $1);
 | 
			
		||||
        }
 | 
			
		||||
    | FLOAT
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::number_literal<double>(elna::boot::make_position(@1), $1);
 | 
			
		||||
            $$ = new elna::boot::literal<double>(elna::boot::make_position(@1), $1);
 | 
			
		||||
        }
 | 
			
		||||
    | BOOLEAN
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::number_literal<bool>(elna::boot::make_position(@1), $1);
 | 
			
		||||
            $$ = new elna::boot::literal<bool>(elna::boot::make_position(@1), $1);
 | 
			
		||||
        }
 | 
			
		||||
    | CHARACTER
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::number_literal<unsigned char>(elna::boot::make_position(@1), $1.at(0));
 | 
			
		||||
            $$ = new elna::boot::literal<unsigned char>(elna::boot::make_position(@1), $1.at(0));
 | 
			
		||||
        }
 | 
			
		||||
    | "nil"
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::number_literal<std::nullptr_t>(elna::boot::make_position(@1), nullptr);
 | 
			
		||||
            $$ = new elna::boot::literal<std::nullptr_t>(elna::boot::make_position(@1), nullptr);
 | 
			
		||||
        }
 | 
			
		||||
    | STRING
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::number_literal<std::string>(elna::boot::make_position(@1), $1);
 | 
			
		||||
            $$ = new elna::boot::literal<std::string>(elna::boot::make_position(@1), $1);
 | 
			
		||||
        }
 | 
			
		||||
traits_expression:
 | 
			
		||||
    TRAIT "(" type_expression ")"
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::traits_expression(elna::boot::make_position(@1), $1, $3);
 | 
			
		||||
        }
 | 
			
		||||
operand:
 | 
			
		||||
qualident:
 | 
			
		||||
    literal { $$ = $1; }
 | 
			
		||||
    | designator_expression { $$ = $1; }
 | 
			
		||||
    | traits_expression { $$ = $1; }
 | 
			
		||||
    | cast_expression { $$ = $1; }
 | 
			
		||||
    | call_expression { $$ = $1; }
 | 
			
		||||
    | "(" expression ")" { $$ = $2; }
 | 
			
		||||
expression:
 | 
			
		||||
operand:
 | 
			
		||||
    unary_expression { $$ = $1; }
 | 
			
		||||
    | binary_expression { $$ = $1; }
 | 
			
		||||
    | qualident { $$ = $1; }
 | 
			
		||||
expression:
 | 
			
		||||
    binary_expression { $$ = $1; }
 | 
			
		||||
    | operand { $$ = $1; }
 | 
			
		||||
binary_expression:
 | 
			
		||||
    expression "*" expression
 | 
			
		||||
@@ -391,12 +394,12 @@ binary_expression:
 | 
			
		||||
            $$ = new elna::boot::binary_expression(elna::boot::make_position(@2), $1, $3,
 | 
			
		||||
                elna::boot::binary_operator::greater_equal);
 | 
			
		||||
        }
 | 
			
		||||
    | expression "and" expression
 | 
			
		||||
    | expression "&" expression
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::binary_expression(elna::boot::make_position(@2), $1, $3,
 | 
			
		||||
                elna::boot::binary_operator::conjunction);
 | 
			
		||||
        }
 | 
			
		||||
    | expression "or" expression
 | 
			
		||||
    | expression "|" expression
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::binary_expression(elna::boot::make_position(@2), $1, $3,
 | 
			
		||||
                elna::boot::binary_operator::disjunction);
 | 
			
		||||
@@ -422,7 +425,7 @@ unary_expression:
 | 
			
		||||
            $$ = new elna::boot::unary_expression(elna::boot::make_position(@1), $2,
 | 
			
		||||
                elna::boot::unary_operator::reference);
 | 
			
		||||
        }
 | 
			
		||||
    | "not" operand
 | 
			
		||||
    | "~" operand
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::unary_expression(elna::boot::make_position(@1), $2,
 | 
			
		||||
                elna::boot::unary_operator::negation);
 | 
			
		||||
@@ -438,17 +441,24 @@ expressions:
 | 
			
		||||
            std::swap($$, $3);
 | 
			
		||||
            $$.emplace($$.cbegin(), $1);
 | 
			
		||||
        }
 | 
			
		||||
    | expression { $$.emplace_back(std::move($1)); }
 | 
			
		||||
    | expression { $$.push_back($1); }
 | 
			
		||||
type_expressions:
 | 
			
		||||
    type_expression "," type_expressions
 | 
			
		||||
        {
 | 
			
		||||
            std::swap($$, $3);
 | 
			
		||||
            $$.emplace($$.cbegin(), $1);
 | 
			
		||||
        }
 | 
			
		||||
    | type_expression { $$.push_back($1); }
 | 
			
		||||
designator_expression:
 | 
			
		||||
    operand "[" expression "]"
 | 
			
		||||
    qualident "[" expression "]"
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::array_access_expression(elna::boot::make_position(@2), $1, $3);
 | 
			
		||||
        }
 | 
			
		||||
    | operand "." IDENTIFIER
 | 
			
		||||
    | qualident "." IDENTIFIER
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::field_access_expression(elna::boot::make_position(@2), $1, $3);
 | 
			
		||||
        }
 | 
			
		||||
    | operand "^"
 | 
			
		||||
    | qualident "^"
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::dereference_expression(elna::boot::make_position(@1), $1);
 | 
			
		||||
        }
 | 
			
		||||
@@ -500,9 +510,12 @@ type_expression:
 | 
			
		||||
        {
 | 
			
		||||
            $$ = std::make_shared<elna::boot::union_type_expression>(elna::boot::make_position(@1), std::move($2));
 | 
			
		||||
        }
 | 
			
		||||
    | "proc" procedure_heading
 | 
			
		||||
    | "proc" "(" type_expressions ")" return_declaration
 | 
			
		||||
        {
 | 
			
		||||
            $$ = $2;
 | 
			
		||||
            auto result = std::make_shared<elna::boot::procedure_type_expression>(elna::boot::make_position(@1),
 | 
			
		||||
                    std::move($5));
 | 
			
		||||
            std::swap(result->parameters, $3);
 | 
			
		||||
            $$ = result;
 | 
			
		||||
        }
 | 
			
		||||
    | IDENTIFIER
 | 
			
		||||
        {
 | 
			
		||||
@@ -559,18 +572,16 @@ type_part:
 | 
			
		||||
    | "type" type_definitions { std::swap($$, $2); }
 | 
			
		||||
formal_parameter: IDENTIFIER ":" type_expression
 | 
			
		||||
        {
 | 
			
		||||
            $$ = new elna::boot::variable_declaration(elna::boot::make_position(@2), $1, $3);
 | 
			
		||||
            $$ = std::make_pair($1, $3);
 | 
			
		||||
        }
 | 
			
		||||
formal_parameters:
 | 
			
		||||
    formal_parameter "," formal_parameters
 | 
			
		||||
    /* no formal parameters */ {}
 | 
			
		||||
    | formal_parameter "," formal_parameters
 | 
			
		||||
        {
 | 
			
		||||
            std::swap($$, $3);
 | 
			
		||||
            $$.emplace($$.cbegin(), $1);
 | 
			
		||||
        }
 | 
			
		||||
    | formal_parameter { $$.emplace_back(std::move($1)); }
 | 
			
		||||
formal_parameter_list:
 | 
			
		||||
    "(" ")" {}
 | 
			
		||||
    | "(" formal_parameters ")" { std::swap($$, $2); }
 | 
			
		||||
actual_parameter_list:
 | 
			
		||||
    "(" ")" {}
 | 
			
		||||
    | "(" expressions ")" { std::swap($$, $2); }
 | 
			
		||||
 
 | 
			
		||||
@@ -17,9 +17,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
 | 
			
		||||
#include "elna/boot/result.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace boot
 | 
			
		||||
namespace elna::boot
 | 
			
		||||
{
 | 
			
		||||
    error::error(const char *path, const struct position position)
 | 
			
		||||
        : position(position), path(path)
 | 
			
		||||
@@ -46,4 +44,3 @@ namespace boot
 | 
			
		||||
        return m_errors;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,9 +17,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
 | 
			
		||||
#include "elna/boot/semantic.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace boot
 | 
			
		||||
namespace elna::boot
 | 
			
		||||
{
 | 
			
		||||
    undeclared_error::undeclared_error(const std::string& identifier, const char *path, const struct position position)
 | 
			
		||||
        : error(path, position), identifier(identifier)
 | 
			
		||||
@@ -122,4 +120,3 @@ namespace boot
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,9 +17,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
 | 
			
		||||
#include "elna/boot/symbol.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace boot
 | 
			
		||||
namespace elna::boot
 | 
			
		||||
{
 | 
			
		||||
    type::type()
 | 
			
		||||
    {
 | 
			
		||||
@@ -301,4 +299,3 @@ namespace boot
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -21,9 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
#include "stringpool.h"
 | 
			
		||||
#include "elna/gcc/elna-tree.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace gcc
 | 
			
		||||
namespace elna::gcc
 | 
			
		||||
{
 | 
			
		||||
    void init_ttree()
 | 
			
		||||
    {
 | 
			
		||||
@@ -66,4 +64,3 @@ namespace gcc
 | 
			
		||||
        return symbol_table;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -19,9 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
#include "elna/gcc/elna-tree.h"
 | 
			
		||||
#include "elna/gcc/elna1.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace gcc
 | 
			
		||||
namespace elna::gcc
 | 
			
		||||
{
 | 
			
		||||
    location_t get_location(const boot::position *position)
 | 
			
		||||
    {
 | 
			
		||||
@@ -144,4 +142,3 @@ namespace gcc
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -34,9 +34,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
#include "fold-const.h"
 | 
			
		||||
#include "langhooks.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace gcc
 | 
			
		||||
namespace elna::gcc
 | 
			
		||||
{
 | 
			
		||||
    tree get_inner_alias(const boot::type& type, std::shared_ptr<symbol_table> symbols)
 | 
			
		||||
    {
 | 
			
		||||
@@ -317,7 +315,7 @@ namespace gcc
 | 
			
		||||
        tree fndecl = build_fn_decl(definition->identifier.c_str(), declaration_type);
 | 
			
		||||
        this->symbols->enter(definition->identifier, fndecl);
 | 
			
		||||
 | 
			
		||||
        if (definition->heading().no_return)
 | 
			
		||||
        if (definition->heading().return_type.no_return)
 | 
			
		||||
        {
 | 
			
		||||
            TREE_THIS_VOLATILE(fndecl) = 1;
 | 
			
		||||
        }
 | 
			
		||||
@@ -336,19 +334,22 @@ namespace gcc
 | 
			
		||||
        function_args_iterator parameter_type;
 | 
			
		||||
        function_args_iter_init(¶meter_type, declaration_type);
 | 
			
		||||
 | 
			
		||||
        for (const boot::variable_declaration *parameter : definition->heading().parameters)
 | 
			
		||||
        std::vector<std::string>::const_iterator parameter_name = definition->parameter_names.cbegin();
 | 
			
		||||
 | 
			
		||||
        for (std::shared_ptr<boot::type_expression> parameter : definition->heading().parameters)
 | 
			
		||||
        {
 | 
			
		||||
            tree declaration_tree = build_decl(get_location(¶meter->position()), PARM_DECL,
 | 
			
		||||
                get_identifier(parameter->identifier.c_str()), function_args_iter_cond(¶meter_type));
 | 
			
		||||
                get_identifier(parameter_name->c_str()), function_args_iter_cond(¶meter_type));
 | 
			
		||||
            DECL_CONTEXT(declaration_tree) = fndecl;
 | 
			
		||||
            DECL_ARG_TYPE(declaration_tree) = function_args_iter_cond(¶meter_type);
 | 
			
		||||
 | 
			
		||||
            if (definition->body != nullptr)
 | 
			
		||||
            {
 | 
			
		||||
                this->symbols->enter(parameter->identifier, declaration_tree);
 | 
			
		||||
                this->symbols->enter(*parameter_name, declaration_tree);
 | 
			
		||||
            }
 | 
			
		||||
            argument_chain = chainon(argument_chain, declaration_tree);
 | 
			
		||||
            function_args_iter_next(¶meter_type);
 | 
			
		||||
            ++parameter_name;
 | 
			
		||||
        }
 | 
			
		||||
        DECL_ARGUMENTS(fndecl) = argument_chain;
 | 
			
		||||
        TREE_PUBLIC(fndecl) = definition->exported;
 | 
			
		||||
@@ -409,17 +410,17 @@ namespace gcc
 | 
			
		||||
        return bind_expr;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void generic_visitor::visit(boot::number_literal<std::int32_t> *literal)
 | 
			
		||||
    void generic_visitor::visit(boot::literal<std::int32_t> *literal)
 | 
			
		||||
    {
 | 
			
		||||
        this->current_expression = build_int_cst(elna_int_type_node, literal->value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void generic_visitor::visit(boot::number_literal<std::uint32_t> *literal)
 | 
			
		||||
    void generic_visitor::visit(boot::literal<std::uint32_t> *literal)
 | 
			
		||||
    {
 | 
			
		||||
        this->current_expression = build_int_cstu(elna_word_type_node, literal->value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void generic_visitor::visit(boot::number_literal<double> *literal)
 | 
			
		||||
    void generic_visitor::visit(boot::literal<double> *literal)
 | 
			
		||||
    {
 | 
			
		||||
        REAL_VALUE_TYPE real_value1;
 | 
			
		||||
 | 
			
		||||
@@ -434,22 +435,22 @@ namespace gcc
 | 
			
		||||
        mpfr_clear(number);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void generic_visitor::visit(boot::number_literal<bool> *boolean)
 | 
			
		||||
    void generic_visitor::visit(boot::literal<bool> *boolean)
 | 
			
		||||
    {
 | 
			
		||||
        this->current_expression = boolean->value ? boolean_true_node : boolean_false_node;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void generic_visitor::visit(boot::number_literal<unsigned char> *character)
 | 
			
		||||
    void generic_visitor::visit(boot::literal<unsigned char> *character)
 | 
			
		||||
    {
 | 
			
		||||
        this->current_expression = build_int_cstu(elna_char_type_node, character->value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void generic_visitor::visit(boot::number_literal<nullptr_t> *)
 | 
			
		||||
    void generic_visitor::visit(boot::literal<nullptr_t> *)
 | 
			
		||||
    {
 | 
			
		||||
        this->current_expression = elna_pointer_nil_node;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void generic_visitor::visit(boot::number_literal<std::string> *string)
 | 
			
		||||
    void generic_visitor::visit(boot::literal<std::string> *string)
 | 
			
		||||
    {
 | 
			
		||||
        tree index_constant = build_int_cstu(elna_word_type_node, string->value.size());
 | 
			
		||||
        tree string_type = build_array_type(elna_char_type_node, build_index_type(index_constant));
 | 
			
		||||
@@ -779,15 +780,14 @@ namespace gcc
 | 
			
		||||
 | 
			
		||||
        for (std::size_t i = 0; i < type.parameters.size(); ++i)
 | 
			
		||||
        {
 | 
			
		||||
            boot::type_expression& parameter_type = type.parameters.at(i)->variable_type();
 | 
			
		||||
            parameter_type.accept(this);
 | 
			
		||||
            type.parameters.at(i)->accept(this);
 | 
			
		||||
            parameter_types[i] = this->current_expression;
 | 
			
		||||
        }
 | 
			
		||||
        tree return_type = void_type_node;
 | 
			
		||||
 | 
			
		||||
        if (type.return_type != nullptr)
 | 
			
		||||
        if (type.return_type.type != nullptr)
 | 
			
		||||
        {
 | 
			
		||||
            type.return_type->accept(this);
 | 
			
		||||
            type.return_type.type->accept(this);
 | 
			
		||||
            return_type = this->current_expression;
 | 
			
		||||
        }
 | 
			
		||||
        this->current_expression = NULL_TREE;
 | 
			
		||||
@@ -1226,4 +1226,3 @@ namespace gcc
 | 
			
		||||
        defer(leave_scope());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,9 +24,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
#include "fold-const.h"
 | 
			
		||||
#include "diagnostic-core.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace gcc
 | 
			
		||||
namespace elna::gcc
 | 
			
		||||
{
 | 
			
		||||
    bool is_pointer_type(tree type)
 | 
			
		||||
    {
 | 
			
		||||
@@ -210,4 +208,3 @@ namespace gcc
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -21,11 +21,10 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include <variant>
 | 
			
		||||
#include "elna/boot/result.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace boot
 | 
			
		||||
namespace elna::boot
 | 
			
		||||
{
 | 
			
		||||
    enum class binary_operator
 | 
			
		||||
    {
 | 
			
		||||
@@ -80,9 +79,9 @@ namespace boot
 | 
			
		||||
    class field_access_expression;
 | 
			
		||||
    class dereference_expression;
 | 
			
		||||
    class designator_expression;
 | 
			
		||||
    class literal;
 | 
			
		||||
    class literal_expression;
 | 
			
		||||
    template<typename T>
 | 
			
		||||
    class number_literal;
 | 
			
		||||
    class literal;
 | 
			
		||||
    class defer_statement;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -116,13 +115,13 @@ namespace boot
 | 
			
		||||
        virtual void visit(array_access_expression *) = 0;
 | 
			
		||||
        virtual void visit(field_access_expression *) = 0;
 | 
			
		||||
        virtual void visit(dereference_expression *) = 0;
 | 
			
		||||
        virtual void visit(number_literal<std::int32_t> *) = 0;
 | 
			
		||||
        virtual void visit(number_literal<std::uint32_t> *) = 0;
 | 
			
		||||
        virtual void visit(number_literal<double> *) = 0;
 | 
			
		||||
        virtual void visit(number_literal<bool> *) = 0;
 | 
			
		||||
        virtual void visit(number_literal<unsigned char> *) = 0;
 | 
			
		||||
        virtual void visit(number_literal<std::nullptr_t> *) = 0;
 | 
			
		||||
        virtual void visit(number_literal<std::string> *) = 0;
 | 
			
		||||
        virtual void visit(literal<std::int32_t> *) = 0;
 | 
			
		||||
        virtual void visit(literal<std::uint32_t> *) = 0;
 | 
			
		||||
        virtual void visit(literal<double> *) = 0;
 | 
			
		||||
        virtual void visit(literal<bool> *) = 0;
 | 
			
		||||
        virtual void visit(literal<unsigned char> *) = 0;
 | 
			
		||||
        virtual void visit(literal<std::nullptr_t> *) = 0;
 | 
			
		||||
        virtual void visit(literal<std::string> *) = 0;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -156,13 +155,13 @@ namespace boot
 | 
			
		||||
        virtual void visit(array_access_expression *) override;
 | 
			
		||||
        virtual void visit(field_access_expression *) override;
 | 
			
		||||
        virtual void visit(dereference_expression *) override;
 | 
			
		||||
        virtual void visit(number_literal<std::int32_t> *) override;
 | 
			
		||||
        virtual void visit(number_literal<std::uint32_t> *) override;
 | 
			
		||||
        virtual void visit(number_literal<double> *) override;
 | 
			
		||||
        virtual void visit(number_literal<bool> *) override;
 | 
			
		||||
        virtual void visit(number_literal<unsigned char> *) override;
 | 
			
		||||
        virtual void visit(number_literal<std::nullptr_t> *) override;
 | 
			
		||||
        virtual void visit(number_literal<std::string> *) override;
 | 
			
		||||
        virtual void visit(literal<std::int32_t> *) override;
 | 
			
		||||
        virtual void visit(literal<std::uint32_t> *) override;
 | 
			
		||||
        virtual void visit(literal<double> *) override;
 | 
			
		||||
        virtual void visit(literal<bool> *) override;
 | 
			
		||||
        virtual void visit(literal<unsigned char> *) override;
 | 
			
		||||
        virtual void visit(literal<std::nullptr_t> *) override;
 | 
			
		||||
        virtual void visit(literal<std::string> *) override;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -213,7 +212,7 @@ namespace boot
 | 
			
		||||
        virtual unary_expression *is_unary();
 | 
			
		||||
        virtual designator_expression *is_designator();
 | 
			
		||||
        virtual procedure_call *is_call_expression();
 | 
			
		||||
        virtual literal *is_literal();
 | 
			
		||||
        virtual literal_expression *is_literal();
 | 
			
		||||
 | 
			
		||||
        void accept(parser_visitor *visitor);
 | 
			
		||||
        ~expression() = 0;
 | 
			
		||||
@@ -336,22 +335,22 @@ namespace boot
 | 
			
		||||
    /**
 | 
			
		||||
     * Literal expression.
 | 
			
		||||
     */
 | 
			
		||||
    class literal : public expression
 | 
			
		||||
    class literal_expression : public expression
 | 
			
		||||
    {
 | 
			
		||||
    public:
 | 
			
		||||
        virtual number_literal<std::int32_t> *is_int() = 0;
 | 
			
		||||
        virtual number_literal<std::uint32_t> *is_word() = 0;
 | 
			
		||||
        virtual number_literal<double> *is_float() = 0;
 | 
			
		||||
        virtual number_literal<bool> *is_bool() = 0;
 | 
			
		||||
        virtual number_literal<unsigned char> *is_char() = 0;
 | 
			
		||||
        virtual number_literal<std::nullptr_t> *is_nil() = 0;
 | 
			
		||||
        virtual number_literal<std::string> *is_string() = 0;
 | 
			
		||||
        virtual literal<std::int32_t> *is_int() = 0;
 | 
			
		||||
        virtual literal<std::uint32_t> *is_word() = 0;
 | 
			
		||||
        virtual literal<double> *is_float() = 0;
 | 
			
		||||
        virtual literal<bool> *is_bool() = 0;
 | 
			
		||||
        virtual literal<unsigned char> *is_char() = 0;
 | 
			
		||||
        virtual literal<std::nullptr_t> *is_nil() = 0;
 | 
			
		||||
        virtual literal<std::string> *is_string() = 0;
 | 
			
		||||
 | 
			
		||||
        literal *is_literal() override;
 | 
			
		||||
        literal_expression *is_literal() override;
 | 
			
		||||
        void accept(parser_visitor *visitor);
 | 
			
		||||
 | 
			
		||||
    protected:
 | 
			
		||||
        literal();
 | 
			
		||||
        literal_expression();
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -359,7 +358,7 @@ namespace boot
 | 
			
		||||
     */
 | 
			
		||||
    class constant_definition : public definition
 | 
			
		||||
    {
 | 
			
		||||
        literal *m_body;
 | 
			
		||||
        literal_expression *m_body;
 | 
			
		||||
 | 
			
		||||
    public:
 | 
			
		||||
        /**
 | 
			
		||||
@@ -368,10 +367,10 @@ namespace boot
 | 
			
		||||
         * \param body Constant value.
 | 
			
		||||
         */
 | 
			
		||||
        constant_definition(const struct position position, const std::string& identifier,
 | 
			
		||||
                const bool exported, literal *body);
 | 
			
		||||
                const bool exported, literal_expression *body);
 | 
			
		||||
        void accept(parser_visitor *visitor);
 | 
			
		||||
 | 
			
		||||
        literal& body();
 | 
			
		||||
        literal_expression& body();
 | 
			
		||||
 | 
			
		||||
        virtual ~constant_definition() override;
 | 
			
		||||
    };
 | 
			
		||||
@@ -379,10 +378,15 @@ namespace boot
 | 
			
		||||
    /**
 | 
			
		||||
     * Tags a procedure type as never returning.
 | 
			
		||||
     */
 | 
			
		||||
    struct no_return_t
 | 
			
		||||
    struct return_declaration
 | 
			
		||||
    {
 | 
			
		||||
        return_declaration() = default;
 | 
			
		||||
        explicit return_declaration(std::shared_ptr<type_expression> type);
 | 
			
		||||
        explicit return_declaration(std::monostate);
 | 
			
		||||
 | 
			
		||||
        std::shared_ptr<type_expression> type{ nullptr };
 | 
			
		||||
        bool no_return{ false };
 | 
			
		||||
    };
 | 
			
		||||
    constexpr no_return_t no_return{};
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Procedure type.
 | 
			
		||||
@@ -390,18 +394,14 @@ namespace boot
 | 
			
		||||
    class procedure_type_expression : public type_expression
 | 
			
		||||
    {
 | 
			
		||||
    public:
 | 
			
		||||
        const std::shared_ptr<type_expression> return_type;
 | 
			
		||||
        const bool no_return;
 | 
			
		||||
        std::vector<variable_declaration *> parameters;
 | 
			
		||||
        const return_declaration return_type;
 | 
			
		||||
        std::vector<std::shared_ptr<type_expression>> parameters;
 | 
			
		||||
 | 
			
		||||
        procedure_type_expression(const struct position position,
 | 
			
		||||
                std::shared_ptr<type_expression> return_type = nullptr);
 | 
			
		||||
        procedure_type_expression(const struct position position, no_return_t);
 | 
			
		||||
                return_declaration return_type = return_declaration());
 | 
			
		||||
 | 
			
		||||
        void accept(parser_visitor *visitor);
 | 
			
		||||
        std::shared_ptr<procedure_type_expression> is_procedure() override;
 | 
			
		||||
 | 
			
		||||
        virtual ~procedure_type_expression() override;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -413,6 +413,7 @@ namespace boot
 | 
			
		||||
 | 
			
		||||
    public:
 | 
			
		||||
        block *const body;
 | 
			
		||||
        std::vector<std::string> parameter_names;
 | 
			
		||||
 | 
			
		||||
        procedure_definition(const struct position position, const std::string& identifier,
 | 
			
		||||
                const bool exported, std::shared_ptr<procedure_type_expression> heading, block *body = nullptr);
 | 
			
		||||
@@ -688,21 +689,21 @@ namespace boot
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    template<typename T>
 | 
			
		||||
    class number_literal : public literal
 | 
			
		||||
    class literal : public literal_expression
 | 
			
		||||
    {
 | 
			
		||||
    public:
 | 
			
		||||
        T value;
 | 
			
		||||
 | 
			
		||||
        number_literal(const struct position position, const T& value)
 | 
			
		||||
        literal(const struct position position, const T& value)
 | 
			
		||||
            : node(position), value(value)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        number_literal<std::int32_t> *is_int() override
 | 
			
		||||
        literal<std::int32_t> *is_int() override
 | 
			
		||||
        {
 | 
			
		||||
            if (std::is_same<T, std::int32_t>::value)
 | 
			
		||||
            {
 | 
			
		||||
                return reinterpret_cast<number_literal<std::int32_t> *>(this);
 | 
			
		||||
                return reinterpret_cast<literal<std::int32_t> *>(this);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
@@ -710,11 +711,11 @@ namespace boot
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        number_literal<std::uint32_t> *is_word() override
 | 
			
		||||
        literal<std::uint32_t> *is_word() override
 | 
			
		||||
        {
 | 
			
		||||
            if (std::is_same<T, std::uint32_t>::value)
 | 
			
		||||
            {
 | 
			
		||||
                return reinterpret_cast<number_literal<std::uint32_t> *>(this);
 | 
			
		||||
                return reinterpret_cast<literal<std::uint32_t> *>(this);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
@@ -722,11 +723,11 @@ namespace boot
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        number_literal<double> *is_float() override
 | 
			
		||||
        literal<double> *is_float() override
 | 
			
		||||
        {
 | 
			
		||||
            if (std::is_same<T, double>::value)
 | 
			
		||||
            {
 | 
			
		||||
                return reinterpret_cast<number_literal<double> *>(this);
 | 
			
		||||
                return reinterpret_cast<literal<double> *>(this);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
@@ -734,11 +735,11 @@ namespace boot
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        number_literal<bool> *is_bool() override
 | 
			
		||||
        literal<bool> *is_bool() override
 | 
			
		||||
        {
 | 
			
		||||
            if (std::is_same<T, bool>::value)
 | 
			
		||||
            {
 | 
			
		||||
                return reinterpret_cast<number_literal<bool> *>(this);
 | 
			
		||||
                return reinterpret_cast<literal<bool> *>(this);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
@@ -746,11 +747,11 @@ namespace boot
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        number_literal<unsigned char> *is_char() override
 | 
			
		||||
        literal<unsigned char> *is_char() override
 | 
			
		||||
        {
 | 
			
		||||
            if (std::is_same<T, unsigned char>::value)
 | 
			
		||||
            {
 | 
			
		||||
                return reinterpret_cast<number_literal<unsigned char> *>(this);
 | 
			
		||||
                return reinterpret_cast<literal<unsigned char> *>(this);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
@@ -758,11 +759,11 @@ namespace boot
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        number_literal<std::nullptr_t> *is_nil() override
 | 
			
		||||
        literal<std::nullptr_t> *is_nil() override
 | 
			
		||||
        {
 | 
			
		||||
            if (std::is_same<T, std::nullptr_t>::value)
 | 
			
		||||
            {
 | 
			
		||||
                return reinterpret_cast<number_literal<std::nullptr_t> *>(this);
 | 
			
		||||
                return reinterpret_cast<literal<std::nullptr_t> *>(this);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
@@ -770,11 +771,11 @@ namespace boot
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        number_literal<std::string> *is_string() override
 | 
			
		||||
        literal<std::string> *is_string() override
 | 
			
		||||
        {
 | 
			
		||||
            if (std::is_same<T, std::string>::value)
 | 
			
		||||
            {
 | 
			
		||||
                return reinterpret_cast<number_literal<std::string> *>(this);
 | 
			
		||||
                return reinterpret_cast<literal<std::string> *>(this);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
@@ -840,4 +841,3 @@ namespace boot
 | 
			
		||||
 | 
			
		||||
    const char *print_binary_operator(const binary_operator operation);
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -21,9 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
#include "elna/boot/ast.h"
 | 
			
		||||
#include "location.hh"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace boot
 | 
			
		||||
namespace elna::boot
 | 
			
		||||
{
 | 
			
		||||
    position make_position(const yy::location& location);
 | 
			
		||||
 | 
			
		||||
@@ -50,4 +48,3 @@ namespace boot
 | 
			
		||||
 | 
			
		||||
    char escape_char(char escape);
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -22,9 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
#include <deque>
 | 
			
		||||
#include <memory>
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace boot
 | 
			
		||||
namespace elna::boot
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Position in the source text.
 | 
			
		||||
@@ -82,4 +80,3 @@ namespace boot
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,9 +24,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
#include "elna/boot/result.h"
 | 
			
		||||
#include "elna/boot/symbol.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace boot
 | 
			
		||||
namespace elna::boot
 | 
			
		||||
{
 | 
			
		||||
    class undeclared_error : public error
 | 
			
		||||
    {
 | 
			
		||||
@@ -68,4 +66,3 @@ namespace boot
 | 
			
		||||
        void visit(procedure_type_expression *) override;
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -23,9 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace boot
 | 
			
		||||
namespace elna::boot
 | 
			
		||||
{
 | 
			
		||||
    class alias_type;
 | 
			
		||||
    class primitive_type;
 | 
			
		||||
@@ -257,4 +255,3 @@ namespace boot
 | 
			
		||||
 | 
			
		||||
    std::shared_ptr<symbol_table> builtin_symbol_table();
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -25,11 +25,8 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
 | 
			
		||||
#include "elna/gcc/elna-tree.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace gcc
 | 
			
		||||
namespace elna::gcc
 | 
			
		||||
{
 | 
			
		||||
    void init_ttree();
 | 
			
		||||
    std::shared_ptr<symbol_table> builtin_symbol_table();
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -29,12 +29,9 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
 | 
			
		||||
#include "elna/boot/result.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace gcc
 | 
			
		||||
namespace elna::gcc
 | 
			
		||||
{
 | 
			
		||||
    location_t get_location(const boot::position *position);
 | 
			
		||||
    std::string print_type(tree type);
 | 
			
		||||
    void report_errors(const std::deque<std::unique_ptr<boot::error>>& errors);
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,9 +30,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace gcc
 | 
			
		||||
namespace elna::gcc
 | 
			
		||||
{
 | 
			
		||||
    std::deque<std::unique_ptr<boot::error>> do_semantic_analysis(const char *path,
 | 
			
		||||
            std::unique_ptr<boot::program>& ast, std::shared_ptr<boot::symbol_table> info_table,
 | 
			
		||||
@@ -74,13 +72,13 @@ namespace gcc
 | 
			
		||||
        void visit(boot::procedure_call *call) override;
 | 
			
		||||
        void visit(boot::cast_expression *expression) override;
 | 
			
		||||
        void visit(boot::traits_expression *trait) override;
 | 
			
		||||
        void visit(boot::number_literal<std::int32_t> *literal) override;
 | 
			
		||||
        void visit(boot::number_literal<std::uint32_t> *literal) override;
 | 
			
		||||
        void visit(boot::number_literal<double> *literal) override;
 | 
			
		||||
        void visit(boot::number_literal<bool> *boolean) override;
 | 
			
		||||
        void visit(boot::number_literal<unsigned char> *character) override;
 | 
			
		||||
        void visit(boot::number_literal<std::nullptr_t> *) override;
 | 
			
		||||
        void visit(boot::number_literal<std::string> *string) override;
 | 
			
		||||
        void visit(boot::literal<std::int32_t> *literal) override;
 | 
			
		||||
        void visit(boot::literal<std::uint32_t> *literal) override;
 | 
			
		||||
        void visit(boot::literal<double> *literal) override;
 | 
			
		||||
        void visit(boot::literal<bool> *boolean) override;
 | 
			
		||||
        void visit(boot::literal<unsigned char> *character) override;
 | 
			
		||||
        void visit(boot::literal<std::nullptr_t> *) override;
 | 
			
		||||
        void visit(boot::literal<std::string> *string) override;
 | 
			
		||||
        void visit(boot::binary_expression *expression) override;
 | 
			
		||||
        void visit(boot::unary_expression *expression) override;
 | 
			
		||||
        void visit(boot::constant_definition *definition) override;
 | 
			
		||||
@@ -104,4 +102,3 @@ namespace gcc
 | 
			
		||||
        void visit(boot::defer_statement *statement) override;
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -29,9 +29,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
			
		||||
#include "elna/boot/ast.h"
 | 
			
		||||
#include "elna/boot/symbol.h"
 | 
			
		||||
 | 
			
		||||
namespace elna
 | 
			
		||||
{
 | 
			
		||||
namespace gcc
 | 
			
		||||
namespace elna::gcc
 | 
			
		||||
{
 | 
			
		||||
    using symbol_table = boot::symbol_map<tree, tree, NULL_TREE>;
 | 
			
		||||
 | 
			
		||||
@@ -82,4 +80,3 @@ namespace gcc
 | 
			
		||||
            tree_code operator_code, tree left, tree right);
 | 
			
		||||
    tree build_field(location_t location, tree record_type, const std::string name, tree type);
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -88,9 +88,9 @@ type
 | 
			
		||||
    position: Position
 | 
			
		||||
 | 
			
		||||
	input: ^Byte
 | 
			
		||||
	empty: proc(data: ^Byte) -> Bool
 | 
			
		||||
	advance: proc(data: ^Byte)
 | 
			
		||||
	head: proc(data: ^Byte) -> Char
 | 
			
		||||
	empty: proc(^Byte) -> Bool
 | 
			
		||||
	advance: proc(^Byte)
 | 
			
		||||
	head: proc(^Byte) -> Char
 | 
			
		||||
  end
 | 
			
		||||
  Token* = record
 | 
			
		||||
    kind: Int
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user