Re: Parsing a language with optional spaces

Maury Markowitz <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
> On Jul 6, 2020, at 3:23 PM, Akim Demaille <[email protected]> wrote:
> 
> FOR/{sp}{id}{sp}={sp}{num}{sp}TO{sp}{num}  { printf("for: %s\n", yytext); }

This is a very different style than what I have seen in the past. In the past, most examples of flex tend to match against the tokens as individual items and return immediately so that bison can do the grammar check and generation. So in my existing (semi-working) .l, I followed this style and produced:

    FOR	{ return FOR; }
    ...
    TO	{ return TO; }

Then over in my .y I have:

    FOR variable '=' expression TO expression

Using your method, what would the associated bison look like? Just a single item matching the entire line?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.