From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ace3fca092a457cd X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn11feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: Unary operator after binary operator: legal or not? => Compiler Error Reply-To: anon@anon.org (anon) References: X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Tue, 31 Jul 2007 23:22:08 GMT NNTP-Posting-Host: 12.65.204.14 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1185924128 12.65.204.14 (Tue, 31 Jul 2007 23:22:08 GMT) NNTP-Posting-Date: Tue, 31 Jul 2007 23:22:08 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:1302 Date: 2007-07-31T23:22:08+00:00 List-Id: PROOF! Using the three statements return +Left & +Right; return +Left * +Right; return +Left * -7; we get the following three Expressions +Left & +Right; +Left * +Right +Left * -7 Ada LRM 4.4 ( 2 ) => expression ::= relation +Left & +Right; +Left * +Right +Left * -7 Ada LRM 4.4 ( 3 ) => relation ::= simple_expression +Left & +Right; +Left * +Right +Left * -7 Ada LRM 4.4 ( 4 ) => simple_expression ::= [unary_adding_operator] term {binary_adding_operator term} ::= +Left & +Right + => is the unary, Left => is a Term, & => binary_adding_operator +Right => is second term ::= +Left * +Right + => is the unary, Left => is a Term, * => binary_adding_operator +Right => is second term ::= +Left * -7 + => is the unary, Left => is a Term, * => binary_adding_operator -7 => is second term For now, skiping Left as a Term, because no compiler error and to save time. Using the second Term! Ada LRM 4.4 ( 5 ) => term ::= factor +Right -7 Ada LRM 4.4 ( 6 ) => factor ::= primary +Right -7 Ada LRM 4.4 ( 7 ) => primary ::= numeric_literal | .. | (expression) +Right => is defined as an expression -7 => is defined as an expression Back to Ada LRM 4.4 ( 2 ) => expression ::= relation +Right -7 Ada LRM 4.4 ( 3 ) => relation ::= simple_expression +Right -7 Ada LRM 4.4 ( 4 ) => simple_expression ::= [unary_adding_operator] term {binary_adding_operator term} ::= +Right + => is the unary, Right => term ::= -7 - => is the unary, 7 => term Ada LRM 4.4 ( 5 ) => term ::= factor Right 7 Ada LRM 4.4 ( 6 ) => factor ::= primary Right 7 Ada LRM 4.4 ( 7 ) => primary ::= numeric_literal | string_literal Right => string_literal 7 => numeric_literal All three expressions are valid Ada expressions +Left & +Right +Left * +Right +Left * -7 Which means that the following three statement are valid! return +Left & +Right; return +Left * +Right; return +Left * -7; Since GNAT gives an error! That Denote This is a GNAT COMPILER ERROR! And No Parenthesize Are Required! GNAT COMPILER ERROR! In , anon@anon.org (anon) writes: >In , anon@anon.org (anon) writes: >>This maybe a compiler error. It seams that my GNAT 2.1 from (NYC) as >>well as my GNAT 4.3 (GNU) and my Adacore GNAT 2005 (GPL) all state >>the same that it there is a "missing operand". But if you use the >>following: >> return "+"(Left) & "+"(Right); >>or >> return (+Left) & (+Right); >>they both work >> >>>From LRM 4.4 .. 4.5 and LRM 6.6 states that the unary functions can be >>redefined. The reason I say this may be an compiler error is because >>the following will still give the same error: >> >>Compiling: xyz.adb (source file time stamp: 2007-07-30 03:00:04) >> >> 1. >> 2. function Xyz (Left, Right : in integer) return integer is >> 3. >> 4. begin -- Xyz >> 5. if +Left <= +Right then >> 6. return +Left * +Right; >> | >> >>> missing operand >> >> 7. end if; >> 8. end Xyz; >> > >Forgot to add, in my modified math version, if you replace the "+Right" >with "+7" which is a simple_expression it still will give an error. And >because you could replace the "+7" with "-7", for negative numbers, >which is also a simple_expression you still get an error. This means you >have found a compiler error! > >This needs to be reported! > > >>In , "Jeffrey R. Carter" writes: >>>Here's something confusing I encountered: >>> >>>with Ada.Strings.Unbounded; >>> >>>function Xyz (Left, Right : in Ada.Strings.Unbounded.Unbounded_String) >>>return String is >>> function "+" (Right : in Ada.Strings.Unbounded.Unbounded_String) >>> return String renames Ada.Strings.Unbounded.To_String; >>>begin -- Xyz >>> if +Left <= +Right then >>> return +Left & +Right; >>> -- ^ Error reported here. >>> end if; >>>end Xyz; >>> >>>A compiler reports "missing operand", referencing the space after the "&". >>> >>>Why then does it accept the comparison in the previous line? Both are >>> >>>+Left [binary operator] +Right >>> >>>-- >>>Jeff Carter >>>"Have you gone berserk? Can't you see that that man is a ni?" >>>Blazing Saddles >>>38 >> >