Path: csiph.com!xmission!news.alt.net!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.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: Sun, 1 Mar 2020 19:41:49 +0200 Organization: Aioe.org NNTP Server Lines: 173 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <20-03-003@comp.compilers> References: <20-02-015@comp.compilers> <20-02-017@comp.compilers> <20-02-033@comp.compilers> <20-02-034@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="54570"; mail-complaints-to="abuse@iecc.com" Keywords: lex Posted-Date: 01 Mar 2020 12:52:57 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:2474 On 29/02/2020 21:38, Ev. Drikos wrote: > On 29/02/2020 11:48, Christopher F Clark wrote: > ... > Obviously, those who coded such BASIC parsers had some simpler rules, > ie the position of the first 'TO' might be used for the statement 50. > Dear Mr. Clark, I'll elaborate a little if you don't mind. IMHO, one problem here is that an identifier before a keyword is quite difficult for a scanner. One could possibly let the parser recognize such obscure identifiers. Let's assume that the first 'TO' found in a for-statement after a '=' is the keyword that separates the lower bound from the upper bound of the loop index. As a demo example, the simplified grammar at the end of this message fails to parse only the last statement (999) below, which looks like a known limitation of my Simulator. An actually generated C++ parser would need some time and effort that currently I don't plan to spend: 10 let i=1 11 letleti=1 20 i=1 30 for forj=1 to n 40 FORFORJ=1TON 50 FOR N = ITOJTOK 60 FORFORJ=IIITONTOJ 70 FORFORJ=TO TO TO 80 FORFORJ=TTTON 999 FORFORJ=TOTON Of course, this is far away from a working solution because one needs to know a lot of details, ie if any spaces read are indeed important. What would you suggest apart a hand coded lexer? Ev. Drikos ---------------------------------------------------------------------- SYNTAX RULES ---------------------------------------------------------------------- #sma #sma #sma TO ::= ::= | ::= | | ::=