Sharecodepoint App Download Qrcode Sharecodepoint Android App Banner
Now You can search anything in sharecodepoint using your voice. Click on mic button. Sharecodepoint Voice Sharecodepoint Youtube Channel



Sharecodepoint popular queries
Search results for lex part
Showing posts with label lex part. Show all posts

Saturday, 23 February 2019

Program to recognize strings ‘aaab’, ‘abbb’, ‘ab’ and ‘a’ using grammar (an b n , n>=0) . | Compiler Design Lab Programs | Yacc Programs

Yacc Part : %token A B NL %% stmt : s NL { printf(“Valid String\n”); exit(0) ;}  ; s : A s B  |  ; %% int yyerror(...

Yacc Part :

%token A B NL
%%
stmt : s NL { printf(“Valid String\n”); exit(0) ;}
 ;
s : A s B
 |
 ;
%%
int yyerror(char *msg)
{
 printf(“Invalid String\n”);
 exit(0);
}
main ()
{
 printf(“Enter the String\n”);
 yyparse();
}


Lex Part :

%{
 #include “y.tab.h”
%}
%%
[aA] { return A; }
[bB] { return B; }
\n { return NL ;}
. { return yytext[0]; }
%%

 

Version 23.2.3.4 - 2016 - 2019 - © Sharecodepoint | Made in India. | Copyright Content