Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
The task is to write a JLex specification for Tiny language. Please note that in this assignment we dont need to use
all the grammar definitions there. Only the lexical part is needed. You will write a JLex specification named Alex
We will run the following commands to generate the scanner, compile it and run it JLex installation instruction is
documented here. You can find some other useful links such as Simple.lex here.
java JLex Main A lex
javac A lex java
java A
You should take extra care on the file names. Make sure all the three commands can run without problem, and
the Aoutput file is generated. If any of the three commands fails, you will receive very low marks, even no matter
how good the remaining part of your program is
The Aclass program will read a text file named Ainput and produce a file named Aoutput which contains
following five lines:
numbers : NumberOfIntergersOrRealNumbers
comments : NumberOfComments
lines : NumberOfLines
quotedString : NumberOfQuotedStrings
identifiers : NumberOfIdentifiers
Here are the sample Ainput and the corresponding output file Aoutput. Note that this time you only need to
count the occurrences of the identifiers, keywords, etc. You do not need to remove the duplicates as in last assignment.
Note that you dont 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started