Related articles |
---|
[2 earlier articles] |
Re: Languages with optional spaces drikosev@gmail.com (Ev. Drikos) (2020-02-23) |
Re: Languages with optional spaces maury.markowitz@gmail.com (Maury Markowitz) (2020-02-25) |
Re: Languages with optional spaces maury.markowitz@gmail.com (Maury Markowitz) (2020-02-25) |
Re: Languages with optional spaces martin@gkc.org.uk (Martin Ward) (2020-02-25) |
Re: Languages with optional spaces 493-878-3164@kylheku.com (Kaz Kylheku) (2020-02-26) |
Re: Languages with optional spaces awanderin@gmail.com (awanderin) (2020-02-26) |
Re: Languages with optional spaces drikosev@gmail.com (Ev. Drikos) (2020-02-28) |
Re: Languages with optional spaces christopher.f.clark@compiler-resources.com (Christopher F Clark) (2020-02-29) |
Re: Languages with optional spaces drikosev@gmail.com (Ev. Drikos) (2020-02-29) |
Re: Languages with optional spaces DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2020-03-01) |
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) |
[6 later articles] |
From: | "Ev. Drikos" <drikosev@gmail.com> |
Newsgroups: | comp.compilers |
Date: | Fri, 28 Feb 2020 13:34:40 +0200 |
Organization: | Aioe.org NNTP Server |
References: | 20-02-015 20-02-017 20-02-020 |
Injection-Info: | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="99116"; mail-complaints-to="abuse@iecc.com" |
Keywords: | lex, Basic |
Posted-Date: | 28 Feb 2020 12:28:09 EST |
Content-Language: | en-US |
On 25/02/2020 19:00, Martin Ward wrote:
> ...So any statement either starts
> with a keyword (a control character), which determines
> the statement type, or it is an assignment with the LET
> keyword omitted...
A scanner generator that supports ie "difference" operators can build a
DFA that splits ie the text FORI to FOR & I without space overhead, if
the reserved keywords are also tokens of the lexer.
The lexical rules below result ie to a DFA with 10 states. Even if I
erase the difference operator "-=" till the end of the document, the
DFA built still has 10 states but the text FORI is returned as an "id".
So, the rules below ensure that an "id" doesn't start with FOR or PRINT,
not sure though if this is what the OP really wanted once he said that
in theory FORI could be a variable (perhaps it can't be just an LHS?).
Ev. Drikos
-----------------------------------------------------------------------
token ::=
FOR
| PRINT
| id
FOR ::=
F O R
PRINT ::=
P R I N T
id ::=
{A..Z [{$|A .. Z|0 .. 9}...]} -= {key[{$|A .. Z|0..9}...]}
key ::=
FOR
| PRINT
Return to the
comp.compilers page.
Search the
comp.compilers archives again.