Enter your email address & Win:

System Software Lab Programs ( Lex and Yaac Programs ) 6a

// June 14th, 2009 // Educational, Engineering, Unix and System Software Lab // Written by

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

………………………………………………………………………………………………………………………….
PART – A

………………………………………………………………………………………………………………………….

6) Program to recognize the grammar (anb, n>= 10).

6.l

/* 6.l */
%{
#include<stdio.h>
#include “y.tab.h”
%}
%%
[aA] return A;
[bB] return B;
.|\n return yytext[0];
%%

—————————————–

6.y

/* 6.y */
%{
#include<stdio.h>
%}
%token A B
%%
stmt: S ‘\n’ {printf(“\nValid expression”);exit(1);}
;
S: X B
X: X A | A A A A A A A A A A
%%
main()
{
printf(“\nEnter the expression: “);
if(yyparse())
{
printf(“\nValid expression”);
exit(0);
}
}
int yyerror()
{
printf(“\nInvalid expression\n”);
return 1;
}

int yywrap()
{
return 1;
}

If you enjoyed this post, make sure you subscribe to my RSS feed!

  • http://www.tecworld.co.cc/ RAVi

    can't we download them?

Get Adobe Flash playerPlugin by wpburn.com wordpress themes