Parse enumeration type declarations.
This commit is contained in:
parent
8003382b3e
commit
271aaf6376
|
|
@ -254,11 +254,12 @@ const VType*parse_type_by_name(perm_string name)
|
|||
%type <named_expr> association_element
|
||||
%type <named_expr_list> association_list port_map_aspect port_map_aspect_opt
|
||||
|
||||
%type <vtype> subtype_indication
|
||||
%type <vtype> subtype_indication type_definition
|
||||
|
||||
%type <text> architecture_body_start package_declaration_start
|
||||
%type <text> identifier_opt identifier_colon_opt logical_name suffix
|
||||
%type <name_list> logical_name_list identifier_list
|
||||
%type <name_list> enumeration_literal_list enumeration_literal
|
||||
%type <compound_name> prefix selected_name
|
||||
%type <compound_name_list> selected_names use_clause
|
||||
|
||||
|
|
@ -404,6 +405,8 @@ block_declarative_item
|
|||
|
||||
| constant_declaration
|
||||
|
||||
| type_declaration
|
||||
|
||||
| use_clause_lib
|
||||
|
||||
/* Various error handling rules for block_declarative_item... */
|
||||
|
|
@ -780,6 +783,31 @@ entity_header
|
|||
{ $$ = $1; }
|
||||
;
|
||||
|
||||
enumeration_literal
|
||||
: IDENTIFIER
|
||||
{ list<perm_string>*tmp = new list<perm_string>;
|
||||
tmp->push_back(lex_strings.make($1));
|
||||
delete[]$1;
|
||||
$$ = tmp;
|
||||
}
|
||||
;
|
||||
|
||||
enumeration_literal_list
|
||||
: enumeration_literal_list ',' enumeration_literal
|
||||
{ list<perm_string>*tmp = $1;
|
||||
list<perm_string>*tmp3 = $3;
|
||||
if (tmp3) {
|
||||
tmp->splice(tmp->end(), *tmp3);
|
||||
delete tmp3;
|
||||
}
|
||||
$$ = tmp;
|
||||
}
|
||||
| enumeration_literal
|
||||
{ list<perm_string>*tmp = $1;
|
||||
$$ = tmp;
|
||||
}
|
||||
;
|
||||
|
||||
expression_list
|
||||
: expression_list ',' expression
|
||||
{ list<Expression*>*tmp = $1;
|
||||
|
|
@ -1762,6 +1790,19 @@ term
|
|||
}
|
||||
;
|
||||
|
||||
type_declaration
|
||||
: K_type IDENTIFIER K_is type_definition ';'
|
||||
{ sorrymsg(@1, "type_declaration not supported.\n"); }
|
||||
;
|
||||
|
||||
type_definition
|
||||
: '(' enumeration_literal_list ')'
|
||||
{ VTypeEnum*tmp = new VTypeEnum($2);
|
||||
delete $2;
|
||||
$$ = tmp;
|
||||
}
|
||||
;
|
||||
|
||||
use_clause
|
||||
: K_use selected_names ';'
|
||||
{
|
||||
|
|
|
|||
|
|
@ -105,3 +105,18 @@ VTypeRange::VTypeRange(const VType*base, int64_t max_val, int64_t min_val)
|
|||
VTypeRange::~VTypeRange()
|
||||
{
|
||||
}
|
||||
|
||||
VTypeEnum::VTypeEnum(const std::list<perm_string>*names)
|
||||
: names_(names->size())
|
||||
{
|
||||
size_t idx = 0;
|
||||
|
||||
for (list<perm_string>::const_iterator cur = names->begin()
|
||||
; cur != names->end() ; ++cur, ++idx) {
|
||||
names_[idx] = *cur;
|
||||
}
|
||||
}
|
||||
|
||||
VTypeEnum::~VTypeEnum()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
# include <iostream>
|
||||
# include <list>
|
||||
# include <vector>
|
||||
# include <climits>
|
||||
# include <inttypes.h>
|
||||
|
|
@ -41,6 +42,9 @@ class VType {
|
|||
// writing parsed types to library files.
|
||||
virtual void write_to_stream(std::ostream&fd) const;
|
||||
|
||||
// This virtual method writes a human-readable version of the
|
||||
// type to a given file for debug purposes. (Question: is this
|
||||
// really necessary given the write_to_stream method?)
|
||||
virtual void show(std::ostream&) const;
|
||||
|
||||
public:
|
||||
|
|
@ -154,4 +158,16 @@ class VTypeRange : public VType {
|
|||
int64_t max_, min_;
|
||||
};
|
||||
|
||||
class VTypeEnum : public VType {
|
||||
|
||||
public:
|
||||
VTypeEnum(const std::list<perm_string>*names);
|
||||
~VTypeEnum();
|
||||
|
||||
virtual void elaborate(decl_t&decl) const;
|
||||
|
||||
private:
|
||||
std::vector<perm_string>names_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -63,3 +63,7 @@ void VTypeRange::elaborate(VType::decl_t&decl) const
|
|||
{
|
||||
base_->elaborate(decl);
|
||||
}
|
||||
|
||||
void VTypeEnum::elaborate(decl_t&) const
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue