Array Accepter Flex and Bison

Array.Y

%{
    #include <stdio.h>
        void yyerror(char*msg);    
%}
%token ARRAY NEW INT SBO SBC EQU ID NUM SEMI
%%
S:Statement {printf(“Accepted”);}       
                                                          
Statement:INT SBO SBC ID EQU NEW INT SBO NUM SBC SEMI

%%
void yyerror(char *msg)
{       
        {printf(“\n  Wrong”);}    
}
int main(void)
{
    yyparse();
        return 0;
}
Array.Flex
%{
    #include “array.tab.h”
    #include<stdlib.h>
%}
%%
[ \t\n] ;  
“[” {return SBO; }
“]” {return SBC; }
“=” {return EQU; }
“new” {return NEW;}
“int” {return INT;}
“;” {return SEMI;}
[0-9]+  {yylval=*yytext;return NUM;}
[a-zA-Z]+ {yylval=*yytext;return ID;}
.
%%
int yywrap(void)
{
  return 1;
}

Advertisements

One thought on “Array Accepter Flex and Bison

  1. An interesting discussion is worth comment. There’s no doubt that that you need to publish
    more on this subject, it may not be a taboo matter but typically folks don’t discuss
    such subjects. To the next! Best wishes!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s