help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Very basic question about Flex


From: address@hidden
Subject: Very basic question about Flex
Date: Fri, 22 Feb 2019 15:00:51 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1

Hi everyone,

i've started to read the lex and yacc book and the bison and flex book. now in the first example they have the following code:

%{
/**
 * First example program for flex
 *
 */
%}

%%

is |
am |
are |
where |
was |
be |
being |
been |
do |
does |
did |
should |
can |
could |
has |
have |
had |
go { printf("%s is a verb\n", yytext); }

[a-zA-Z]+ { printf("%s is not a verb", yytext); }

.|\n { ECHO; /* normal default anyway */ }

%%

int main(int argc, char **argv)
{
    yylex();
}

Now my question is when i enter one of the verbs it's working normaly like expected, but when i enter for example 234someword i also get the messsage %s is not a verb but i've no rule saying that, i've only [a-zA-Z]+ to catch this situation, why does he also react on word that begin with a number ??


best regards!






reply via email to

[Prev in Thread] Current Thread [Next in Thread]