-- --
-- B o d y --
-- --
--- Copyright (C) 2002-2006, Free Software Foundation, Inc. --
+-- Copyright (C) 2002-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- --
with Csets; use Csets;
with Err_Vars; use Err_Vars;
-with Namet; use Namet;
with Opt; use Opt;
with Osint; use Osint;
with Output; use Output;
function Deleting return Boolean;
-- Return True if code should be deleted or commented out
- function Expression (Evaluate_It : Boolean) return Boolean;
+ function Expression
+ (Evaluate_It : Boolean;
+ Complemented : Boolean := False) return Boolean;
-- Evaluate a condition in an #if or an #elsif statement.
-- If Evaluate_It is False, the condition is effectively evaluated,
-- otherwise, only the syntax is checked.
if Pp_States.Last = Ground then
return False;
-
else
return Pp_States.Table (Pp_States.Last).Deleting;
end if;
-- Expression --
----------------
- function Expression (Evaluate_It : Boolean) return Boolean is
+ function Expression
+ (Evaluate_It : Boolean;
+ Complemented : Boolean := False) return Boolean
+ is
Evaluation : Boolean := Evaluate_It;
-- Is set to False after an "or else" when left term is True and
-- after an "and then" when left term is False.
-- not expression
Scan.all;
- Current_Result := not Expression (Evaluation);
+ Current_Result :=
+ not Expression (Evaluation, Complemented => True);
when Tok_Identifier =>
Symbol_Name1 := Token_Name;
-- Check the next operator
if Token = Tok_And then
- if Current_Operator = Op_Or then
+ if Complemented then
+ Error_Msg
+ ("mixing NOT and AND is not allowed, parentheses are required",
+ Token_Ptr);
+
+ elsif Current_Operator = Op_Or then
Error_Msg ("mixing OR and AND is not allowed", Token_Ptr);
end if;
end if;
elsif Token = Tok_Or then
- if Current_Operator = Op_And then
+ if Complemented then
+ Error_Msg
+ ("mixing NOT and OR is not allowed, parentheses are required",
+ Token_Ptr);
+
+ elsif Current_Operator = Op_And then
Error_Msg ("mixing AND and OR is not allowed", Token_Ptr);
end if;
-- --
-- S p e c --
-- --
--- Copyright (C) 2002-2006, Free Software Foundation, Inc. --
+-- Copyright (C) 2002-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- --
with GNAT.Dynamic_Tables;
-with Types; use Types;
+with Namet; use Namet;
+with Types; use Types;
package Prep is