aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2017-10-26 19:24:18 +0200
committerTristan Gingold <tgingold@free.fr>2017-10-26 19:24:18 +0200
commit1014234660d921a5dccb8bd1d1766190f561611b (patch)
tree4f5255bed98fe6f22869691a4f96726f0f368f47 /src/vhdl
parent5cfe481f7c2cbf90917b00862af02687f1ec2893 (diff)
downloadghdl-1014234660d921a5dccb8bd1d1766190f561611b.tar.gz
ghdl-1014234660d921a5dccb8bd1d1766190f561611b.tar.bz2
ghdl-1014234660d921a5dccb8bd1d1766190f561611b.zip
Add elocation for right parenthesis.
Diffstat (limited to 'src/vhdl')
-rw-r--r--src/vhdl/elocations.adb18
-rw-r--r--src/vhdl/elocations.ads8
-rw-r--r--src/vhdl/elocations_meta.adb11
-rw-r--r--src/vhdl/elocations_meta.ads2
-rw-r--r--src/vhdl/parse.adb10
5 files changed, 46 insertions, 3 deletions
diff --git a/src/vhdl/elocations.adb b/src/vhdl/elocations.adb
index 94b647c4b..d964bcde0 100644
--- a/src/vhdl/elocations.adb
+++ b/src/vhdl/elocations.adb
@@ -286,7 +286,6 @@ package body Elocations is
| Iir_Kind_Exponentiation_Operator
| Iir_Kind_Function_Call
| Iir_Kind_Aggregate
- | Iir_Kind_Parenthesis_Expression
| Iir_Kind_Qualified_Expression
| Iir_Kind_Type_Conversion
| Iir_Kind_Allocator_By_Expression
@@ -393,6 +392,7 @@ package body Elocations is
| Iir_Kind_Interface_File_Declaration
| Iir_Kind_Interface_Type_Declaration
| Iir_Kind_Interface_Package_Declaration
+ | Iir_Kind_Parenthesis_Expression
| Iir_Kind_Concurrent_Simple_Signal_Assignment
| Iir_Kind_Concurrent_Conditional_Signal_Assignment
| Iir_Kind_Concurrent_Selected_Signal_Assignment =>
@@ -449,6 +449,22 @@ package body Elocations is
Set_Field1 (N, Loc);
end Set_Start_Location;
+ function Get_Right_Paren_Location (N : Iir) return Location_Type is
+ begin
+ pragma Assert (N /= Null_Iir);
+ pragma Assert (Has_Right_Paren_Location (Get_Kind (N)),
+ "no field Right_Paren_Location");
+ return Get_Field1 (N);
+ end Get_Right_Paren_Location;
+
+ procedure Set_Right_Paren_Location (N : Iir; Loc : Location_Type) is
+ begin
+ pragma Assert (N /= Null_Iir);
+ pragma Assert (Has_Right_Paren_Location (Get_Kind (N)),
+ "no field Right_Paren_Location");
+ Set_Field1 (N, Loc);
+ end Set_Right_Paren_Location;
+
function Get_End_Location (N : Iir) return Location_Type is
begin
pragma Assert (N /= Null_Iir);
diff --git a/src/vhdl/elocations.ads b/src/vhdl/elocations.ads
index a6b728fa4..57c044b52 100644
--- a/src/vhdl/elocations.ads
+++ b/src/vhdl/elocations.ads
@@ -502,7 +502,9 @@ package Elocations is
-- Iir_Kind_Aggregate_Info (None)
- -- Iir_Kind_Parenthesis_Expression (None)
+ -- Iir_Kind_Parenthesis_Expression (L1)
+ --
+ -- Get/Set_Right_Paren_Location (Field1)
-- Iir_Kind_Qualified_Expression (None)
@@ -621,6 +623,10 @@ package Elocations is
function Get_Start_Location (N : Iir) return Location_Type;
procedure Set_Start_Location (N : Iir; Loc : Location_Type);
+ -- Field: Field1
+ function Get_Right_Paren_Location (N : Iir) return Location_Type;
+ procedure Set_Right_Paren_Location (N : Iir; Loc : Location_Type);
+
-- Field: Field2
function Get_End_Location (N : Iir) return Location_Type;
procedure Set_End_Location (N : Iir; Loc : Location_Type);
diff --git a/src/vhdl/elocations_meta.adb b/src/vhdl/elocations_meta.adb
index 433edd32e..9ead9dafa 100644
--- a/src/vhdl/elocations_meta.adb
+++ b/src/vhdl/elocations_meta.adb
@@ -24,6 +24,8 @@ package body Elocations_Meta is
case F is
when Field_Start_Location =>
return "start_location";
+ when Field_Right_Paren_Location =>
+ return "right_paren_location";
when Field_End_Location =>
return "end_location";
when Field_Is_Location =>
@@ -65,6 +67,8 @@ package body Elocations_Meta is
case F is
when Field_Start_Location =>
return Get_Start_Location (N);
+ when Field_Right_Paren_Location =>
+ return Get_Right_Paren_Location (N);
when Field_End_Location =>
return Get_End_Location (N);
when Field_Is_Location =>
@@ -97,6 +101,8 @@ package body Elocations_Meta is
case F is
when Field_Start_Location =>
Set_Start_Location (N, V);
+ when Field_Right_Paren_Location =>
+ Set_Right_Paren_Location (N, V);
when Field_End_Location =>
Set_End_Location (N, V);
when Field_Is_Location =>
@@ -179,6 +185,11 @@ package body Elocations_Meta is
end case;
end Has_Start_Location;
+ function Has_Right_Paren_Location (K : Iir_Kind) return Boolean is
+ begin
+ return K = Iir_Kind_Parenthesis_Expression;
+ end Has_Right_Paren_Location;
+
function Has_End_Location (K : Iir_Kind) return Boolean is
begin
case K is
diff --git a/src/vhdl/elocations_meta.ads b/src/vhdl/elocations_meta.ads
index 34d461a77..ed1f2cdf1 100644
--- a/src/vhdl/elocations_meta.ads
+++ b/src/vhdl/elocations_meta.ads
@@ -24,6 +24,7 @@ package Elocations_Meta is
type Fields_Enum is
(
Field_Start_Location,
+ Field_Right_Paren_Location,
Field_End_Location,
Field_Is_Location,
Field_Begin_Location,
@@ -48,6 +49,7 @@ package Elocations_Meta is
(N : Iir; F : Fields_Enum; V: Location_Type);
function Has_Start_Location (K : Iir_Kind) return Boolean;
+ function Has_Right_Paren_Location (K : Iir_Kind) return Boolean;
function Has_End_Location (K : Iir_Kind) return Boolean;
function Has_Is_Location (K : Iir_Kind) return Boolean;
function Has_Begin_Location (K : Iir_Kind) return Boolean;
diff --git a/src/vhdl/parse.adb b/src/vhdl/parse.adb
index 01bd61f60..493736f12 100644
--- a/src/vhdl/parse.adb
+++ b/src/vhdl/parse.adb
@@ -4717,7 +4717,7 @@ package body Parse is
Res: Iir;
Last : Iir;
Assoc: Iir;
- Loc : Location_Type;
+ Loc, Right_Loc : Location_Type;
begin
Loc := Get_Token_Location;
@@ -4735,6 +4735,8 @@ package body Parse is
when Tok_Right_Paren =>
-- This was just a braced expression.
+ Right_Loc := Get_Token_Location;
+
-- Skip ')'.
Scan;
@@ -4752,6 +4754,12 @@ package body Parse is
Res := Create_Iir (Iir_Kind_Parenthesis_Expression);
Set_Location (Res, Loc);
Set_Expression (Res, Expr);
+
+ if Flag_Elocations then
+ Create_Elocations (Res);
+ Set_Right_Paren_Location (Res, Right_Loc);
+ end if;
+
return Res;
when Tok_Semi_Colon =>