- The following codes are written in C and are meant to be compiled with CC or GCC compilers.
- Need to have the following installed :
- GCC Compiler
- Flex
- Yacc
lex <filename>.l
gcc lex.yy.c
./a.out
lex <filename>.l
yacc -d <filename>.y
gcc lex.yy.c y.tab.c -lfl
./a.out
Input format for each of the programs
-
a. Count the number of characters, words, lines and special characters in a given input file.
any string with numbers and special characters
b Validate the strings of the type a^m b^m+n c^n where m,n>=0
aabbcc abc ab bc
-
a. Count the number of positive and negetive integers and positive and negetive fractions
> 1 -2 3/4 -5/6 7/-8 -9/-10 +11/12 > // Just give a series fo space separated numbers
b. Evaluate a given arithmetic expression with + - * / operators.
1+2*3/4-5
-
a. Count the number of valid nested FOR loops
for(a;b;c){} for(a;b;c){for(a;b;c){d;}}
b. Validate function defination
int main(){} int foo(int a){} int bar(int a,int b){return a;}
-
Generate the intermediate 3 address code and quadruples for a given expression
a=b+c*d a+b+c+d+e+f a=(b+d)*(c+e)
-
Generate the assembly code for a given set of arithmetic expressions
./outputfilename.out < input.txt