par.ads, par.adb: Improve handling of extra right parens.
2007-08-14 Robert Dewar <dewar@adacore.com> Ed Schonberg <schonberg@adacore.com> * par.ads, par.adb: Improve handling of extra right parens. (Par): Remove flag From_Limited_With_Clause. * par-util.adb, par-ch3.adb: Improve error recovery for bad constraint Improve handling of extra right parens. From-SVN: r127423
This commit is contained in:
parent
3355aa3e72
commit
7dc5f546f0
@ -61,15 +61,14 @@ package body Ch3 is
|
||||
Done : out Boolean;
|
||||
In_Spec : Boolean);
|
||||
-- Scans out a single declarative item, or, in the case of a declaration
|
||||
-- with a list of identifiers, a list of declarations, one for each of
|
||||
-- the identifiers in the list. The declaration or declarations scanned
|
||||
-- are appended to the given list. Done indicates whether or not there
|
||||
-- may be additional declarative items to scan. If Done is True, then
|
||||
-- a decision has been made that there are no more items to scan. If
|
||||
-- Done is False, then there may be additional declarations to scan.
|
||||
-- In_Spec is true if we are scanning a package declaration, and is used
|
||||
-- to generate an appropriate message if a statement is encountered in
|
||||
-- such a context.
|
||||
-- with a list of identifiers, a list of declarations, one for each of the
|
||||
-- identifiers in the list. The declaration or declarations scanned are
|
||||
-- appended to the given list. Done indicates whether or not there may be
|
||||
-- additional declarative items to scan. If Done is True, then a decision
|
||||
-- has been made that there are no more items to scan. If Done is False,
|
||||
-- then there may be additional declarations to scan. In_Spec is true if
|
||||
-- we are scanning a package declaration, and is used to generate an
|
||||
-- appropriate message if a statement is encountered in such a context.
|
||||
|
||||
procedure P_Identifier_Declarations
|
||||
(Decls : List_Id;
|
||||
@ -2410,7 +2409,7 @@ package body Ch3 is
|
||||
begin
|
||||
Constraint_Node := New_Node (N_Digits_Constraint, Token_Ptr);
|
||||
Scan; -- past DIGITS
|
||||
Expr_Node := P_Expression_No_Right_Paren;
|
||||
Expr_Node := P_Expression;
|
||||
Check_Simple_Expression_In_Ada_83 (Expr_Node);
|
||||
Set_Digits_Expression (Constraint_Node, Expr_Node);
|
||||
|
||||
@ -2442,7 +2441,7 @@ package body Ch3 is
|
||||
begin
|
||||
Constraint_Node := New_Node (N_Delta_Constraint, Token_Ptr);
|
||||
Scan; -- past DELTA
|
||||
Expr_Node := P_Expression_No_Right_Paren;
|
||||
Expr_Node := P_Expression;
|
||||
Check_Simple_Expression_In_Ada_83 (Expr_Node);
|
||||
Set_Delta_Expression (Constraint_Node, Expr_Node);
|
||||
|
||||
@ -3505,7 +3504,8 @@ package body Ch3 is
|
||||
|
||||
else
|
||||
begin
|
||||
Expr_Node := No_Right_Paren (P_Expression_Or_Range_Attribute);
|
||||
Expr_Node := P_Expression_Or_Range_Attribute;
|
||||
Check_No_Right_Paren;
|
||||
|
||||
if Token = Tok_Colon
|
||||
and then Nkind (Expr_Node) = N_Identifier
|
||||
@ -3602,7 +3602,7 @@ package body Ch3 is
|
||||
|
||||
if Abstract_Present then
|
||||
Error_Msg_SP ("ABSTRACT not allowed in interface type definition " &
|
||||
"('R'M' 3.9.4(2/2))");
|
||||
"(RM 3.9.4(2/2))");
|
||||
end if;
|
||||
|
||||
Scan; -- past INTERFACE
|
||||
@ -3983,7 +3983,9 @@ package body Ch3 is
|
||||
Scan_State : Saved_Scan_State;
|
||||
|
||||
begin
|
||||
if Style_Check then Style.Check_Indentation; end if;
|
||||
if Style_Check then
|
||||
Style.Check_Indentation;
|
||||
end if;
|
||||
|
||||
case Token is
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
-- --
|
||||
-- B o d y --
|
||||
-- --
|
||||
-- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
|
||||
-- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
|
||||
-- --
|
||||
-- GNAT is free software; you can redistribute it and/or modify it under --
|
||||
-- terms of the GNU General Public License as published by the Free Soft- --
|
||||
@ -176,6 +176,18 @@ package body Util is
|
||||
end if;
|
||||
end Check_Misspelling_Of;
|
||||
|
||||
--------------------------
|
||||
-- Check_No_Right_Paren --
|
||||
--------------------------
|
||||
|
||||
procedure Check_No_Right_Paren is
|
||||
begin
|
||||
if Token = Tok_Right_Paren then
|
||||
Error_Msg_SC ("unexpected right parenthesis");
|
||||
Scan; -- past unexpected right paren
|
||||
end if;
|
||||
end Check_No_Right_Paren;
|
||||
|
||||
-----------------------------
|
||||
-- Check_Simple_Expression --
|
||||
-----------------------------
|
||||
@ -587,21 +599,6 @@ package body Util is
|
||||
end if;
|
||||
end No_Constraint;
|
||||
|
||||
--------------------
|
||||
-- No_Right_Paren --
|
||||
--------------------
|
||||
|
||||
function No_Right_Paren (Expr : Node_Id) return Node_Id is
|
||||
begin
|
||||
if Token = Tok_Right_Paren then
|
||||
Error_Msg_SC ("unexpected right parenthesis");
|
||||
Resync_Expression;
|
||||
return Error;
|
||||
else
|
||||
return Expr;
|
||||
end if;
|
||||
end No_Right_Paren;
|
||||
|
||||
---------------------
|
||||
-- Pop_Scope_Stack --
|
||||
---------------------
|
||||
|
@ -51,8 +51,7 @@ with Tbuild; use Tbuild;
|
||||
---------
|
||||
|
||||
function Par
|
||||
(Configuration_Pragmas : Boolean;
|
||||
From_Limited_With : Boolean := False) return List_Id
|
||||
(Configuration_Pragmas : Boolean) return List_Id
|
||||
is
|
||||
Num_Library_Units : Natural := 0;
|
||||
-- Count number of units parsed (relevant only in syntax check only mode,
|
||||
@ -1042,6 +1041,10 @@ is
|
||||
-- it is returned unchanged. Otherwise an error message is issued
|
||||
-- and Error is returned.
|
||||
|
||||
procedure Check_No_Right_Paren;
|
||||
-- Called to check that the current token is not a right paren. If it
|
||||
-- is, then an error is given, and the right parenthesis is scanned out.
|
||||
|
||||
function Comma_Present return Boolean;
|
||||
-- Used in comma delimited lists to determine if a comma is present, or
|
||||
-- can reasonably be assumed to have been present (an error message is
|
||||
@ -1089,10 +1092,6 @@ is
|
||||
-- parameter. If a constraint is present, an error message is posted,
|
||||
-- and the constraint is scanned and discarded.
|
||||
|
||||
function No_Right_Paren (Expr : Node_Id) return Node_Id;
|
||||
-- Function to check for no right paren at end of expression, returns
|
||||
-- its argument if no right paren, else flags paren and returns Error.
|
||||
|
||||
procedure Push_Scope_Stack;
|
||||
pragma Inline (Push_Scope_Stack);
|
||||
-- Push a new entry onto the scope stack. Scope.Last (the stack pointer)
|
||||
|
@ -6,7 +6,7 @@
|
||||
-- --
|
||||
-- S p e c --
|
||||
-- --
|
||||
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
|
||||
-- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
|
||||
-- --
|
||||
-- GNAT is free software; you can redistribute it and/or modify it under --
|
||||
-- terms of the GNU General Public License as published by the Free Soft- --
|
||||
@ -30,17 +30,14 @@
|
||||
with Types; use Types;
|
||||
|
||||
function Par
|
||||
(Configuration_Pragmas : Boolean;
|
||||
From_Limited_With : Boolean := False) return List_Id;
|
||||
(Configuration_Pragmas : Boolean) return List_Id;
|
||||
-- Top level parsing routine. There are two cases:
|
||||
--
|
||||
-- If Configuration_Pragmas is False, Par parses a compilation unit in the
|
||||
-- current source file and sets the Cunit, Cunit_Entity and Unit_Name fields
|
||||
-- of the units table entry for Current_Source_Unit. On return the parse tree
|
||||
-- is complete, and decorated with any required implicit label declarations.
|
||||
-- The value returned in this case is always No_List. If From_Limited_With is
|
||||
-- True, we are parsing a compilation unit found in a limited-with clause (Ada
|
||||
-- 2005, AI-50217)
|
||||
-- The value returned in this case is always No_List.
|
||||
--
|
||||
-- If Configuration_Pragmas is True, Par parses a list of configuration
|
||||
-- pragmas from the current source file, and returns the list of pragmas.
|
||||
|
Loading…
Reference in New Issue
Block a user