emery@MITRE-BEDFORD.ARPA (Emery) (09/19/87)
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
stt@ada-uts.UUCP (09/22/87)
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
MFELDMAN@GWUVM.BITNET (Mike Feldman) (09/22/87)
Regarding your strange little program, Meridian gives the following: line 3 <<error>> illegal base in numeric literal. I will try some other compilers later.