Parse (to sorry messages) unbounded array definitions.
This commit is contained in:
parent
8487cb5616
commit
24bd630cb2
|
|
@ -68,6 +68,12 @@ void Package::write_to_stream(ostream&fd) const
|
||||||
|
|
||||||
for (map<perm_string,struct const_t*>::const_iterator cur = cur_constants_.begin()
|
for (map<perm_string,struct const_t*>::const_iterator cur = cur_constants_.begin()
|
||||||
; cur != cur_constants_.end() ; ++ cur) {
|
; cur != cur_constants_.end() ; ++ cur) {
|
||||||
|
if (cur->second==0 || cur->second->typ==0) {
|
||||||
|
fd << "-- const " << cur->first
|
||||||
|
<< " has errors." << endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
fd << "constant " << cur->first << ": ";
|
fd << "constant " << cur->first << ": ";
|
||||||
cur->second->typ->write_to_stream(fd);
|
cur->second->typ->write_to_stream(fd);
|
||||||
fd << " := ";
|
fd << " := ";
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
%parse-param {perm_string parse_library_name}
|
%parse-param {perm_string parse_library_name}
|
||||||
%{
|
%{
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011-2012 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2011-2013 Stephen Williams (steve@icarus.com)
|
||||||
* Copyright CERN 2012 / Stephen Williams (steve@icarus.com)
|
* Copyright CERN 2012-2013 / Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -674,6 +674,15 @@ composite_type_definition
|
||||||
delete $2;
|
delete $2;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* unbounded_array_definition IEEE 1076-2008 P5.3.2.1 */
|
||||||
|
| K_array '(' index_subtype_definition_list ')' K_of subtype_indication
|
||||||
|
{ sorrymsg(@1, "unbounded_array_definition not supported.\n");
|
||||||
|
std::list<prange_t*> r;
|
||||||
|
VTypeArray*tmp = new VTypeArray($6, &r);
|
||||||
|
$$ = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
| record_type_definition
|
| record_type_definition
|
||||||
{ $$ = $1; }
|
{ $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
@ -1342,6 +1351,16 @@ index_constraint
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
/* The identifier should be a type name */
|
||||||
|
index_subtype_definition /* IEEE 1076-2008 P5.3.2.1 */
|
||||||
|
: IDENTIFIER K_range BOX
|
||||||
|
;
|
||||||
|
|
||||||
|
index_subtype_definition_list
|
||||||
|
: index_subtype_definition_list ',' index_subtype_definition
|
||||||
|
| index_subtype_definition
|
||||||
|
;
|
||||||
|
|
||||||
instantiation_list
|
instantiation_list
|
||||||
: identifier_list
|
: identifier_list
|
||||||
{
|
{
|
||||||
|
|
@ -2189,12 +2208,13 @@ subtype_indication
|
||||||
delete[]$1;
|
delete[]$1;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
| IDENTIFIER '(' simple_expression direction simple_expression ')'
|
| IDENTIFIER index_constraint
|
||||||
{ const VType*tmp = calculate_subtype_array(@1, $1, active_scope, $3, $4, $5);
|
{ const VType*tmp = calculate_subtype_array(@1, $1, active_scope, $2);
|
||||||
if (tmp == 0) {
|
if (tmp == 0) {
|
||||||
errormsg(@1, "Unable to calculate bounds for array of %s.\n", $1);
|
errormsg(@1, "Unable to calculate bounds for array of %s.\n", $1);
|
||||||
}
|
}
|
||||||
delete[]$1;
|
delete[]$1;
|
||||||
|
delete $2;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
| IDENTIFIER K_range simple_expression direction simple_expression
|
| IDENTIFIER K_range simple_expression direction simple_expression
|
||||||
|
|
@ -2205,11 +2225,6 @@ subtype_indication
|
||||||
delete[]$1;
|
delete[]$1;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
| IDENTIFIER '(' error ')'
|
|
||||||
{ errormsg(@1, "Syntax error in subtype indication.\n");
|
|
||||||
yyerrok;
|
|
||||||
$$ = new VTypeERROR;
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
|
|
||||||
suffix
|
suffix
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2011,2013 Stephen Williams (steve@icarus.com)
|
||||||
|
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -19,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# include "parse_misc.h"
|
# include "parse_misc.h"
|
||||||
|
# include "parse_types.h"
|
||||||
# include "parse_api.h"
|
# include "parse_api.h"
|
||||||
# include "entity.h"
|
# include "entity.h"
|
||||||
# include "architec.h"
|
# include "architec.h"
|
||||||
|
|
@ -65,7 +67,7 @@ void bind_architecture_to_entity(const char*ename, Architecture*arch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const VType* calculate_subtype_array(const YYLTYPE&loc, const char*base_name,
|
static const VType* calculate_subtype_array(const YYLTYPE&loc, const char*base_name,
|
||||||
ScopeBase* /* scope */,
|
ScopeBase* /* scope */,
|
||||||
Expression*array_left,
|
Expression*array_left,
|
||||||
bool /* downto*/ ,
|
bool /* downto*/ ,
|
||||||
|
|
@ -98,6 +100,21 @@ const VType* calculate_subtype_array(const YYLTYPE&loc, const char*base_name,
|
||||||
return base_type;
|
return base_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const VType* calculate_subtype_array(const YYLTYPE&loc, const char*base_name,
|
||||||
|
ScopeBase*scope, list<prange_t*>*ranges)
|
||||||
|
{
|
||||||
|
if (ranges->size() == 1) {
|
||||||
|
prange_t*tmpr = ranges->front();
|
||||||
|
Expression*lef = tmpr->expr_left();
|
||||||
|
Expression*rig = tmpr->expr_right();
|
||||||
|
return calculate_subtype_array(loc, base_name, scope,
|
||||||
|
lef, tmpr->is_downto(), rig);
|
||||||
|
}
|
||||||
|
|
||||||
|
sorrymsg(loc, "Don't know how to handle multiple ranges here.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const VType* calculate_subtype_range(const YYLTYPE&loc, const char*base_name,
|
const VType* calculate_subtype_range(const YYLTYPE&loc, const char*base_name,
|
||||||
ScopeBase*scope,
|
ScopeBase*scope,
|
||||||
Expression*range_left,
|
Expression*range_left,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#ifndef __parse_misc_H
|
#ifndef __parse_misc_H
|
||||||
#define __parse_misc_H
|
#define __parse_misc_H
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2011,2013 Stephen Williams (steve@icarus.com)
|
||||||
|
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -25,6 +26,7 @@ class ActiveScope;
|
||||||
class Architecture;
|
class Architecture;
|
||||||
class Expression;
|
class Expression;
|
||||||
class Package;
|
class Package;
|
||||||
|
class prange_t;
|
||||||
class ScopeBase;
|
class ScopeBase;
|
||||||
class VType;
|
class VType;
|
||||||
|
|
||||||
|
|
@ -33,9 +35,7 @@ extern void bind_architecture_to_entity(const char*ename, Architecture*arch);
|
||||||
|
|
||||||
extern const VType* calculate_subtype_array(const YYLTYPE&loc, const char*base_name,
|
extern const VType* calculate_subtype_array(const YYLTYPE&loc, const char*base_name,
|
||||||
ScopeBase*scope,
|
ScopeBase*scope,
|
||||||
Expression*array_left,
|
std::list<prange_t*>*ranges);
|
||||||
bool downto,
|
|
||||||
Expression*array_right);
|
|
||||||
extern const VType* calculate_subtype_range(const YYLTYPE&loc, const char*base_name,
|
extern const VType* calculate_subtype_range(const YYLTYPE&loc, const char*base_name,
|
||||||
ScopeBase*scope,
|
ScopeBase*scope,
|
||||||
Expression*range_left,
|
Expression*range_left,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#ifndef __parse_types_H
|
#ifndef __parse_types_H
|
||||||
#define __parse_types_H
|
#define __parse_types_H
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2011,2013 Stephen Williams (steve@icarus.com)
|
||||||
|
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -74,10 +75,12 @@ class prange_t {
|
||||||
~prange_t() { delete left_; delete right_; }
|
~prange_t() { delete left_; delete right_; }
|
||||||
void dump(ostream&out, int indent) const;
|
void dump(ostream&out, int indent) const;
|
||||||
|
|
||||||
Expression*msb() { return direction_? left_ : right_; }
|
inline Expression*msb() { return direction_? left_ : right_; }
|
||||||
Expression*lsb() { return direction_? right_: left_; }
|
inline Expression*lsb() { return direction_? right_: left_; }
|
||||||
|
|
||||||
inline bool is_downto() const { return direction_; }
|
inline bool is_downto() const { return direction_; }
|
||||||
|
inline Expression*expr_left() { return left_; }
|
||||||
|
inline Expression*expr_right() { return right_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Expression *left_, *right_;
|
Expression *left_, *right_;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue