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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1f96acbbf1e7e66a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!news-east.rr.com!news-feed-01.rdc-kc.rr.com!news.rr.com!cyclone2.kc.rr.com!news2.kc.rr.com!tornado.socal.rr.com.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada Subject: Re: lexical ambiguity References: <1nozvv83n7lhc.1b3qf0olmyllp$.dlg@40tude.net> From: Keith Thompson Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:nvI9pHclmkvQcF+8DhEBX0ZayHc= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 02 Jun 2006 23:27:04 GMT NNTP-Posting-Host: 66.75.136.120 X-Complaints-To: abuse@rr.com X-Trace: tornado.socal.rr.com 1149290824 66.75.136.120 (Fri, 02 Jun 2006 16:27:04 PDT) NNTP-Posting-Date: Fri, 02 Jun 2006 16:27:04 PDT Organization: Road Runner High Speed Online http://www.rr.com Xref: g2news2.google.com comp.lang.ada:4657 Date: 2006-06-02T23:27:04+00:00 List-Id: bla_bla1357 writes: > I'm doing a lexical analysis of Ada using Lex as part of a student project. > The highlight is on using Lex, not on the programming language of Ada and > I'm not farmilliar with using Ada. So what I woulkd like to find out is if > there is any lexical ambiguity in Ada (like the ambiguity in C with the > unary and binary plus and minus). Thanks in advance... I suppose it depends on what you mean by "lexical ambiguity". Strictly speaking, there are no grammatical ambiguities in either language. There are plenty of things that look like ambiguities, but they're all resolved by the rules of the language. In C, for example, this: x+++++y looks like it could be parsed as x ++ + ++ y which would be a legal expression, but in fact it's tokenized as x ++ ++ + y which results in a syntax error. (C's typedef names do cause some interesting lexical problems, but that's another topic.) Ada, like, C, has unary and binary "+" and "-" operators, but each operator is easily identified based on the syntactic context in which it appears. One well-known case of a near ambiguity is: Character'('x') If Ada followed C's "maximal munch" rule, this would be tokenized as Character '(' x '... leading to a syntax error; instead, it's tokenized as: Character ' ( 'x' ) So, there are no real ambiguities in either language, but each uses different rules to resolve things that would otherwise have been ambiguous. -- Keith Thompson (The_Other_Keith) kst-u@mib.org San Diego Supercomputer Center <*> We must do something. This is something. Therefore, we must do this.