Difference between revisions of "Fall 2020: System Programming Lab"

From MKWiki
Jump to navigation Jump to search
 
(78 intermediate revisions by the same user not shown)
Line 1: Line 1:
== '''Lab 1: Getting Started''' ( week of 10th August 2020 ) ==
+
==''' Resources'''==
* Brief introduction to Java Basic Building Blocks [http://mkbhandari.com/mkwiki/data/spring2020/Lab01.pdf '''Download''']
+
* An introductory tutorial on [[Lex Tutorial|Lex]].
 +
* LEX & YACC TUTORIAL by Tom Niemann [https://www.epaperpress.com/lexandyacc/index.html]
 +
* Lex Basics on javatpoint [https://www.javatpoint.com/lex]
 +
* Lex on Windows [http://www.surajgaikwad.com/2013/10/compile-lex-and-yacc-progs-on-windows.html]
 +
 
 +
== '''Lab 1: Getting Started''' ( week of 10<sup>th</sup> August 2020 ) ==
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
|-
 
|-
Line 9: Line 14:
 
|-
 
|-
 
| style="width: 8%"  | 1  
 
| style="width: 8%"  | 1  
| style="width: 60%" | WAP to find the sum of any number of integers entered as command line argument
+
| style="width: 60%" | Write a Lex Program to count number of words
| style="width: 15%" | Lab Exercise No. 1
+
| style="width: 15%" | Practice Set  No. 1(1) ||
|  
 
 
|-
 
|-
| 2 || WAP to find the factorial of a given number || Lab Exercise No. 2 ||
+
| 2 || Write a Lex program to count the number of lines and characters in the input file.  || Lab Exercise No. 1 ||
 
|-
 
|-
| 3 || WAP to check whether the given number is prime or not || Lab Exercise No. 6 ||
+
| 3 || Write a Lex Program to count the number of lines, tabs and spaces used in the input. || Practice Set No. 1(2) ||
 
|-
 
|-
| 4 || WAP to print the following pattern using nested for loop:<br>
+
| 4 || Write a Lex Program to count the number of lines, words, small letters, capital letters, digits, special characters, and finally all characters. || Practice Set No. 1(3) ||
*<br>
 
*  *<br>
 
*  *  *<br>
 
*  *  *  *
 
|| Practice Set No. L1 ||
 
 
|}
 
|}
  
== '''Lab 2:''' ( week of 15th January 2020 ) ==
+
== '''Lab 2-3''' ( week of 17<sup>th</sup> & 24<sup>th</sup> August 2020 ) ==
* Reading input from keyboard, Arrays [http://mkbhandari.com/mkwiki/data/spring2020/Lab02.pdf '''Download''']
 
 
 
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
|-
 
|-
Line 36: Line 33:
 
|-
 
|-
 
| style="width: 8%"  | 1  
 
| style="width: 8%"  | 1  
| style="width: 60%" | WAP to read data of various types from user(keyboard)
+
| style="width: 60%" | Write a Lex program to count the number of vowels and consonants in a given string
| style="width: 15%" | Practice Set No. L2
+
| style="width: 15%" | Practice Set No. 2(1) ||
|
 
|-
 
| 2 || Rewrite the Lab Exercise No. 3, by taking the number as input from the keyboard  || Lab Exercise No. 6 ||
 
|-
 
| 3 || WAP to learn use of single dimensional array by defining the array dynamically  || Lab Exercise No. 3 ||
 
 
|-
 
|-
| 4 || WAP to Search an element in the array(Linear Search) ||Practice Set No. L2(2) ||
+
| 2 || Write a Lex program that implements the '''Caesar cipher'''. It replaces every letter with the one three letters after(right shift) in an alphabetical order, wrapping around at Z e.g a is replaced by d ,d by e ,and so on z by c. || Lab Exercise No. 2 || Read about Caesar Cipher from [https://en.wikipedia.org/wiki/Caesar_cipher]
|-
 
| 5 || WAP to learn use of Two dimensional array by defining the array dynamically  || Lab Exercise No. 4 ||
 
 
|}
 
|}
  
== '''Lab 3:''' ( week of 22nd January 2020 ) ==
+
== '''Lab 4''' ( week of 31<sup>st</sup> August 2020 ) ==
* String Manipulation [http://mkbhandari.com/mkwiki/data/spring2020/Lab03.pdf '''Download''']
 
 
 
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
|-
 
|-
Line 60: Line 48:
 
|-
 
|-
 
| style="width: 8%"  | 1  
 
| style="width: 8%"  | 1  
| style="width: 60%" | WAP to convert a decimal number to a binary number
+
| style="width: 60%" | Write a Lex program that finds the longest word (defined as a contiguous string of upper and lower case letters) in the input.
| style="width: 15%" | Lab Exercise No. 5
+
| style="width: 15%" | Lab Exercise No. 3 ||
| [http://mkbhandari.com/mkwiki/data/spring2020/D2B.java '''Solution''']
 
 
|-
 
|-
| 2 || WAP to convert a decimal number to a octal number  || Practice Set No. L3 ||
+
| 2 || Write a Lex program that distinguishes keywords, integers, floats, identifiers, operators, and comments in any simple programming language. || Lab Exercise No. 4 ||  
|-
 
| 3 || WAP to find the sum of any number of integers interactively, i.e., entering every number from the keyboard, where as the total number of integers is given as a command line argument. || Lab Exercise No. 7 ||
 
|-
 
| 4* || WAP that show working of different functions of String and StringBuffer class like setCharAt(), setLength(), append(), insert(), concat(), and equals() || Lab Exercise No. 8 || Concepts of String Handling is required
 
 
|}
 
|}
  
== '''Lab 4:''' ( week of 29th January 2020 ) ==
+
== '''Lab 5-6''' ( week of 7<sup>th</sup> & 14<sup>th</sup> September 2020 ) ==
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
|-
 
|-
Line 80: Line 63:
 
|-
 
|-
 
| style="width: 8%"  | 1  
 
| style="width: 8%"  | 1  
| style="width: 60%" | Create a '''Box''' class consisting of three instance variables: '''width, height''', and '''depth'''. Create another class named '''BoxDemo''' that:
+
| style="width: 60%" | Write a Lex program to count the number of identifiers in a c file.
* Declares 3 objects of type '''Box''' ,
+
| style="width: 15%" | Lab Exercise No. 5 ||
* Assigns values to the instance variables of '''Box objects''', and
 
* Finally computes the '''volume''' of '''all 3 Box objects'''.
 
There are no methods in this class.
 
| style="width: 15%" | Practice Set No. L4
 
|  
 
 
|-
 
|-
| 2 || Implement Q. NO. 1 using methods. Apply the concepts like '''methods taking parameter''', '''methods returning values''', etc. || Practice Set No. L4(2) ||
+
| 2 || Write a Lex program to count the number of words ,characters ,blank spaces and lines in c file. || Lab Exercise No. 6 ||  
|-
 
| 3 || Write a program to create a “distance” class with methods where distance is computed in terms of feet and inches, how to create objects of a class and to see the use of this pointer. || Lab Exercise No. 9 ||
 
 
|}
 
|}
  
== '''Lab 5:''' ( week of 05th February 2020 ) ==
+
== '''Lab 7-8''' ( week of 21<sup>st</sup> & 28<sup>th</sup> September 2020 ) ==
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
|-
 
|-
Line 102: Line 78:
 
|-
 
|-
 
| style="width: 8%"  | 1  
 
| style="width: 8%"  | 1  
| style="width: 60%" | Create a '''Box''' class consisting of three instance variables: '''width, height''', and '''depth'''. Create another class named '''BoxDemo''' that:  
+
| style="width: 60%" | Write a Lex specification program that generates a C program which takes a string “abcd” and prints the following output:<br>
* Declares 3 objects of type '''Box''' ,
+
abcd <br>
* Assign the values of object 1 using '''Default Constructor'''(explicit).
+
abc<br>
* Assign the values of object 2 using '''Parameterized Constructor'''.
+
ab<br>
* Assign the values of object 3 using '''Parameterized Method'''.
+
a
Finally computer the volume of all three objects.
+
| style="width: 15%" | Lab Exercise No. 7 ||
| style="width: 15%" | Practice Set No. L5
 
|  
 
 
|-
 
|-
| 2* || Modify the "distance" class by creating constructor for assigning values (feet and inches) to the distance object. Create another object and assign second object as reference variable to another object reference variable. Further create a third object which is a clone of the first object. || Lab Exercise No. 10 ||
+
| 2 || Write a Lex program to recognize a valid arithmetic expression. || Lab Exercise No. 8 ||  
|-
 
| 3 || Write a program to show that during method overloading, if no matching argument is found, then java will apply automatic type conversions(from lower to higher data type). || Lab Exercise No. 11 ||
 
 
|}
 
|}
  
== '''Lab 6:''' ( week of 12th February 2020 ) ==
+
== '''Lab 9''' ( week of 5<sup>th</sup> October 2020 ) ==
* Read Access Modifiers from  [https://www.javatpoint.com/access-modifiers Java T Point]
 
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
|-
 
|-
Line 125: Line 96:
 
! Remarks
 
! Remarks
 
|-
 
|-
| style="width: 8%| 1
+
| colspan="4"  style="text-align: center;| Complete all the Lex programs i.e., '''Lab Exercise No.1 - Lab Exercise No.8'''
| style="width: 60%" | Implement a Stack class with two data items('''array stk''' and '''tos''') and three methods('''Stack()''' Constructor to initialize tos, '''Push()''', and '''Pop()''' )
 
| style="width: 15%" | Practice Set No. L6
 
|
 
|-
 
| 2 || Complete the remaining section of Q. NO. 2 of Lab 5 (using copy constructor) || Lab Exercise No. 10 ||
 
|-  
 
| 3* || Write a program to show the difference between '''public''' and '''private''' access specifiers. The program should also show that primitive data types are '''passed by value''' and objects are '''passed by reference''' and to learn use of '''final keyword'''. || Lab Exercise No. 12 || Read '''final keyword''' examples from [https://www.javatpoint.com/final-keyword]
 
 
|}
 
|}
  
== '''Lab 7:''' ( week of 19th February 2020 ) ==
+
== '''Lab 10-11''' ( week of 2<sup>nd</sup> & 9<sup>th</sup> November 2020 ) ==
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
|-
 
|-
Line 144: Line 108:
 
|-
 
|-
 
| style="width: 8%"  | 1  
 
| style="width: 8%"  | 1  
| style="width: 60%" | Write a program to demonstrate the concept of '''static keyword''' for:
+
| style="width: 60%" | Write a Program in YACC to evaluate an expression (simple calculator program for addition, subtraction, multiplication, and division).
* variable
+
| style="width: 15%" | Lab Exercise No. 10 ||
* method
 
* block
 
| style="width: 15%" | Practice Set No. L7
 
| Read about '''static keyword''' in detail from [https://www.javatpoint.com/static-keyword-in-java#staticblock]
 
 
|-
 
|-
| 2 || Write a program to show the use of static functions and to pass variable length arguments in a function. || Lab Exercise No. 13 || Read about '''varargs''' from [https://www.geeksforgeeks.org/variable-arguments-varargs-in-java/]
+
| 2 || Write a YACC program to find the validity of a given expression( for operator + - * and / ). A program in YACC which recognizes a valid variable which starts with letter followed by a digit. The letter should be in lowercase only. || Lab Exercise No. 9 ||  
|-
 
| 3 || Write a program to demonstrate the concept of boxing and unboxing. || Lab Exercise No. 14 || Read about '''Autoboxing and Unboxing''' from [https://www.geeksforgeeks.org/autoboxing-unboxing-java/]
 
 
|}
 
|}
  
== '''Lab 8:''' (week of 18th March 2020 ) ==
+
== '''Final Lab''' ==
* Read '''Lect12''' slide from [[Spring 2020: Programming in Java|Java Course Page]]
 
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
{| class="wikitable" style="text-align: left; width: 100%";  
 
|-
 
|-
Line 166: Line 123:
 
|-
 
|-
 
| style="width: 8%"  | 1  
 
| style="width: 8%"  | 1  
| style="width: 60%" | Create a multi-file program where in one file a string message is taken as input from the user and the function to display the message on the screen is given in another file (make use of Scanner package in this program).
+
| style="width: 60%" | Program in YACC to recognize the string "abbb‟, "ab‟, "a‟ of the langauge (a<sup>n</sup>b<sup>n</sup>, n>=1).
| style="width: 15%" | Lab Exercise No. 15
+
| style="width: 15%" | Lab Exercise No. 11 ||
| Read tutorial on '''Packages''' from [https://www.javatpoint.com/package#packagewaystoload]
 
Solution:
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/PackagesEx/file1.java '''file1.java'''], [http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/PackagesEx/file2.java '''file2.java''']
 
|-
 
| 2 || Write a program to create a multilevel package and also creates a reusable class to generate Fibonacci series, where the function to generate Fibonacii series is given in a different file belonging to the same package. || Lab Exercise No. 16 ||
 
Solution:
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/PackagesEx/fibonacci.java '''fibonacci.java'''], [http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/PackagesEx/fiboTest.java '''fiboTest.java''']
 
|-
 
| 3 || Write a program that creates illustrates different levels of protection in classes/subclasses belonging to same package or different packages.|| Lab Exercise No. 17 || Same as discussed in class ppt under  '''An Access Example'''
 
|}
 
 
 
== '''Exception Handling''' ==
 
* Read '''Lect14''' slides from [[Spring 2020: Programming in Java|Java Course Page]]
 
{| class="wikitable" style="text-align: justify; width: 100%";
 
|-
 
! Q. NO. 
 
! Program 
 
! Lab Exercise No. 
 
! Remarks
 
|-
 
| style="width: 8%"  | 1
 
| style="width: 60%" | Write a program “DivideByZero” that takes two numbers a and b as input, computes a/b, and invokes Arithmetic Exception to generate a message when the denominator is zero.
 
| style="width: 15%" | EH (1)
 
| Read tutorial on '''Exception Handling''' from [https://www.javatpoint.com/exception-handling-in-java]
 
Solution:
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/ExceptionEx/DivideByZero.java '''DivideByZero.java''']
 
|-
 
| 2 || Write a program to show the use of nested try statements that emphasizes the sequence of checking for catch handler statements. || EH (2) ||
 
Solution:
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/ExceptionEx/NestedTry1.java '''NestedTry1.java''']
 
|-
 
| 3 || Write a program to create your own exception types to handle situation specific to your application (Hint: Define a subclass of Exception which itself is a subclass of Throwable).|| EH (3) ||
 
Solution:
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/ExceptionEx/ExceptionTest.java '''ExceptionTest.java''']
 
|-
 
| 4 || Write a program to implement stack. Use exception handling to manage underflow and overflow conditions. || EH (4) ||
 
Solution(1):
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/ExceptionEx/StackException.java '''file1''']
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/ExceptionEx/Stack.java '''file2''']
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/ExceptionEx/ArrayStack.java '''file3''']
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/ExceptionEx/StackExceptionDemo.java '''Test File'''] <br>
 
Solution(2):
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/ExceptionEx/StackExceptionTest.java '''StackExceptionTest.java''']
 
|-
 
| 5
 
| Create an exception subclass UnderAge, which prints "Under Age" along with the age value when an object of UnderAge class is printed in the catch statement.
 
Write a class exceptionDemo in which the method test() throws UnderAge exception if the variable age passed to it as argument is less than 18. Write main() method also to show working of the program.
 
| EH (5)
 
| Solution:
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/ExceptionEx/UnderAgeExceptionTest.java '''UnderAgeExceptionTest.java''']
 
|}
 
 
 
== '''I/O Strems (or File Handling)''' ==
 
* Read '''Lect17''' slides from [[Spring 2020: Programming in Java|Java Course Page]]
 
{| class="wikitable" style="text-align: justify; width: 100%";
 
|-
 
! Q. NO. 
 
! Program 
 
! Lab Exercise No. 
 
! Remarks
 
|-
 
| style="width: 8%"  | 1
 
| style="width: 57%" | Write a program to read characters from console using BufferedReader
 
| style="width: 15%" | I/O (1)
 
| Read tutorial on '''Java I/O''' from [https://www.javatpoint.com/java-io]
 
Solution:
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/IO/BRRead.java '''BRRead.java''']
 
|-
 
| 2 || Write a program to read string from console using BufferedReader || I/O (2) ||
 
Solution:
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/IO/BRReadLines.java '''BRReadLines.java''']
 
|-
 
| 3
 
| Write a program that copies content of one file to another. Pass the names of the files through command-line arguments.
 
| I/O (3)
 
| Solution1: [http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/IO/CopyFile.java '''CopyFile.java''']
 
Solution2: [http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/IO/CopyFile2.java '''CopyFile2.java'''] <br>
 
Sample input file(Source) <br>
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/IO/TEXT.TXT '''TEXT.TXT''']
 
|-
 
| 4
 
| Write a program to read a file and display only those lines that have the first two characters as '//' (Use try with resources).
 
| I/O (4)
 
| Read tutorial on '''The try-with-resources statement''' from [https://www.javatpoint.com/java-try-with-resources]
 
Solution:
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/IO/TryWithResources.java '''TryWithResources.java''']
 
Sample input file <br>
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/IO/TEXTTWR.TXT '''TWR.TXT''']
 
|}
 
 
 
== '''Event Handling, AWT and Swings ''' ==
 
* Read '''Lect20''' slides from [[Spring 2020: Programming in Java|Java Course Page]]
 
{| class="wikitable" style="text-align: justify; width: 100%";
 
|-
 
! Q. NO. 
 
! Program 
 
! Lab Exercise No. 
 
! Remarks
 
|-
 
| style="width: 8%"  | 1  
 
| style="width: 57%" | Write a program to handle mouse events(Clicked, Entered, Exited, Presses, and Released).
 
| style="width: 15%" | AWTnEH(1)
 
| Solution:
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/AWTandEventHandling/MouseListenerExample.java '''MouseListenerExample.java''']
 
Read tutorial from [http://www.javatpoint.com/java-mouselistener]
 
|-
 
| 2
 
| Write a program to handle key events(Pressed, Released, and Typed).
 
| AWTnEH(2) 
 
| Solution:
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/AWTandEventHandling/KeyListenerExample.java '''KeyListenerExample.java''']
 
Read tutorial from [http://www.javatpoint.com/java-keylistener]
 
 
|-
 
|-
| 3
+
| 2 || Program in YACC to recognize the language (a<sup>n</sup>b , n>=10). (output to say input is valid or not) || Lab Exercise No. 12 ||  
| Using AWT, write a program to display a string in frame window with pink colour as background.
 
| AWTnEH(3) 
 
| Solution: [http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/AWTandEventHandling/SetBGColor.java '''SetBGColor.java''']
 
Read tutorial on Adapter Classes from [https://www.javatpoint.com/java-adapter-classes]
 
|-
 
| 4
 
| Using AWT, write a program to create two buttons named “Red” and “Blue”. When a button is pressed the background color should be set to the color named by the button’s label.
 
| AWTnEH(4)
 
| Solution: [http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/AWTandEventHandling/ButtonPress.java '''ButtonPress.java''']
 
|-
 
| 5
 
| Using AWT, write a program which responds to KEY_TYPED event and updates the status window with message (“Typed character is: X”). Use adapter class for other two events.
 
| AWTnEH(5)
 
| Solution: [http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/AWTandEventHandling/KbdAdapterDemo.java '''KbdAdapterDemo.java''']
 
Read Java KeyAdapter Example from tutorial on Adapter Classes [https://www.javatpoint.com/java-adapter-classes]
 
|-
 
| 6
 
| Using AWT, write a program to create two buttons labelled ‘A’ and ‘B’. When button ‘A’ is pressed, it displays your personal information (Name, Course, Roll No, College) and when button ‘B’ is pressed, it displays your CGPA in previous semester. 
 
| AWTnEH(6)
 
| Solution: [http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/AWTandEventHandling/PersonalInfo.java '''PersonalInfo.java''']
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/AWTandEventHandling/CGPA.java '''CGPA.java''']
 
[http://mkbhandari.com/mkwiki/data/spring2020/JavaLab/AWTandEventHandling/PersonalInfoCGPADemo.java '''PersonalInfoCGPADemo''']
 
|-
 
| 7
 
| Rewrite Q. NO. 3-6 using Swing 
 
| SWG(3-6)
 
|  
 
 
|}
 
|}

Latest revision as of 01:10, 16 November 2020

Resources

  • An introductory tutorial on Lex.
  • LEX & YACC TUTORIAL by Tom Niemann [1]
  • Lex Basics on javatpoint [2]
  • Lex on Windows [3]

Lab 1: Getting Started ( week of 10th August 2020 )

Q. NO. Program Lab Exercise No. Remarks
1 Write a Lex Program to count number of words Practice Set No. 1(1)
2 Write a Lex program to count the number of lines and characters in the input file. Lab Exercise No. 1
3 Write a Lex Program to count the number of lines, tabs and spaces used in the input. Practice Set No. 1(2)
4 Write a Lex Program to count the number of lines, words, small letters, capital letters, digits, special characters, and finally all characters. Practice Set No. 1(3)

Lab 2-3 ( week of 17th & 24th August 2020 )

Q. NO. Program Lab Exercise No. Remarks
1 Write a Lex program to count the number of vowels and consonants in a given string Practice Set No. 2(1)
2 Write a Lex program that implements the Caesar cipher. It replaces every letter with the one three letters after(right shift) in an alphabetical order, wrapping around at Z e.g a is replaced by d ,d by e ,and so on z by c. Lab Exercise No. 2 Read about Caesar Cipher from [4]

Lab 4 ( week of 31st August 2020 )

Q. NO. Program Lab Exercise No. Remarks
1 Write a Lex program that finds the longest word (defined as a contiguous string of upper and lower case letters) in the input. Lab Exercise No. 3
2 Write a Lex program that distinguishes keywords, integers, floats, identifiers, operators, and comments in any simple programming language. Lab Exercise No. 4

Lab 5-6 ( week of 7th & 14th September 2020 )

Q. NO. Program Lab Exercise No. Remarks
1 Write a Lex program to count the number of identifiers in a c file. Lab Exercise No. 5
2 Write a Lex program to count the number of words ,characters ,blank spaces and lines in c file. Lab Exercise No. 6

Lab 7-8 ( week of 21st & 28th September 2020 )

Q. NO. Program Lab Exercise No. Remarks
1 Write a Lex specification program that generates a C program which takes a string “abcd” and prints the following output:

abcd
abc
ab
a

Lab Exercise No. 7
2 Write a Lex program to recognize a valid arithmetic expression. Lab Exercise No. 8

Lab 9 ( week of 5th October 2020 )

Q. NO. Program Lab Exercise No. Remarks
Complete all the Lex programs i.e., Lab Exercise No.1 - Lab Exercise No.8

Lab 10-11 ( week of 2nd & 9th November 2020 )

Q. NO. Program Lab Exercise No. Remarks
1 Write a Program in YACC to evaluate an expression (simple calculator program for addition, subtraction, multiplication, and division). Lab Exercise No. 10
2 Write a YACC program to find the validity of a given expression( for operator + - * and / ). A program in YACC which recognizes a valid variable which starts with letter followed by a digit. The letter should be in lowercase only. Lab Exercise No. 9

Final Lab

Q. NO. Program Lab Exercise No. Remarks
1 Program in YACC to recognize the string "abbb‟, "ab‟, "a‟ of the langauge (anbn, n>=1). Lab Exercise No. 11
2 Program in YACC to recognize the language (anb , n>=10). (output to say input is valid or not) Lab Exercise No. 12