Skip to content

Commit

Permalink
Parse (to "sorry") arrays of named types.
Browse files Browse the repository at this point in the history
  • Loading branch information
steveicarus committed May 23, 2012
1 parent 621c091 commit ceaa60d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,10 @@ data_type /* IEEE1800-2005: A.2.2.1 */
FILE_NAME(tmp, @1);
$$ = tmp;
}
| TYPE_IDENTIFIER
{ $$ = $1; }
| TYPE_IDENTIFIER range_opt
{ if ($2) $$ = new array_type_t($1, $2);
else $$ = $1;
}
| K_string
{ yyerror(@1, "sorry: String data type not supported.");
$$ = 0;
Expand Down
5 changes: 5 additions & 0 deletions pform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2770,6 +2770,11 @@ void pform_set_data_type(const struct vlltype&li, data_type_t*data_type, list<pe
return;
}

if (/*array_type_t*array_type = */ dynamic_cast<array_type_t*> (data_type)) {
VLerror(li, "sorry: General array types not supported.");
return;
}

assert(0);
}

Expand Down
11 changes: 11 additions & 0 deletions pform_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ struct vector_type_t : public data_type_t {
std::auto_ptr< list<pform_range_t> > pdims;
};

/*
* The array_type_t is a generalization of the vector_type_t in that
* the base type is another general data type.
*/
struct array_type_t : public data_type_t {
inline explicit array_type_t(data_type_t*btype, std::list<pform_range_t>*pd)
: base_type(btype), packed_dims(pd) { }
data_type_t*base_type;
std::auto_ptr< list<pform_range_t> > packed_dims;
};

struct real_type_t : public data_type_t {
enum type_t { REAL, SHORTREAL };
inline explicit real_type_t(type_t tc) : type_code(tc) { }
Expand Down

0 comments on commit ceaa60d

Please sign in to comment.