Path: csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: "Ev. Drikos" Newsgroups: comp.compilers Subject: Re: Languages with optional spaces Date: Mon, 2 Mar 2020 20:04:56 +0200 Organization: Aioe.org NNTP Server Lines: 43 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <20-03-006@comp.compilers> References: <20-02-015@comp.compilers> <20-02-033@comp.compilers> <20-02-034@comp.compilers> <20-03-003@comp.compilers> <20-03-005@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="30038"; mail-complaints-to="abuse@iecc.com" Keywords: lex, syntax Posted-Date: 02 Mar 2020 18:19:09 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Content-Language: en-US Xref: csiph.com comp.compilers:2477 On 02/03/2020 08:33, Christopher F Clark wrote: > ... > > As far as I can tell (and I haven't thought seriously about BASIC for > years), there are roughly two cases. > Neither I have thought seriously about any BASIC Dialect so far. The example grammar in my previous message took me less than half an hour. > 1) We have already identified the lower bound in "lower bound TO upper > bound". This can happen if we saw a number, or maybe an identifier > without the word "TO" in it (followed by a space?). This will not be > true, if we just saw an operator such as "+" as we will be expecting > another identifier to continue the expression... One is supposed to progressively add syntax as needed. I just found such a case at www.gkc.org.uk/martin/software/UK101-tapes.zip: 5120 FOR J=K+1TON4:A(K,J)=A(K,J)/P:NEXT J:I=1 Here is a more complete rule that parses ie "512 FOR J=LOWER+1TOUPPER" ::= ~: | | | -: { } | | IMHO, the most difficult problems come with statements like "NEXT i,j" that imply a shared end statement of two FOR loops and BASIC doesn't seem to be as easy as Fortran where this problem has a simple solution: https://github.com/drikosev/Fortran/blob/master/OMP_Legacy_Parser.txt > ... > So, what would I do? I would do it in 3 parts. A lexer, a "fixer", > and a parser... So, the suggestion is a fixer between the parser and the lexer. Ok, I appreciate your opinion. Ev. Drikos