21.08.2015 Views

Compiler Lab (Course code CS671)

Compiler Lab (Course code: CS671) - CIT, Kokrajhar...

Compiler Lab (Course code: CS671) - CIT, Kokrajhar...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CENTRAL INSTITUTE OF TECHNOLOGY,KOKRAJHAR(A Centrally Funded Institute under Ministry of HRD, Govt. of India)BODOLAND TERRITORIAL AREAS DISTRICTS :: KOKRAJHAR :: ASSAM :: 783370Website: www.cit.ac.in<strong>Compiler</strong> <strong>Lab</strong> (<strong>Course</strong> <strong>code</strong>: <strong>CS671</strong>)6 th Semester Degree, CSEPrerequisites: Knowledge of algorithm, data structure and C languageAssignment Set 1: Problems on file Programming:1.1 Open the files in different modes.1.2 Retrieve contents from a file.1.3 Copy the content of one file and paste it in another.1.4 Delete a particular fileS/W to be used: Linux OS and C compilerAssignment Set2:Design of a Lexer (for solving all the assignments under this hood read all theinput data from a already existing file ):2.1 Design a Lexer which can identify all the keywords of the C Language as validtoken.2.2 Design a Lexer which can identify the variables, constants of the C Language asvalid token.2.3 Design a Lexer which can identify all the arithmetic and logical operations ofthe C Language as valid token.2.4 Integrate 2.1, 2.2 and 2.3 to generate your one lexer which uniquely identifiesall the keywords (return KEY token), variable (return SYM#, value of the variableas token), constant (reurn CON, value), and operator (return OP token).S/W to be used: Linux OS and C compiler


Assignment Set 3: Usage of LEX:Assignment Set 4: Usage of Yacc :3.1 Write a LEX program which can identify whether an alphabet is constant andvowel.3.2 Write a LEX program which can take any input and try to match it with thefollowing rules:letter -> [A-Za-z]digit->[0-9]id->letter(letter|digit)*3.3 Write a LEX program which can take any input and try to match any input withthe regular expression(a|b|c)*back3.4 Write a LEX program which opens a file and add line no in front of each line inthe file.S/W to be used: Linux OS, C compiler and FLEX.4.1 Design a calculator which takes an arithmetic expression. Identify whether theexpression is valid or not using the help of LEX compiler. If it is a valid expressionthen it gives the result else generate the syntax error. The arithmetic expressionshould be like below: Addition Subtraction Division Multiplication Factorial Power GCD Computing the value of a seriesDo not forget to maintain the operator precedence in your result.4.2 Design a sentence checker which takes a sentence as an input. Analyze all thewords in your sentence using FLEX. Return the tokens for the words in thismanner like NOUN, PRONOUN, VERB, ADVERB, ADJECTIVE. Then using Yacccompiler check whether the sentence satisfies the grammar of English. (Try tosolve this problem in a small set of NOUN, PRONOUN, VERB, ADVERB, ADJECTIVE)S/W to be used: Linux OS, C compiler, FLEX and Bison.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!