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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a9bab26b6fe54a36 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!v8g2000yqb.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: Pondering what rationale behind record type Date: Wed, 18 May 2011 15:55:03 -0700 (PDT) Organization: http://groups.google.com Message-ID: <8992c749-fae9-44cb-be6e-d3f8a592ee1a@v8g2000yqb.googlegroups.com> References: <90148303-4dc4-4c05-882f-88dd69a95494@z13g2000prk.googlegroups.com> <92quueFnsfU1@mid.individual.net> <4dc864b9$0$6890$9b4e6d93@newsspool2.arcor-online.net> <4dc90f7a$0$7659$9b4e6d93@newsspool1.arcor-online.net> <11dlfbvj00hru$.7zkw6im0a7gj$.dlg@40tude.net> <4dc92d14$0$6776$9b4e6d93@newsspool3.arcor-online.net> <14o3gst7h97px$.g6k9bn5b3p4q$.dlg@40tude.net> <9543fcbd-9035-45d3-8a5b-45592f927685@w10g2000yqa.googlegroups.com> NNTP-Posting-Host: 24.230.151.194 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1305759303 2490 127.0.0.1 (18 May 2011 22:55:03 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 18 May 2011 22:55:03 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v8g2000yqb.googlegroups.com; posting-host=24.230.151.194; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:20279 Date: 2011-05-18T15:55:03-07:00 List-Id: On May 11, 2:32=A0am, "Dmitry A. Kazakov" wrote: > On Tue, 10 May 2011 19:28:16 -0700 (PDT), Shark8 wrote: > > On May 10, 7:50=A0am, "Dmitry A. Kazakov" > > wrote: > > >> What is the reason to name statements? > > > Simple: to aid in readability. > > I have a few rather deeply nested items where I'm tokenizing > > PostScript > > (due the rules of the language) and it is handy to have things like > > -- Case C, When C '<' =3D> > > Read_Character( C, Input ); > > HANDLE_LT: -- less than > > if C =3D '<' then > > =A0Return Dictionary_Type; > > elsif C =3D '~' then > > =A0Return String_Type; > > else > > =A0Unread_Character( C, Input ); > > =A0Return -- I forgot what the last case, just '<', was... > > end if HANDLE_LT; > > The above should have been a "case", or better matching the input against= a > token table with semantic callbacks doing things. > > > There's even a few in blocks where I handle things like > > names ['identifiers'] vs. numbers; the PLRM defines a name > > as a string of "regular characters which cannot be interpreted > > as a string." This means that 23E4 is a number while 24F4 is > > a name as are $4, 2i3, @, 2^4 and so forth. > > That is semantic analysis to me. No need to burden parser with that. You > parse 23E4 as a token and later interpret it as an identifier or number. True, it is semantic analysis. The way I have it set up is this case structure is inside my tokenizer; the tokenizer may or may not be on the same machine as the parser itself. One of the reasons that I'm forced to use if-statements in the cases for the various constructs is because some of them are dependent on state: Strings, for example are delimited with parentheses, BUT may contain balanced pairs or be escaped out. So, (Here we are (nowhere).) is equal to the Ada String "Here we are (nowhere)." A quick/easy "go to the next closing paren" will produce incorrect results, just as it would in the string (:/)) which is equal the Ada String ":)". Finally, the case I was writing from memory, the [first] less-than can be: 1 - The first part of the "<<", a Dictionary, which is self- delimiting. 2 - The first part of the "<~", which is a Hex-encoded String (IIRC). 3 - I still can't remember what just '<' was... > > It REALLY does help in sorting where you are in the decoding. > > I don't think that large "if"s is a good style. No names may help that. > BTW, in your case "then", "else", "elsif" must carry the name of the "if" > they belong. I don't either; but the PLRM does describe the parser as consuming the characters/tokens from the input and then producing the proper object*. Also, I want to have the ability to have the parser a separate component, likely a server on a remote-machine handling multiple clients, and that imposes its own constraints as well. * Not as in OOP-Object, but as in component... though you could use OOP.