2023 2024 Student Forum > Management Forum > Main Forum

 
  #1  
16th November 2016, 05:39 PM
Unregistered
Guest
 
LEX Lab Programs-VTU

Hii sir, I wants to get the LEX Lab Programs of the Visvesvaraya Technological University will you Please provide me the list of the LEX Lab Programs of the Visvesvaraya Technological University ?
Similar Threads
Thread
MBA MPA Programs
MBA Programs Org
MBA Programs
Different MBA Programs
Top MBA Programs
NYS MBA Programs
MBA MSA Programs
MBA Programs in IIM
MBA JD Programs
MD MBA Programs
GWU MBA Programs
Best Psy.D Programs in the US
Best MBA programs in US
UHD MBA Programs
MBA Programs RI MBA Programs Rhode Island
MBA MHA Programs In PA
MS Programs in US
CT MBA Programs
NJ MBA Programs
DPT Programs PA
  #2  
16th November 2016, 05:49 PM
Super Moderator
 
Join Date: Mar 2013
Re: LEX Lab Programs-VTU

As you Asking for the LEX Lab Programs of the Visvesvaraya Technological University the Programmes of the LEX Lab of the VTU University is given below


LEX PROGRAMS ::
1a.l
%{
int lines=0,words=0,chars=0,blanks=0;
%}
%%
[\t] blanks++;
[\n] lines++;
[^ \t\n]+ {words++;chars+=yyleng;}
%%
yywrap()
{
printf("charcter=%d,lines=%d,blanks=%d,words=%d\n" ,chars,lines,blanks,words);
}
int main(int argc,char*argv[])
{
yyin=fopen(argv[1],"r");
yylex();
return 0;
}

1b.l
%{
int comment=0;
%}

%%
[/*].*[*/] {comment++;}
.echo ;
%%

int yywrap()
{
return 1;
}

main(int argc,char**argv)
{
yyin=fopen(argv[1],"r");
yyout=fopen(argv[2],"w");
yylex();
printf("no of comment lines %d\n",comment);
}
---------------------------------------------------------------------------------
2a.l
%{
#include<stdio.h>
int nplus=0,nminus=0,nmul=0,ndiv=0,id=0,flag1=0,flag2= 0;
%}
%%
[(] {flag1++;}
[)] {flag1--;}
[a-zA-Z0-9]+ {flag2++;id++;}
[+] {flag2--;nplus++;}
[-] {flag2--;nminus++;}[*] {flag2--;nmul++;}
[/] {flag2--;ndiv++;}
%%
main()
{
printf("\nenter a valid arithematic expression\n");
yylex();
if(flag1!=0||flag2!=1)
printf("invalid expression");
else
{
printf("\nValid expression\n");
printf("addition(+)=%d\n",nplus);
printf("subtraction(-)=%d\n",nminus);
printf("multiplication(*)=%d\n",nmul);
printf("division(/)=%d\n",ndiv);
printf("\nIDENTIFIER=%d\n",id);
}
}
2b.l
%{
int valid;
%}
%%
[a-zA-Z][ ](and|but|or)[ ][a-zA-Z] { valid=1; }
.|[\n] ;
%%
main()
{
printf("\nEnter the sentence ");
yylex();
if(valid)
{
printf("\nStatement is compound!\n");
}
else
{
printf("\nStatement is simple!\n");
}
}
------------------------------------------------------------------------------------
3.l
%{
#include<stdio.h>
int count=0,flag=0;
%}

%%
"int "|"float"|"char"|"long" {flag=1;}
","|","|";" {if(flag) count++;}
%%
int main(int arg,char*argv[])
{
yyin=fopen(argv[1],"r");
yylex();
printf("No of identifiers=%d\n",count);
}


LEX AND YACC PROGRAMS::
4a.l
%{
#include"y.tab.h"
%}
%%
[0-9]+ return NUMBER;
[a-zA-Z] return ID;
[\t];
[\n];
. return yytext[0];
%%

4a.y
%{
#include<stdio.h>
#include<stdlib.h>
%}
%token NUMBER ID
%left '+''-'
%left '*''/'
%left '('')'
%%
e:e'+'e|e'-'e|e'*'e|e'/'e|'('e')'|NUMBER|ID;
%%
main()
{
printf("Enter the expression\n");
yyparse();
printf("valid expression\n");
}
yyerror()
{
printf("invalid expression\n");
exit(0);
}
-------------------------------------------------------------------
4b.l
%{
#include"y.tab.h"
%}
%%
[a-zA-Z] return ALPHA;
[0-9] return DIGIT;
[\t];
[\n];
. return yytext[0];
%%
4b.y
%{
#include<stdio.h>
#include<stdlib.h>
%}

%token ALPHA DIGIT
%%
e:ALPHA|e DIGIT|e ALPHA;
%%

main()
{
printf("Enter the expression\n");
yyparse();
printf("valid expression\n");
}
yyerror()
{
printf("invalid expression\n");
exit(0);
}
--------------------------------------------------------------
5a.l
%{
#include"y.tab.h"
int yylval;
%}

%%
[0-9]+ yylval=atoi(yytext); return NUM;
[\t];
[\n]
. return yytext[0];
%%
5a.y
%{
#include<ctype.h>
#include<stdio.h>
%}
%token NUM
%left '+''-'
%left '*''/'

%%
exp:e {printf("Value of the expression is %d\n",$1);}
e:e'+'e {$$=$1+$3;}
e:e'-'e {$$=$1-$3;}
e:e'*'e {$$=$1*$3;}
e:e'/'e {if($3==0) printf("Invalid\n"); $$=$1/$3;}
e:NUM {$$=$1;}
e:'-'e {$$=-$2;}
%%

main()
{
printf("Enter the expression\n");
yyparse();
printf("valid expression\n");
}
yyerror()
{
printf("invalid expression\n");
exit(0);
}
---------------------------------------------------------------------
5b.l
%{
#include"y.tab.h"
%}

%%
a return A;
b return B;
[\t];
[\n];
. return yytext[0];
%%

For Any Queries you may contact to the VTU university the contact details Are given below

Contact details :
VTU university
Address: Jnana Sangama, VTU Main Road, Machhe, Belagavi, Karnataka 590018
Phone: 0831 249 8196


Quick Reply
Your Username: Click here to log in

Message:
Options

Thread Tools Search this Thread



All times are GMT +5. The time now is 03:21 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
SEO by vBSEO 3.6.0 PL2

1 2 3 4