comp.lang.ada
 help / color / mirror / Atom feed
* lexical question
@ 1987-09-19  1:47 Emery
  0 siblings, 0 replies; 3+ messages in thread
From: Emery @ 1987-09-19  1:47 UTC (permalink / raw)


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 ":="?

				dave emery
				emery@mitre-bedford.arpa

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

* Re: lexical question
       [not found] <28027@mitre-bedford.ARPA>
@ 1987-09-21 21:31 ` stt
  0 siblings, 0 replies; 3+ messages in thread
From: stt @ 1987-09-21 21:31 UTC (permalink / raw)



As the BOOK says in 2.2:2
  ... an explicit separator is required ... when without
separation, interpretation as a single lexical element is
possible...

In this case, the separator is not required because
"1:=" is not a legal single lexical element, nor
is "1:".  It is true that "1:0:" might be considered
a based literal, except that 2.4.2:1 specifies that
the "base must be at least two and at most sixteen."
However, even if it were "2:" instead of "1:", the lexer
must look beyond the ":" to determine whether the
":" is acting as an allowable replacement for "#" (see
2.10:3).

Tucker Taft c/o Intermetrics, Cambridge, MA

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

* Re: lexical question
@ 1987-09-22 16:50 Mike Feldman
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Feldman @ 1987-09-22 16:50 UTC (permalink / raw)


Regarding your strange little program, Meridian gives the following:

line 3 <<error>> illegal base in numeric literal.

I will try some other compilers later.

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

end of thread, other threads:[~1987-09-22 16:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1987-09-22 16:50 lexical question Mike Feldman
     [not found] <28027@mitre-bedford.ARPA>
1987-09-21 21:31 ` stt
  -- strict thread matches above, loose matches on Subject: below --
1987-09-19  1:47 Emery

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