11. Program in YACC to recognize the language (a^n b , n>=10). (output to say input is valid or not)
Program in YACC to recognize the language (a^n b , n>=10). (output to say input is valid or not) File Name : pr12.y /* program to check whether the given string is a part of the language a^n b or not */ /* Shows nothing if string is a part of language */ /* shows a message if string is not a part of language */ %{ # include<stdio.h> int yylex ( void ); int yyerror ( char *); %} %token A B //tokens : the alphabets of language 'a' and 'b' %% //production rules for grammar expr: s B ; s : s A | A ; %% int main () { printf( "Enter the string \n" ); yyparse(); return 0 ; } int yyerror ( char *s) { printf( "Invalid: Not a part of the language - a^n b \n" ); } File Name : pr12.l %{ # include "y.tab.h" extern int yylval; %} A [a] B [b] %% {A} {yylval=yytext[ 0 ]; return A;} {B} {yylval=yytext[ 1 ]; return B;} \ n { return 0 ;} . { return yytext[ 0 ];} %% // Output of the Above...