Add string type
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
%token <std::int32_t> INTEGER "integer"
|
||||
%token <float> FLOAT "float"
|
||||
%token <std::string> CHARACTER "character"
|
||||
%token <std::string> STRING "string"
|
||||
%token <bool> BOOLEAN
|
||||
%token IF WHILE DO
|
||||
%token CONST VAR PROCEDURE
|
||||
@@ -76,6 +77,7 @@
|
||||
%type <std::unique_ptr<elna::source::number_literal<double>>> float_literal;
|
||||
%type <std::unique_ptr<elna::source::number_literal<bool>>> boolean_literal;
|
||||
%type <std::unique_ptr<elna::source::char_literal>> character_literal;
|
||||
%type <std::unique_ptr<elna::source::string_literal>> string_literal;
|
||||
%type <std::unique_ptr<elna::source::constant_definition>> constant_definition;
|
||||
%type <std::vector<std::unique_ptr<elna::source::constant_definition>>> constant_definition_part constant_definitions;
|
||||
%type <std::unique_ptr<elna::source::declaration>> variable_declaration;
|
||||
@@ -153,7 +155,11 @@ float_literal: FLOAT
|
||||
};
|
||||
character_literal: CHARACTER
|
||||
{
|
||||
$$ = std::make_unique<elna::source::char_literal>(elna::source::make_position(@1), $1[0]);
|
||||
$$ = std::make_unique<elna::source::char_literal>(elna::source::make_position(@1), $1.at(0));
|
||||
};
|
||||
string_literal: STRING
|
||||
{
|
||||
$$ = std::make_unique<elna::source::string_literal>(elna::source::make_position(@1), $1);
|
||||
};
|
||||
boolean_literal: BOOLEAN
|
||||
{
|
||||
@@ -194,6 +200,7 @@ pointer:
|
||||
| float_literal { $$ = std::move($1); }
|
||||
| boolean_literal { $$ = std::move($1); }
|
||||
| character_literal { $$ = std::move($1); }
|
||||
| string_literal { $$ = std::move($1); }
|
||||
| variable_expression { $$ = std::move($1); }
|
||||
| LEFT_PAREN expression RIGHT_PAREN { $$ = std::move($2); }
|
||||
summand:
|
||||
|
||||
Reference in New Issue
Block a user