Implement parameterless prcoedures
This commit is contained in:
@@ -80,8 +80,8 @@
|
||||
%type <elna::source::string_literal *> string_literal;
|
||||
%type <elna::source::constant_definition *> constant_definition;
|
||||
%type <std::vector<elna::source::constant_definition *>> constant_part constant_definitions;
|
||||
%type <elna::source::declaration *> variable_declaration;
|
||||
%type <std::vector<elna::source::declaration *>> variable_declarations variable_part
|
||||
%type <elna::source::variable_declaration *> variable_declaration;
|
||||
%type <std::vector<elna::source::variable_declaration *>> variable_declarations variable_part
|
||||
formal_parameter_list;
|
||||
%type <elna::source::type_expression *> type_expression;
|
||||
%type <elna::source::expression *> expression pointer summand factor comparand;
|
||||
@@ -105,35 +105,45 @@
|
||||
program:
|
||||
type_part constant_part procedure_part variable_part compound_statement DOT
|
||||
{
|
||||
std::vector<elna::source::definition *> definitions($1.size() + $2.size() + $3.size());
|
||||
std::vector<elna::source::definition *> definitions($1.size() + $3.size());
|
||||
std::vector<elna::source::definition *>::iterator definition = definitions.begin();
|
||||
std::vector<elna::source::definition *> value_definitions($2.size() + $4.size());
|
||||
std::vector<elna::source::definition *>::iterator value_definition = value_definitions.begin();
|
||||
|
||||
for (auto& type : $1)
|
||||
for (auto type : $1)
|
||||
{
|
||||
*definition++ = type;
|
||||
}
|
||||
for (auto& constant : $2)
|
||||
for (auto constant : $2)
|
||||
{
|
||||
*definition++ = constant;
|
||||
*value_definition++ = constant;
|
||||
}
|
||||
for (auto& procedure : $3)
|
||||
for (auto procedure : $3)
|
||||
{
|
||||
*definition++ = procedure;
|
||||
}
|
||||
for (auto variable : $4)
|
||||
{
|
||||
*value_definition++ = variable;
|
||||
}
|
||||
driver.tree = std::make_unique<elna::source::program>(elna::source::position{},
|
||||
std::move(definitions), std::move($4), std::move($5));
|
||||
std::move(definitions), std::move(value_definitions), std::move($5));
|
||||
}
|
||||
block: constant_part variable_part statement
|
||||
{
|
||||
std::vector<elna::source::definition *> definitions($1.size());
|
||||
std::vector<elna::source::definition *> definitions($1.size() + $2.size());
|
||||
std::vector<elna::source::definition *>::iterator definition = definitions.begin();
|
||||
|
||||
for (auto& constant : $1)
|
||||
for (auto constant : $1)
|
||||
{
|
||||
*definition++ = constant;
|
||||
}
|
||||
for (auto variable : $2)
|
||||
{
|
||||
*definition++ = variable;
|
||||
}
|
||||
$$ = new elna::source::block(elna::source::position{},
|
||||
std::move(definitions), std::move($2), std::move($3));
|
||||
{}, std::move(definitions), std::move($3));
|
||||
};
|
||||
procedure_definition:
|
||||
PROCEDURE IDENTIFIER formal_parameter_list SEMICOLON block SEMICOLON
|
||||
@@ -335,7 +345,7 @@ type_expression:
|
||||
}
|
||||
variable_declaration: IDENTIFIER COLON type_expression
|
||||
{
|
||||
$$ = new elna::source::declaration(elna::source::make_position(@1), $1, $3);
|
||||
$$ = new elna::source::variable_declaration(elna::source::make_position(@1), $1, $3);
|
||||
};
|
||||
variable_declarations:
|
||||
variable_declaration COMMA variable_declarations
|
||||
|
||||
Reference in New Issue
Block a user