comp.lang.ada
 help / color / mirror / Atom feed
* Re: Strange syntax
@ 1987-09-23 17:53 Kenneth.Lee
  1987-09-24  9:12 ` Jan Kok
  0 siblings, 1 reply; 3+ messages in thread
From: Kenneth.Lee @ 1987-09-23 17:53 UTC (permalink / raw)


> From: "GBURG::CWILLIAMS" <cwilliams%gburg decnet@bluto scc com>
> The Rational R1000 compiler also accepts the example as legal and does execute
> properly. Given the fact that DEC-Ada also accepts it, I would say that it is
> in fact legal Ada. The fact that other compilers reject it as erroneous 
> suggests to me that the example should be added to the ACVC if the final 
> determination is that the example is legal.
> 
> Chuck Williams
> CONTEL Federal Systems

The Rational R1000 compiles the code because the first step when a source
unit is promoted to an installed unit is to format the code.  The
reformatted code for the line in question is:
	Foo : Integer range 1 .. Max_Val + 1 := 15;

The following, recent post on the SEI bboard from Robert Firth provides an
explanation for the compiler diagnostics.

22-Sep-87 17:52    Robert Firth@sei cmu edu     1:= syntax error
The problems with "1:=" generating an error can be traced to
[RM 2.4.2 - Based Literals] and [RM 2.10 - Allowable Replacements of
Characters].

The compiler believes that the sequence "1:" introduces a based literal,
for instance "1:0123:".  Accordingly, it fails on the "=" character,
which cannot be part of a based literal.

Recall that, while based literals are usually written "2#1010#", the
colon is an allowable replacement for the hachure.  You should expect
various error messages, such as "illegal char in based literal",
"invalid base in based literal", and so on.

This lexis is correct according to the RM - indeed, any alternative
would no longer be LR(1) and so would cause trouble for automatic
scanner generators.  And the colon is a replacement character because
Steelman required that Ada be representable using a 56-character set.

Sigh.

Robert


-----


Ken

^ permalink raw reply	[flat|nested] 3+ messages in thread
* strange syntax
@ 1987-09-22 18:15 Mike Feldman
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Feldman @ 1987-09-22 18:15 UTC (permalink / raw)


========================================================================
Dave Emery writes:


>Here's a real ada-guru question:
>Is the following program (syntactically) legal?
>  package demo is
>    max_val : constant := 15;
>    -- check the next declaration out carefully...
>   foo : integer range 1 .. max_val +1:= 15;
>   -- some compilers complain right  ^ there, and say that 1: is not
>   -- a legal literal, and then i get all kind of errors...
> end demo;
>It's obvious from reading the program what is meant, but must a
>parser be able to determine that +1: breaks down to 3 tokens, "+", "1"
>and ":="?


This looks really quirky to me. I tried it with four compilers: Meridian
1.5, Ada/Ed-PC, TeleSoft 3.1.3 VMS and Verdix 5.4.1 Sun. _All_ rejected
the program, typically with some "bad literal" message, with or without
further propagation. Oddly enough, _all_ accepted the program if a
blank was put after the 1 but before the colon! (i.e. +1 := ).

I cannot imagine a context for : in that position that's not going to
be a := - are there any syntax buffs out there who can explain just what
is ambiguous in that context?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1987-09-24  9:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1987-09-23 17:53 Strange syntax Kenneth.Lee
1987-09-24  9:12 ` Jan Kok
  -- strict thread matches above, loose matches on Subject: below --
1987-09-22 18:15 strange syntax Mike Feldman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox