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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3b05f12bd7a2a871,start X-Google-Attributes: gid103376,public From: "Nick Roberts" Subject: Lexical Conundrum Date: 1998/02/19 Message-ID: <01bd3d80$101287c0$LocalHost@xhv46.dial.pipex.com>#1/1 X-Deja-AN: 326720244 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1 Organization: UUNet UK server (post doesn't reflect views of UUNet UK) Keywords: parsing; ambiguity Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-02-19T00:00:00+00:00 List-Id: I have run the following program 1 with Ada.Text_IO; use Ada.Text_IO; 2 procedure Test_1 is 3 subtype UC is Character range'A'..'Z'; 4 begin 5 Put_Line("Start of Test_1"); 6 if 'a'='a' or'a'in UC then 7 Put_Line("True branch executed"); 8 end if; 9 Put_Line("End of Test_1"); 10 end; through GNAT 3.10, and it compiles and runs fine. I haven't tried, but I imagine it would probably work on any Ada compiler, in all likelihood. But, if you look closely at line 6, you will see the sequence or'a'in in the middle of an expression. Now, from chapter 2 of the RM, one might get the impression that this could be parsed as five lexical elements (three identifiers and two apostrophes). Of course, if a compiler were to parse it that way, the result would be a syntax error. For comparison, I have put range'A'..'Z'; into line 3. I don't think there is an ambiguity in parsing this, although it is very close to the previous example. Similarly, if the space were to be removed from just before the example in line 6, the ambiguity would be resolved there also. One immediate conclusion, I think, is that the introduction of a one-letter attribute (in an implementation of the language) could cause difficulties! Of course, it's hard to imagine a motive for such an attribute, in practice. Question: would a compiler be in contravention of the RM by rejecting the above program (with a syntax error in line 6)? I admit that such a compiler may be considered to be poorly designed! == Nick Roberts ================================================ == Croydon, UK =========================== == ================ == Proprietor, ThoughtWing Software ========== == Independent Software Development Consultant ====== == Nick.Roberts@dial.pipex.com ==== == Voicemail & Fax +44 181-405 1124 === == == == I live not in myself, but I become == === Portion of that around me; and to me == ==== High mountains are a feeling, but the hum == ======= Of human cities torture. =========== -- Byron [Childe Harold]