aboutsummaryrefslogtreecommitdiffstats
path: root/src/ortho
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-07-25 15:45:41 +0200
committerTristan Gingold <tgingold@free.fr>2020-07-25 15:45:41 +0200
commit3972f6c78055902116e6c9227da45e1bfe5e2c27 (patch)
treee8914f8a795b05dc44fd71b9493d9c2fc7bcaab2 /src/ortho
parent5f3c9498dc9ad737b398109edf53b4c4a7344696 (diff)
downloadghdl-3972f6c78055902116e6c9227da45e1bfe5e2c27.tar.gz
ghdl-3972f6c78055902116e6c9227da45e1bfe5e2c27.tar.bz2
ghdl-3972f6c78055902116e6c9227da45e1bfe5e2c27.zip
ortho/oread: parse subarray element type.
Diffstat (limited to 'src/ortho')
-rw-r--r--src/ortho/oread/ortho_front.adb24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/ortho/oread/ortho_front.adb b/src/ortho/oread/ortho_front.adb
index 84dace138..4a1e0ee9d 100644
--- a/src/ortho/oread/ortho_front.adb
+++ b/src/ortho/oread/ortho_front.adb
@@ -352,7 +352,7 @@ package body Ortho_Front is
Array_Element : Node_Acc;
when Type_Subarray =>
Subarray_Base : Node_Acc;
- --Subarray_Length : Natural;
+ Subarray_El : Node_Acc;
when Type_Access =>
Access_Dtype : Node_Acc;
when Type_Record
@@ -1320,9 +1320,11 @@ package body Ortho_Front is
return Res;
when Tok_Subarray =>
-- Grammar:
- -- SUBARRAY type [ len ]
+ -- SUBARRAY type '[' len ']' [ OF eltype ]
declare
Base_Node : Node_Acc;
+ Len : O_Cnode;
+ El_Node : Node_Acc;
Res_Type : O_Tnode;
begin
Next_Token;
@@ -1332,15 +1334,23 @@ package body Ortho_Front is
end if;
Expect (Tok_Left_Brack);
Next_Token;
- Res_Type := New_Array_Subtype
- (Base_Node.Type_Onode,
- Base_Node.Array_Element.Type_Onode,
- Parse_Constant_Value (Base_Node.Array_Index));
+ Len := Parse_Constant_Value (Base_Node.Array_Index);
Expect (Tok_Right_Brack);
Next_Token;
+ if Tok = Tok_Of then
+ Next_Token;
+ El_Node := Parse_Type;
+ -- TODO: check this is a subtype of the element
+ else
+ El_Node := Base_Node.Array_Element;
+ -- TODO: check EL_NODE is constrained.
+ end if;
+ Res_Type := New_Array_Subtype
+ (Base_Node.Type_Onode, El_Node.Type_Onode, Len);
Res := new Node' (Kind => Type_Subarray,
Type_Onode => Res_Type,
- Subarray_Base => Base_Node);
+ Subarray_Base => Base_Node,
+ Subarray_El => El_Node);
return Res;
end;
when Tok_Ident =>