Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22006

flex parse - not parsing

$
0
0

Let's assume I have this rules for my grammar :

Check complete code at bottom

Both works, is there any way I can check for both like creating a S3 {S1}|{S2}. This doesn't work.

Currently my whole code :

%{
  extern int yylex();
%}
%option noyywrap

WS  [ \t\n]+
ID    [a-z]
S1      "."{ID}+
S2    {ID}+

%%

{S1} {printf("s1 : %s\n",yytext);}
{S2} {printf("s2 : %s\n",yytext);}


%%
int main(int, char**) {
  while (yylex());
}

CMD:

fsd
s2 : fsd

.sdf
s1 : .sdf

I have tried different s3, like : {S3} {S1|S2},{S3} {S1}|{S2},{S3} S1|S2,S3 S1|S2 nothing seems to work


Viewing all articles
Browse latest Browse all 22006

Trending Articles