Re: Languages with optional spaces

"Ev. Drikos" <drikosev@gmail.com>
Mon, 2 Mar 2020 20:04:56 +0200

          From comp.compilers

Related articles
[9 earlier articles]
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)
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: "Ev. Drikos" <drikosev@gmail.com>
Newsgroups: comp.compilers
Date: Mon, 2 Mar 2020 20:04:56 +0200
Organization: Aioe.org NNTP Server
References: 20-02-015 20-02-033 20-02-034 20-03-003 20-03-005
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
Content-Language: en-US

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"


<lbound> ::=
                        <lbound> <rel-op> <lbound> ~: <rel-op>
            | <lbound> <add-op> <lbound>
            | <lbound> <mult-op> <lbound>
            | <add-op> <lbound> -: { <mult-op> }
            | <number>
            | <id-p>


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


Post a followup to this message

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