* Ada reference manual rule for doubled parentheses around if_expression?
@ 2015-07-31 17:00 Stephen Leake
2015-07-31 18:29 ` Bob Duff
2015-07-31 20:07 ` EGarrulo
0 siblings, 2 replies; 7+ messages in thread
From: Stephen Leake @ 2015-07-31 17:00 UTC (permalink / raw)
A question recently came up on the Emacs ada-mode list; my Emacs
ada-mode parser rejects this if_expression in an association list:
Tmp : Boolean := Id (if True then True else True);
but accepts this:
Tmp : Boolean := Id ((if True then True else True));
I remember seeing some rule in the Ada reference manual that says the
doubled parens are not needed here. But now I can't find the rule, and I
don't want to edit my grammar without a reference.
Anyone know where that rule is? or what to search for?
--
-- Stephe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Ada reference manual rule for doubled parentheses around if_expression?
2015-07-31 17:00 Ada reference manual rule for doubled parentheses around if_expression? Stephen Leake
@ 2015-07-31 18:29 ` Bob Duff
2015-08-01 7:36 ` Simon Wright
2015-08-01 9:11 ` Stephen Leake
2015-07-31 20:07 ` EGarrulo
1 sibling, 2 replies; 7+ messages in thread
From: Bob Duff @ 2015-07-31 18:29 UTC (permalink / raw)
Stephen Leake <stephen_leake@stephe-leake.org> writes:
> A question recently came up on the Emacs ada-mode list; my Emacs
> ada-mode parser rejects this if_expression in an association list:
>
> Tmp : Boolean := Id (if True then True else True);
>
> but accepts this:
>
> Tmp : Boolean := Id ((if True then True else True));
>
> I remember seeing some rule in the Ada reference manual that says the
> doubled parens are not needed here. But now I can't find the rule, and I
> don't want to edit my grammar without a reference.
>
> Anyone know where that rule is? or what to search for?
4.5.7(7). This is a syntax rule, despite not being written in BNF.
I suggest you read the AARM annotations.
- Bob
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Ada reference manual rule for doubled parentheses around if_expression?
2015-07-31 17:00 Ada reference manual rule for doubled parentheses around if_expression? Stephen Leake
2015-07-31 18:29 ` Bob Duff
@ 2015-07-31 20:07 ` EGarrulo
1 sibling, 0 replies; 7+ messages in thread
From: EGarrulo @ 2015-07-31 20:07 UTC (permalink / raw)
On Friday, July 31, 2015 at 7:00:13 PM UTC+2, Stephen Leake wrote:
> A question recently came up on the Emacs ada-mode list; my Emacs
> ada-mode parser rejects this if_expression in an association list:
>
> Tmp : Boolean := Id (if True then True else True);
>
> but accepts this:
>
> Tmp : Boolean := Id ((if True then True else True));
>
> I remember seeing some rule in the Ada reference manual that says the
> doubled parens are not needed here. But now I can't find the rule, and I
> don't want to edit my grammar without a reference.
>
> Anyone know where that rule is? or what to search for?
The Rationale says it in the "1.3.2 Expressions" chapter.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Ada reference manual rule for doubled parentheses around if_expression?
2015-07-31 18:29 ` Bob Duff
@ 2015-08-01 7:36 ` Simon Wright
2015-08-01 9:11 ` Stephen Leake
1 sibling, 0 replies; 7+ messages in thread
From: Simon Wright @ 2015-08-01 7:36 UTC (permalink / raw)
Bob Duff <bobduff@theworld.com> writes:
> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
>> A question recently came up on the Emacs ada-mode list; my Emacs
>> ada-mode parser rejects this if_expression in an association list:
>>
>> Tmp : Boolean := Id (if True then True else True);
>>
>> but accepts this:
>>
>> Tmp : Boolean := Id ((if True then True else True));
>>
>> I remember seeing some rule in the Ada reference manual that says the
>> doubled parens are not needed here. But now I can't find the rule,
>> and I don't want to edit my grammar without a reference.
>>
>> Anyone know where that rule is? or what to search for?
>
> 4.5.7(7). This is a syntax rule, despite not being written in BNF. I
> suggest you read the AARM annotations.
The question to which Stephe refers also shows
function F2 (V : Integer) return Boolean
is (True and then True)
or else True;
which GNAT accepts but probably shouldn't? the parens in ARM 6.8(2)[1]
wrap the whole expression.
[1] http://www.ada-auth.org/standards/12rm/html/RM-6-8.html#p2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Ada reference manual rule for doubled parentheses around if_expression?
2015-07-31 18:29 ` Bob Duff
2015-08-01 7:36 ` Simon Wright
@ 2015-08-01 9:11 ` Stephen Leake
2015-08-01 13:42 ` Bob Duff
1 sibling, 1 reply; 7+ messages in thread
From: Stephen Leake @ 2015-08-01 9:11 UTC (permalink / raw)
Bob Duff <bobduff@theworld.com> writes:
> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
>> I remember seeing some rule in the Ada reference manual that says the
>> doubled parens are not needed here. But now I can't find the rule, and I
>> don't want to edit my grammar without a reference.
>>
>> Anyone know where that rule is? or what to search for?
>
> 4.5.7(7). This is a syntax rule, despite not being written in BNF.
> I suggest you read the AARM annotations.
Thanks.
There's a similar rule for quantified expressions in 4.5.8(4).
GNAT also accepts this:
function Expression_Function_1 (V : Integer) return Boolean
is (V = V and then True)
or else True;
I think that's a bug, because there are no parens surrounding the
entire expression.
--
-- Stephe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Ada reference manual rule for doubled parentheses around if_expression?
2015-08-01 9:11 ` Stephen Leake
@ 2015-08-01 13:42 ` Bob Duff
2015-08-03 22:56 ` Randy Brukardt
0 siblings, 1 reply; 7+ messages in thread
From: Bob Duff @ 2015-08-01 13:42 UTC (permalink / raw)
Stephen Leake <stephen_leake@stephe-leake.org> writes:
> Bob Duff <bobduff@theworld.com> writes:
>
>> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>>
>>> I remember seeing some rule in the Ada reference manual that says the
>>> doubled parens are not needed here. But now I can't find the rule, and I
>>> don't want to edit my grammar without a reference.
>>>
>>> Anyone know where that rule is? or what to search for?
>>
>> 4.5.7(7). This is a syntax rule, despite not being written in BNF.
>> I suggest you read the AARM annotations.
>
> Thanks.
You're welcome.
> There's a similar rule for quantified expressions in 4.5.8(4).
Right.
> GNAT also accepts this:
>
> function Expression_Function_1 (V : Integer) return Boolean
> is (V = V and then True)
> or else True;
>
> I think that's a bug, because there are no parens surrounding the
> entire expression.
I agree that's a bug. It doesn't seem to have anything to do with the
special rules about conditional/quantified expressions. Or does it?
If you report this to report@adacore.com, it will get fixed.
- Bob
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Ada reference manual rule for doubled parentheses around if_expression?
2015-08-01 13:42 ` Bob Duff
@ 2015-08-03 22:56 ` Randy Brukardt
0 siblings, 0 replies; 7+ messages in thread
From: Randy Brukardt @ 2015-08-03 22:56 UTC (permalink / raw)
"Bob Duff" <bobduff@theworld.com> wrote in message
news:87mvybktvt.fsf@theworld.com...
> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
...
>> GNAT also accepts this:
>>
>> function Expression_Function_1 (V : Integer) return Boolean
>> is (V = V and then True)
>> or else True;
>>
>> I think that's a bug, because there are no parens surrounding the
>> entire expression.
>
> I agree that's a bug. It doesn't seem to have anything to do with the
> special rules about conditional/quantified expressions. Or does it?
>
> If you report this to report@adacore.com, it will get fixed.
Looks like a bug to me, too. I remembered that we had changed something
about these, but what it was was to accept an aggregate as well as a
parenthesized expression:
function Expression_Function_1 (V : Integer) return Rec is (A => 1, B =>
V);
rather than
function Expression_Function_1 (V : Integer) return Rec is ((A => 1, B
=> V));
This was another case of double paren elimination. But of course we don't
have any rules that eliminate all parens!
Randy.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-08-03 22:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-31 17:00 Ada reference manual rule for doubled parentheses around if_expression? Stephen Leake
2015-07-31 18:29 ` Bob Duff
2015-08-01 7:36 ` Simon Wright
2015-08-01 9:11 ` Stephen Leake
2015-08-01 13:42 ` Bob Duff
2015-08-03 22:56 ` Randy Brukardt
2015-07-31 20:07 ` EGarrulo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox