System Software Lab


back

(see "how to compile" at bottom of the page)

1.a Write a program in LEX to count the no of vowels and consonants in a given string. 
1.b Write a YACC program to test for the validity of a simple expression involving operators +,-,*,/ . 
2.a Write a program in LEX to count the no of Characters, Words, Blanks and lines in a given text
2.b Write a YACC program which recognizes nested IF control statements and displays the no of      levels of nesting in  the IF (C programming style).
3.a

Write a program in LEX to count the no of  (i) positive and negative integers (ii) positive and  negative fractions.  

3.b

Write a YACC program to recognize a valid Arithmetic expression that uses operations +,-,*,/.

4.a

Write a LEX program to recognize a valid C program and also check for valid loop structure in it.

4.b

Write a YACC program which recognizes a valid variable which starts with letter followed by a digit. The letter should be in lower case only.

5.a

Write a LEX program to count the number of printf and scanf statements in a valid C program. Replace printf and scanf by WRITE and READ statements respectively.

5.b

Write a YACC program to evaluate an expression (simple calculator program).

6.a

Write a LEX program to check for validity of a expression. Count the no of operators in the  expressions.

6.b

 Write a YACC program to check whether a given string belongs to the grammer  anb { n>=0}.

7.a Write a LEX program to check whether an statement is simple or compound. 
7.b Write a YACC program to check whether a given string belongs to the grammer anbn {n>=0}
8.a Write a LEX program to count the no of identifiers in a file.
8.b Write a YACC program to recognize a valid IF - ELSE - THEN statements .(C programming style).

 

LEX and YACC for windows              

Sample programs for O'Relly series      

 

Compiling :

  LEX programs : $ lex <file-name.l>
                             $ cc lex.yy.c -ll
                             $ ./a.out

  YACC programs :$ yacc <file-name.y>
                                $ cc y.tab.c
                                $ ./a.out

  LEX and YACC combined :
                           $ lex <file-name.l>
                           $ yacc <file-name.y>
                           $ cc y.tab.c -ll
                           $ ./a.out