School of Computer Science     University of Windsor

03-60-214: Computer Languages, Grammars and Translators
[Home] [Assignments] [Lecture Slides] [Resources]   [Find your marks]

[Assignment 1]
[Assignment 2]
[Assignment 3]
[Assignment 4]

[Home]
[Up]
[Tiny Language]
[A2 Test Case]

 

 

Assignment 2

Scanner generation using JLex (6 Points)

Due date: Feb 10 Feb 17, 12:50 pm

Where to submit

You must submit your assignment at the web submission site
. You can submit 5 times, and we will use your last submission for your final marks for this assignment. For each submission you will get your marks instantly on the web and by email.

Purpose

Understand the lexical definition of a language. Generate a scanner using JLex. 

Assignment Specification

The task is to write a JLex specification for Tiny language.  Please note that in this assignment  we don't need to use all the grammar definitions there.  Only the lexical part is needed.

You will write a JLex specification named "A2.lex". We will run the following commands to generate the scanner, compile it, and run it. 

  > java JLex.Main A2.lex
  > javac A2.lex.java
  > java A2

You should take extra care on the file names. Make sure all the three commands can run without problem, and the A2.output file is generated. If any of the 3 commands fails, you will receive very low marks, even 0, no matter how good the other part of your program is.

The A2.class program will read a text file named "A2.input", and produce a file named "A2.output" which contains following five lines:

     identifiers: NumberOfIdentifiers
     keywords: NumberOfKeyowrds
     numbers: NumberOfIntergersOrRealNumbers
     lines: NumberOfLines
     quotedString: NumberOfQuotedStrings
Here are the sample A2.input and the corresponding output file A2.output. Line numbers should not be zero-based, i.e., if there are 3 lines, your count for line number should be 3 instead of 2.

Note that you don't need to write any Java programs. The scanner is generated from your lex specification. 

Marking scheme

This assignment will give you bonus up to 1 point depending on the length of your program. If your program counts everything correct, you shall receive 5. On top of that, there is a bonus calculated using your program length.
	yourMark=0;
	if ( A2.lex file is not sent properly or file name is incorrect) return; 
	if (java program named A2.lex.java is generated from your lex file) 
	   yourMark+=0.5;
	if ( generated program is compiled correctly && A2.class is generated) {
            yourMark+=0.5;
            if (your java program reads A2.input && generates result file A2.output){
                     for (each of the 5 counts in A2.output) {
                           if (count is correct) {  
                                 yourMark+=0.8;
                            }
                      }
             }   
	}
	yourMark += (lengthOfYourProgram>140)?0:96/lengthOfYourProgram;  // length is counted by PHP in terms of words; Note that different programs count the words in different ways. 
	for (each day of your late submission)  yourMark=yourMark*0.7;

What to submit

You only need to submit A2.lex     

Instructor: Dr. Jianguo Lu     Email: jlu at uwindsor  Office: 5111 Lambton Tower        Phone: 519.253.3000 ext 3786