From ceaa60d2f4f6c571230ee9a9af9df27a8411ea72 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sun, 13 May 2012 17:05:09 -0700 Subject: [PATCH] Parse (to "sorry") arrays of named types. --- parse.y | 6 ++++-- pform.cc | 5 +++++ pform_types.h | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/parse.y b/parse.y index 1c88baa17c..40fb6375b0 100644 --- a/parse.y +++ b/parse.y @@ -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; diff --git a/pform.cc b/pform.cc index 30c2fae81c..b4f8f55350 100644 --- a/pform.cc +++ b/pform.cc @@ -2770,6 +2770,11 @@ void pform_set_data_type(const struct vlltype&li, data_type_t*data_type, list (data_type)) { + VLerror(li, "sorry: General array types not supported."); + return; + } + assert(0); } diff --git a/pform_types.h b/pform_types.h index d896315012..cfd56e5c3c 100644 --- a/pform_types.h +++ b/pform_types.h @@ -139,6 +139,17 @@ struct vector_type_t : public data_type_t { std::auto_ptr< list > 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*pd) + : base_type(btype), packed_dims(pd) { } + data_type_t*base_type; + std::auto_ptr< list > 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) { }