Unix & CD Lab Manual - III B.tech.-27!01!2075
Unix & CD Lab Manual - III B.tech.-27!01!2075
2016-2017
S.No. Contents
a) Practice the following commands in UNIX environment
(i) File Handling Utilities (ii) Disk Utilities
b) Practice the given commands in UNIX environment
T1.
(i) Security by File Permissions (iii) Process Utilities
c) Demonstrate all Text Processing Utilities in UNIX.
d) Practice Stream editor commands.
a) Write a shell script to print the sum of even numbers from given n
numbers.
b) Write a shell script that accepts a file name as argument and display
T2. specified number of lines from the beginning of file.
c) Write a shell script that takes an argument and checks if argument
supplied is a file or a directory and reports accordingly. If the
argument is a directory, display the contents of directory.
T3. b) Write an awk script to count the number of lines in a file that do
not contain vowels.
c) Write an awk script to find the number of characters, words and
lines in a file.
Ex: ls> f1
T5. a) Write a C program to create a child process and allow the parent to
T11. Implement intermediate code generation and code generation for a given
expression.
a) LEX Program to count the number of lines, words and letters, capital
letters, small letters and digits in a file.
T12.
b) Function usage in LEX program.
c) Design a simple arithmetic calculator: USE LEX and YACC.
Case Study: Implement parsing techniques for a given grammar and show
DFA.
Task1:
Options:
Syntax: $touch [options] filename
a)-c:$ is printed at the end of each line,this option should be used with ‘-’.
Syntax:$cat -c -v filename
Example:$cat -c -v test
OUTPUT:Hello GRIET$
2)$touch: To create more than one file at a time with zero bytes.
Syntax:$touch file1 file2 file3 …. filen
Example:$touch f1 f2 f3…fn
Options:
Syntax:$touch [options] filename
Options:
a)-f:Force move by overwriting destination file without prompt.
Syntax:$mv -f source destination
Example: $mv -f main.c main.txt
Options:
a)-f: ignores non existing files, never prompt
Syntax: $rm -f filename
Example: $rm -f myfile.txt
OUTPUT:Removes file myfile.txt
1.$du:
Output: 4 rf.c
2. $df:
It reports the amount of free space available for each file system separately i.e;
estimate the free space.
3. $mount:
It is used to attach all file systems available in same device to the tree structure.
Options:
Output:Linux.
-a: mounts all file system that are listed in a configuration file
4. $umount/$unmount:
This command is used for detaching a file system from unix tree structure.
Syntax: $unmount[option]<directory/path>
Options:
Example:$umount –r /usr/local
1.$chmod:
ls –l student.list
$ls –l student1.list
2.$umask:
The default permissions may be altered by super user.The default permissions are
transformed by subtracting the user mask from it to remove one or more permissions.
Output: This becomes 644 (666-022) for ordinary file and 755(777-022) for
directories.
ii).PROCESS UTILITES:
1.$ps(Process Status):
Syntax: $ps
Example: $ps
643 02 10:31:00 ps
Options:
Example: $ps –f
Output:
Example: $ps –a
2.$kill:
This command is used to kill the process i.e; stop or terminate a process.(by
administrator)Syntax: $kill <pid>
1.$grep: Used to search,select and Print Specified records or lines from an input files.
Syntax:$grep [options] pattern [filename1][filename2]………..
Eg:$cat >st.list
1 XXX 123
2 XYZ 234
3 ZZZ 345
Options:
ii)-v(deleting lines):This selects all lines except those containing the pattern.
3 ZZZ 345
Output:1
2.$tee: It handles a character stream by duplicating its input and it saves one copy in a file
and when others copy the output.
Ex:$who/tee user.txt
Options:
Eg:$tee –a foo.txt
Output: batch
$cat foo.txt
foo
batch
Syntax:$tee –I <filename>
3. $cmp:It makes a comparison of each byte of two files and terminates the moment it
encounters difference.
Good Morning
$cat >same1
Good Night
Welcome
to USP&CD lab
Options:
Output: 1 155 40
2 145 156
3 40 141
Output: 1 155 40
2 145 156
3 40 141
4. $comm:It compares the files line by line and displays the common and differing lines.
Syntax:$comm <file1><file2>
Agra Banglore
Banglore Chennai
Chennai Delhi
Mysore Mysore
Agra
Banglore
Chennai
Delhi
Mysore
Output:
Banglore
Chennai
Delhi
Mysore
Output:
Agra
Banglore
Chennai
Mysore
Output:
Agra
Laxman 114
$diff f1 f2
Options:
<good Morning with line no.1 of second file then file can be
_______________ matched.
>good night
1 , 3c1 , 3
<Unix
<command
<if(a==b)
>
>
Options:
Syntax:$head –n <filename>
Eg:$head –n 3 file3
Syntax:$head –u <filename>
Jan
Feb
Mar
……
Oct
Output: Apple
Options:
Syntax:$tail -c <filename>
Eg:$tail -c -5 f1.txt
Output: Apple
Syntax:$tail –v <filename>
Eg:$tail –v f1.txt
Apple
Grape
$cat >sort1
computer
Computer
COMPUTER
123456
@#$%^
$sort sort1
Output:@#$%^
123456
Computer
Computer
COMPUTER
Options:
Eg:$cat >sort2
f*()
123
abc
)(*f
$sort –d sort2
Output: )(*f
f*()
123
Abc
Eg:$sort –m sort2
Output: &*()
123
abc
) (*&
12
33
45
Output:$sort –n abc
12
45
9.$tr:It translates or deletes character from standard input and writing into standard output
device.
Example:$tr a x
akshitha
Output:xkshithx
10.$cut:This command splits vertically.By using this command , required fields or columns
can be extracted from a file.
Example:$cat >s1.list
222?bbb?6?cse?28-sep-97
333?ccc?7?cse?14-feb-97
Options:
i)-c:$cut –c 3 -s1.list
1? aaa ? 5?cse?25-aug-96
2?bbb?6?cse?28-sep-97
3?ccc?7?cse?14-feb-97
$cat >bank.txt
AIM: Shell script that accepts a file name, starting and ending line numbers as
arguments and displays all the lines between the given line numbers.
Script:
if [ $# -le 2 ]
then
echo "insufficient arguments"
fi
if [ $2 -gt $3 ]
then
echo "arguments are not proper"
fi
x=`expr $3 - $2 + 1`
cat $1 | head -$3 | tail -$x
OUTPUT:
$sh p1.sh test 2 4
hello
hai
griet
$ cat test
welcome
hello
hai
griet
karuna
AIM: Shell script that receives any number of file names as arguments checks if every
argument supplied is a file or a directory
Script:
for x in $*
do
if [ -f $x ]
then
echo " $x is a file "
echo " no. of lines in the file $x are: "
wc -l $x
elif [ -d $x ]
then
echo " $x is a directory "
else
echo " enter valid filename or directory name "
fi
done
OUTPUT:
$cse$karuna$sh p4.sh
f1 is a file
no.of lines in the file f1 are : 4
f2 is a file
no.of lines in the file f2 are: 3
test is a file
no.of lines in the file test are: 5
gkr1 is a directory
3(b). Write an awk script to count the number of lines in a file that do not contain
vowels.
AIM: An awk script to find the number of lines in a file without vowels.
Script:
BEGIN{
printf "\t No. of lines in a given file "
FS= " "
}
#BODY
{
if($0 !~ /[aAeEiIoOuU]/)
{
nlines++;
}
}
END{
printf "\n Total no. of lines that do not contain vowels: %d\n",nlines}
OUTPUT:
$cat f1
hello
hai
my
sky
$awk –f pr8.awk f1
No. of lines in a given file :
Total no. of lines that do not contain vowels: 2
OUTPUT:
$cat f1
hello world
hai
my
sky
$awk –f pr9.awk f1
No. of lines, characters, words in a given file :
No.of lines : 5
No.of words: 19
Task 4:
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
void main()
{
int fd1,fd2,n=1;
char *buf;
fd1=open("f1",O_RDONLY);
fd2=open("f2",O_WRONLY|O_CREAT,S_IWUSR|S_IRUSR);
if((fd1== -1) || (fd2== -1))
printf("error");
else
{
while(n>0)
{
n=read(fd1,&buf,1);
write(fd2,&buf,1);
}
}
}
OUTPUT:
$ cat > f1
Welcome to Advanced UNIX programming lab
[3]+ Stopped cat >f1
$ gcc p10.c
$ ./a.out
$cat f1
Welcome to Advanced UNIX programming lab
$cat f2
Welcome to Advanced UNIX programming lab
Program:
#include<fcntl.h>
#include<stdlib.h>
#include<sys/stat.h>
#define BUFSIZE 1024
void main(int argc, char *argv[])
{
int fd1;
int n;
char buf[BUFSIZE];
fd1=open(argv[1],O_RDONLY);
while((n=read(fd1,buf,BUFSIZE))>0)
write(1,buf,n);
close(fd1);
}
OUTPUT:
$ gcc p11a.c
$ ./a.out f1 (given file name as argument)
Welcome to Advanced UNIX Programming lab
Program:
#include<fcntl.h>
#include<stdlib.h>
#include<dirent.h>
#include<stdio.h>
#define BUFSIZE 1024
void main(int argc, char *argv[])
{
DIR *dir;
struct dirent *direntry;
if((dir=opendir(argv[1]))==NULL)
exit(0);
while(direntry=readdir(dir))
printf("%s\n",direntry->d_name);
closedir(dir);
}
OUTPUT:
$ gcc p11b.c
$ ./a.out karuna (given directory name as argument)
.
..
f1
f2
gkr
4(c). Write a program that takes one or more file/directory names as command line
input and reports the following information on the file.
AIM: Program to display file type, no. of links, time of last access and rwx permissions.
Program:
#include<stdio.h>
#include<stdlib.h>
#include<sys/stat.h>
#define BUFSIZE 1024
int main(int argc, char *argv[])
{
int i=1;
struct stat statbuf;
while(i<argc)
{
if(lstat(argv[i],&statbuf) == -1)
exit(0);
printf("File name : %s\n",argv[i]);
printf("File type and permissions : %o\n",statbuf.st_mode);
printf("No.of links : %d\n",statbuf.st_nlink);
printf("Time of last access : %d\n",ctime(&statbuf.st_atime));
i++;
}
}
OUTPUT:
$ gcc p12.c
$ ./a.out f1 (given file name as argument)
File name: f1
File type and permissions : 100664
No. of links : 1
Time of last access : 5990208
Program:
#include<fcntl.h>
#include<stdlib.h>
#include<dirent.h>
#include<string.h>
#include<unistd.h>
#include<sys/stat.h>
#define BUFSIZE 1024
void main(int argc, char *argv[])
{
DIR *dir;
int fd1;
struct dirent *direntry;
fd1=open("f3.txt",O_WRONLY|O_CREAT);
printf("%d",fd1);
if((dir=opendir(argv[1]))==NULL)
exit(0);
else
{
while(direntry=readdir(dir))
{
write(fd1,direntry->d_name, strlen(direntry->d_name));
}
}
closedir(dir);
}
OUTPUT:
$ gcc p15.c
$ ./a.out karuna (given directory name as argument)
$cat f2.txt
f1
f2
gkr
Task 5:
Program:
# include<stdio.h>
#include<sys/types.h>
void main( )
{
pid_t pid;
pid=fork( );
if (pid<0)
{
printf("unable to create a process ");
}
else if(pid >0)
{
printf("Parent Process …");
printf("Process id : %d\t Its parent id : %d \n", getpid( ),getppid( ));
}
else
{
printf("Child Process …");
printf("Process id : %d\t Its parent id : %d \n", getpid( ),getppid( ));
}
}
OUTPUT:
$ gcc p16.c
$ ./a.out
Parent Process…..
Procee id: 2255 Its parent id: 2678
Child Process…..
Procee id: 2980 Its parent id: 2255
Program:
# include<stdio.h>
#include<sys/types.h>
void main( )
{
pid_t pid;
pid=fork( );
if (pid<0)
{
printf("unable to create a process ");
}
else if (pid==0)
{
printf("Child Process …");
printf("Process id : %d\t Its parent id : %d \n", getpid( ),getppid( ));
printf("Child Process terminated….");
}
else if(pid >0)
{
printf("Parent Process …");
for( ; ; );
}
}
OUTPUT:
$ gcc p17.c
$ ./a.out
Parent Process…..
Child Process…..
Procee id: 2980 Its parent id: 2255
Program:
# include<stdio.h>
#include<sys/types.h>
void main( )
{
pid_t pid;
pid=fork( );
if (pid<0)
{
printf("unable to create a process ");
}
else if(pid==0)
{
printf("Child Process …");
printf("Process id : %d\t Its parent id : %d \n", getpid( ),getppid( ));
sleep(30);
printf("Process id : %d\t Its parent id : %d \n", getpid( ),getppid( ));
}
else
{
printf("Parent Process …");
printf("Process id : %d\t Its parent id : %d \n", getpid( ),getppid( ));
}
}
OUTPUT:
$ gcc p18.c
$ ./a.out
Parent Process…..
Procee id: 2255 Its parent id: 2678
Child Process…..
Procee id: 2980 Its parent id: 2255
(after sleep…..)
$ Procee id: 2980 Its parent id: 1 (orphan process parent is init process & id is 1)
AIM: C program that illustrate suspending and resuming processes using signals.
Program:
#include<stdio.h>
#include<signal.h>
void alarmHandler(int);
void intHandler(int);
void main( )
{
signal(SIGINT,intHandler);
signal(SIGALRM,alarmHandler);
printf("alaram is set to 10 sec \n");
alarm(10);
printf("The process is paused for a while \n");
pause();
printf("The process is going to sleep \n");
sleep(10);
}
OUTPUT:
csedept@csedept-Lenovo-G570:~$ gcc p24.c
csedept@csedept-Lenovo-G570:~$ ./a.out
alaram is set to 10 sec
The process is paused for a while
^C interrupted signal is handled
The process is going to sleep
alarm signal is handled
Program:
#define FIFO1 "Fifo1"
#define FIFO2 "Fifo2"
#include<stdio.h>
#include<string.h>
#include<sys/types.h>
#include<fcntl.h>
#include<sys/stat.h>
void main( )
{
int childpid,wfd,rfd;
mknod(FIFO1,0666|S_IFIFO,0);
mknod(FIFO2,0666|S_IFIFO,0);
if (( childpid=fork())==-1)
{
printf("cannot fork");
}
else
if(childpid >0)
{
wfd=open(FIFO1,1);
rfd=open(FIFO2,0);
client(rfd,wfd);
while (wait((int *) 0 ) !=childpid);
close(rfd);
close(wfd);
unlink(FIFO1);
unlink(FIFO2);
}
else
{
rfd=open(FIFO1,0);
wfd=open(FIFO2,1);
server(rfd,wfd);
close(rfd);
close(wfd);
}
}
client(int readfd,int writefd)
OUTPUT:
$ gcc p20.c
enter file name: f1 (server writes data into file f1)
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main(void)
{
char *s=(char *)calloc(sizeof(char),20000);
char *t=(char *)calloc(sizeof(char),20000);
char key[32][20]={"auto","break","case","char","const","continue","default"
,"do","double","else","enum","extern","float","for","goto"
,"if","int","long","register","return","short","signed",
"sizeof","static","struct","switch","typedef","union"
,"unsigned","void","volatile","while"};
int i,j,k=0,c;
char f[20],ch;
FILE *fp;
//clrscr();
printf("enter a file: ");
scanf("%s",f);
fp=fopen(f,"r");
if(fp==NULL)
printf("file cannot be opened");
else
{
while((ch=fgetc(fp))!=EOF)
{
*(s+k)=ch;
k++;
}
*(s+k)='\0';
}
printf("%s\n",s);
printf("------------------------------------------------------\n");
i=0;
x:while(*(s+i)!='\0')
{
j=0;c=0;
if(*(s+i)=='#')
{
i++;
while(*(s+i)!='\n')
i++;
}
i=i+2;
}
printf("is a comment line\n");
}
else if(*(s+i)=='['||*(s+i)==']'||*(s+i)=='('||*(s+i)==')'||*(s+i)=='{'||*(s+i)=='}')
{
printf("%c is a special symbol\n",*(s+i));
i++;
}
else if(isdigit(*(s+i)))
{
if(isdigit(*(s+i))||*(s+i)=='.')
{
printf("%c",*(s+i));
i++;
while(isdigit(*(s+i))||*(s+i)=='.')
{
printf("%c",*(s+i));
i++;
#include<stdio.h>
#include<string.h>
void main()
{
char *s[20],temp;
char *a=(char *)calloc(sizeof(char),200);
char *t=(char *)calloc(sizeof(char),200);
int i=0,j=0,n,k=0,l=0,m=0,p=0;
printf("enter the no of productions: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
s[i]=(char *)calloc(sizeof(char),200);
printf("p%d:",i);
scanf("%s",s[i]);
}
printf("enter the string to derive: ");
scanf("%s",a);
printf("given productions\n");
for(i=0;i<n;i++)
{
printf("%s\n",s[i]);
}
i=0; j=0;
while(*(s[i]+j)!='>')
{
j++;
}
j++;
x:m=0;
while(*(s[i]+j)!='\0')
OUTPUT:
……TO VALIDATE A STRING USING BRUTEFORCE TECHNIQUE……
S->cAd
A->ab/a
enter the input string
cad
string is valid
if(E())
{
if(str[i]=='$')
{
printf("String accepted");
}
else
{
printf("error");
getch();
}
}
else
printf("invalid expression");
getch();
}
int E()
{
if(T())
{
if(E1())
return 1;
else
return 0;
}
else
return 0;
}
int E1()
{
if(str[i]=='+')
{
i++;
if(T())
{
if(E1())
return 1;
else
return 0;
}
int T()
{
if(F())
{
if(T1())
return 1;
else
return 0;
}
return 0;
}
int T1()
{
if(str[i]=='*')
{
i++;
if(F())
{
if(T1())
return 1;
else
return 0;
}
else
return 0;
}
return 1;
}
int F()
{
if(str[i]=='(')
{
i++;
if(E())
{
if(str[i]==')')
{
i++;
OUTPUT:
Enter the input string
a+b
Valid input string
Enter the input string
+b
Invalid
/*
OUTPUT:
E->TX
X->+TX
X-.>#
T->FY
Y->*FY
Y->#
FIRST SET
E {,i,(}
T {i, ( }
X {+,#}
Y { *.#}
F { i,(}
FOLLOW SET
E { $,)}
X { $,)}
T { +,$,)}
Y { +,$,)}
F { *,+,$,)}
b) follow of a given grammar.
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>
struct fir
{
int n;
char nt,first[5];
}fir[5];
struct fol
{
int n;
char nt,follow[5];
}fol[5];
int folp=0,n=6;
char p[6][10];
void main()
{
int i,j;
char b[6];
strcpy(p[0],"E->TX");
strcpy(p[1],"X->+TX");
strcpy(p[2],"T->FY");
strcpy(p[3],"Y->*FY");
strcpy(p[4],"F->(E)");
strcpy(p[5],"F->i");
strcpy(b,"EXTYF");
fir[0].nt='X';
fir[0].n=1;
strcpy(fir[0].first,"+");
fir[0].nt='Y';
fir[0].n=1;
strcpy(fir[0].first,"*");
for(i=0;i<5;i++)
{
findfollow(b[i],folp);
folp++;
}
strcpy(fol[0].follow,"$)");
strcpy(fol[1].follow,"$)");
strcpy(fol[2].follow,"+");
strcpy(fol[3].follow,"+");
strcpy(fol[4].follow,"*");
printf("follow sets are\n");
for(i=0;i<5;i++)
{
//printf("%c-> ",fol[i].nt);
for(j=0;fol[i].follow[j]!='\0';j++)
printf("%c,",fol[i].follow[j]);
FOLLOW SET
E { $,)}
X { $,)}
T { +,$,)}
Y { +,$,)}
F { *,+,$,)}
}
}
}
--------------------------------------------------------------
$ i+i$ shift:i
$i +i$ E->i
$E +i$ shift:+
$E+ i$ shift:i
$E+i $ E->i
$E+E $ E->E+E
$E $ accept
#include<string.h>
int i,ch,j,l,addr=100;
void main()
char ex1[5],ex2[5];
while(1)
scanf("%d",&ch);
switch(ch)
case 1:
scanf("%s",exp);
l=strlen(exp);
ex2[0]='\0';
i=0;
while(exp[i]!='=')
i++;
strncat(ex2,exp,i);
strrev(exp);
strncat(ex1,exp,l-(i+1));
strrev(ex1);
break;
case 2:
scanf("%s",ex);
strcpy(exp,ex);
l=strlen(exp);
exp1[0]='\0';
for(i=0;i<l;i++)
if(exp[i]=='+'||exp[i]=='-')
if(exp[i+2]=='/'||exp[i+2]=='*')
strrev(exp);
j=l-i-1;
strncat(exp1,exp,j);
strrev(exp1);
else
strncat(exp1,exp,i+2);
break;
else if(exp[i]=='/'||exp[i]=='*')
strncat(exp1,exp,i+2);
break;
break;
case 3:
scanf("%s%s%s",id1,op,id2);
if(((strcmp(op,"<")==0)||(strcmp(op,">")==0)||(strcmp(op,"<=")==0)||(strcmp(op,">=")==0)||
(strcmp(op,"==")==0)||(strcmp(op,"!=")==0))==0)
printf("Expression is error");
addr++;
printf("\n%d\t T:=0",addr);
addr++;
addr++;
printf("\n%d\t T:=1",addr);
break;
case 4:exit(0);
strrev(char* str)
int len,i,temp;
len=strlen(str)-1;
for(i=0;i<strlen(str)/2;i++)
temp=str[i];
str[len--]=temp;
return(str);
}
OUTPUT:
1.ASSIGNMENT
2.ARITHMETIC
3.RELATIONAL
4.EXIT
Enter the choice:1
1.ASSIGNMENT
2.ARITHMETIC
3.RELATIONAL
4.EXIT
Enter the choice:_
if(flag==0)
{
printf("\t%s\t\t\tMOV r%d,%c\n",st[i+1],regno1,st[i+1][0]);
break;
}
OUTPUT:
TO GENERATE OPTMIZED TARGET MACHINE CODE FOR AN INTERMEDIATE
CODE
Enter the no. of statements:2
Enter the statements:a=b+c
x=b+c
If the machine architecture is having the following format
OPERATIONS SOURCE TARGET
ADD var/reg var/reg :--> MOV b,r1 ,variable b contents are moved to register r1
Tstatements targetcode
a=b+c
MOV b,r1
ADD c,r1
MOV r1,a
x=b+c MOV r1,x
Task-12(a). LEX program to count the number of lines, words and letters, capital letters,
small letters and digits in a file.
Algorithm:
Read each character from the text file :
How to count the number of lines? we simply count the encounters of '\n'
<newline>character.
To count the number of words we count white spaces and tab character(of course,
newline characters too..)
Program:
%{
#include<stdio.h>
int lines=0, words=0,s_letters=0,c_letters=0, num=0, spl_char=0,total=0;
%}
%%
\n { lines++; words++;}
[\t ' '] words++;
[A-Z] c_letters++;
[a-z] s_letters++;
[0-9] num++;
. spl_char++;
%%
main(void)
{
yyin= fopen("myfile.txt","r");
yylex();
total=s_letters+c_letters+num+spl_char;
printf(" This File contains ...");
printf("\n\t%d lines", lines);
printf("\n\t%dwords",words);
printf("\n\t%d small letters", s_letters);
printf("\n\t%d capital letters",c_letters);
printf("\n\t%d digits", num);
printf("\n\t%d special characters",spl_char);
printf("\n\tIn total %d characters.\n",total);
}
Output:
Let the 'myfile.txt' contains this.
%{
#include
int op=0,i;
floata,b;
%}
dig [0-9]+|([0-9]*)"."([0-9]+)
add "+"
sub "-"
mul "*"
div "/"
pow "^"
ln \n
%%
{dig} {digi();} /*** digi() is a user defined function ***/
{add} {op=1;}
{sub} {op=2;}
{mul} {op=3;}
{div} {op=4;}
{pow} {op=5;}
{ln} {printf("\n the result :%f\n\n",a);}
%%
digi()
{
if(op==0)
a=atof(yytext); /*** atof() is used to convert the ASCII input to float***/
else
Output:
7+5
The result :12.000
%{
#include<stdio.h>
#include<ctype.h>
%}
%token num
%left '+''-'
%left '*''/'
%right '^'
%%
s:e'\n'{printf("%d",$1);}
e: e '+' e{$$=$1+$3;}
|e '-' e{$$=$1-$3;}
|e '*' e{$$=$1*$3;}
|e '/' e{$$=$1/$3;}
|e '^' e {
int i,j=$1;