Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 comments: NumberOfComments quotedString: NumberOfQuotedStrings 

Here are the sample A2.input and the corresponding output file A2.output. Note that this time you only need to count the occurrences of the identifiers, keywords, etc. You do not need to remove the duplciates as in last assignment.

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions

Question

Draw a schematic diagram of I.C. engines and name the parts.

Answered: 1 week ago