Re: simple problem

Hans Åberg <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
> On 23 Feb 2019, at 23:19, [email protected] <[email protected]> wrote:
> 
> Hi again, i have the following code:

Here is a slightly different code, for example with input "x1 y2 34 ? exit". The lexer will rescan unless there is an action return, which happens for "exit". Typically in a lexer, whitespace is eaten, dividing up the tokens.

Otherwise, Flex has a mailing list, cf.
  https://en.wikipedia.org/wiki/Flex_(lexical_analyser_generator)
The manual is good, too.

Also, there is the Usenet newsgroup comp.compilers for general questions about parsing, mostly advanced.

--
%{
#include <stdio.h>
#include <stdlib.h>
%}

%option noyywrap

identifier  [[:alpha:]][[:alnum:]]*
integer     [[:digit:]]+

%%

[ \f\r\t\v\n]+  { /* eat whitespace */ }
"exit"          { printf("Exit!\n"); return 0; }
{identifier}    { printf("%s is an identifer\n", yytext); }
{integer}       { printf("%s is an integer\n", yytext); }
.               { printf("/* %s: do nothing*/\n", yytext); }

%%

int main(int argc, char **argv)
{

    printf("Start\n");
    yylex();
    printf("End\n");

    return(0);
}
--



_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison
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.