Re: Languages with optional spaces

Gene <gene.ressler@gmail.com>
Tue, 14 Apr 2020 10:08:31 -0700 (PDT)

          From comp.compilers

Related articles
[12 earlier articles]
Re: Languages with optional spaces christopher.f.clark@compiler-resources.com (Christopher F Clark) (2020-03-01)
Re: Languages with optional spaces drikosev@gmail.com (Ev. Drikos) (2020-03-01)
Re: Languages with optional spaces christopher.f.clark@compiler-resources.com (Christopher F Clark) (2020-03-02)
Re: Languages with optional spaces drikosev@gmail.com (Ev. Drikos) (2020-03-02)
Re: Languages with optional spaces gah4@u.washington.edu (2020-03-02)
Re: Languages with optional spaces drikosev@gmail.com (Ev. Drikos) (2020-03-12)
Re: Languages with optional spaces gene.ressler@gmail.com (Gene) (2020-04-14)
Re: Languages with optional spaces mertesthomas@gmail.com (2020-04-19)
Re: Languages with optional spaces aston.goldsmith@gmail.com (2020-05-05)
| List of all articles for this month |

From: Gene <gene.ressler@gmail.com>
Newsgroups: comp.compilers
Date: Tue, 14 Apr 2020 10:08:31 -0700 (PDT)
Organization: Compilers Central
References: 20-02-015
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="1286"; mail-complaints-to="abuse@iecc.com"
Keywords: lex, parse
Posted-Date: 14 Apr 2020 16:18:15 EDT
In-Reply-To: 20-02-015

On Wednesday, February 19, 2020 at 11:24:02 AM UTC-5, Maury Markowitz wrote:
> I'm trying to write a lex/yacc (flex/bison) interpreter for classic BASICs
> like the original DEC/MS, HP/DG etc. ...
>
> The problem is that FORI part. Some BASICs allow variable names with more than
> two characters, so in theory, FORI could be a variable. ...


> Is there a canonical cure for this sort of problem that isn't worse than the
> disease?


Flex regexes alone don't have enough power. But you could add a conditional
REJECT when a normal ID match has a prefix that's a keyword. (This could be
made fast with a trie of that's an issue.) REJECT causes fallback to the "next
best" rule, which seems to be what you want.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.