// additional functionality of power right associative
grammar Exp;
options{
k=2;
}
/* This will be the entry point of our parser. */
eval returns [double value]
: additionExp{$value=$additionExp.value; System.out.println($value);}
;
/* Addition and subtraction have the lowest precedence. */
additionExp returns [double value]
: m1=multiplyExp {$value=$m1.value;}
( '+' m2=multiplyExp {$value+=$m2.value;}
...
Sunday, September 2, 2012
[lex-yacc] Simple Expression evalution using lex & yacc
CAL1.l----------------------------------------------------------------------
%{
#include <stdlib.h>
#include <stdio.h>
#include "y.tab.h"
void yyerror(char*);
%}
%%
[ \t]+ ;
[0-9]+\.[0-9]+ {yylval.fval=atof(yytext);return FLOAT;}
[0-9]+ {yylval.ival=atoi(yytext);return INTEGER;}
[-+*/] {return *yytext;}
"(" {return *yytext;}
")" {return *yytext;}
\n {return *yytext;}
. {printf("invalid character: %c",*yytext);}
CAL1.Y--------------------------------------------------------------------------------------------------
%{
#include...
Reverse Enginnering
Reverse
Enginnering
The term reverse engineering as applied to
software means different things to different people."Reverse engineering
is the process of analyzing a subject system to create representations of the
system at a higher level of abstraction." It can also be seen as
"going backwards through the development cycle". In this model, the
output of the implementation phase (in source code form) is reverse-engineered
back to the analysis phase, in an inversion of the traditional waterfall model.
Reverse engineering...
Wifi technology
WiFi enabled devices are connected wirelessly and can connect to the Internet via a wireless access point.WiFi can function in geographical location and can be used where wiring and cable connection is not feasible.
In this experiment we will learn the different standards and the simulation of WiFi network. It also explains the concept of hidden node and exposed node problem and solve these issues.
The following hardware devices are required for connecting the Wi Fi Network.
Access Point
Access Point acts as a bridge between the wireless...
[C-CODE] Reverse file content using lseek function
#include<protos.h>
#include<io.h>
void main()
{
clrscr();
int fd=open("C:\\text.txt",O_RDONLY);
if(fd==-1)
{
printf("FIle does not exists....");
return ;
}
char c;
int i=0;
lseek(fd,-1L-i,SEEK_END);
do
{
read(fd,&c,1);
printf("%c",c);
i++;
}
while( lseek(fd,-1L-(i),SEEK_END)!=0);
read(fd,&c,1);
printf("%c",c);
getch();
}
How to run it?
$gcc file.c \
$./a.out...
[C-CODE] Copy file contents using system calls
/*Code open-sourced by http://codejar-lab.in
This is only for study purpose only and if you found any error use own logic to correct it so dont comment error.
*/
#include <syscall.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/uio.h>
#include <sys/stat.h>
#include <stdio.h>
int main(int argc,char * argv[])
{
int fd;
fd=open(argv[1],O_CREAT | O_RDONLY);
if(fd==-1)
...
[C-CODE]Program to sum numbers using parallel processing
/*Code open-sourced by http://codejar-lab.in
This is only for study purpose only and if you found any error use own logic to correct it so dont comment error.
*/
#include<stdio.h>
#include<sys/ipc.h>
#include<sys/wait.h>
#include<sys/shm.h>
int FFork(int iProcess)
{
int iCount;
int PId;
for (iCount=1; iCount<iProcess; iCount++)
{
PId =...
[C-CODE]How to fork process in unix?
/*Code open-sourced by http://codejar-lab.in
This is only for study purpose only and if you found any error use own logic to correct it so dont comment error.
*/
#include<stdio.h>
int main()
{
int PId;
PId = fork();
if ( PId == 0 )
{
printf("Child Here.....\n");
sleep(20);
printf(" Parent Id : %d\n",getppid());
printf(" My Id : %d\n",getpid());
}
else
{
printf("Parent Here.....\n");
printf(" My Child : %d\n",PId);
printf(" My Id : %d\n",getpid());
printf(" My Parent : %d\n",getppid());
...
Subscribe to:
Posts (Atom)