Programs and scripts submitted as part of the Compiler Design Lab for the 8th semester of Mathematics & Computing.
Program 19 : WAP in C to implement shift-reduce parser for the following grammar:
E-> 2E2
E-> 3E3
E-> 4
Program 20 : WAP in C to implement operator precedence parser for the following grammar:
E-> E+E
E-> E*E
E-> id
Program 12 : Lex Program to count number identifiers, keywords, operators in a file.
Program 13 : Lex Program to generate a scanner that will take a decimal number between 1 to 999 in words and prints numeric value as output.
Program 14 : Lex program to count the no. of words starting with ab in a file.
Program 15 : Lex program to identify keywords and turn them into uppercase.
Program 16 : Lex program to find the longest word in a file and reverse it.
Program 17 : Lex program to count the number of 'scanf' and 'printf' statement in a “C” program & replace them with 'readf' and 'writef' statements.
Program 18 : Lex program to count the number of vowels and consonants in a file.
Program 9 : Write a program in FLEX to check whether a given Identifier is valid or not. Create a symbol table for the same.
Program 10 : Write a program in FLEX to check whether a given Keyword is valid or not. Create a symbol table for the same.
Program 11 : Write a program in FLEX to check whether a given Operator is valid or not. Create a symbol table for the same.
Note:
For every input, the program should satisfy the following conditions:
- If the input is invalid - Return error message.
- If input is valid and it is not present in the symbol table - Make a new entry in the symbol table and return the corresponding index value.
- If the input is valid and it is present in the symbol table - Return the corresponding index value.
Program 6 : Write a program to check whether a given Identifier is valid or not. Create a symbol table for the same.
Program 7 : Write a program to check whether a given Keyword is valid or not. Create a symbol table for the same.
Program 8 : Write a program to check whether a given Operator is valid or not. Create a symbol table for the same.
Note:
For every input, the program should satisfy the following conditions:
- If the input is invalid - Return error message.
- If input is valid and it is not present in the symbol table - Make a new entry in the symbol table and return the corresponding index value.
- If the input is valid and it is present in the symbol table - Return the corresponding index value.
Program 1 : Write a C program to take another C program as input and store it into another file
Program 2 : Write a C program to count the number of lines in the stored C program
Program 3 : Write a C program to count the number of different operators in previously stored file
Program 4 : Write a C program to remove all white spaces, tabs and newline commands from stored C program and copy it into another file.
Program 5 : Write a C program to check the single and multiple comment lines in previously stored file.