CS 453 Programming Assignment #2 — MeggyJava Scanner
Due Thursday February 23th (by 11:59pm)
Introduction
PA2 is the first programming assignment for CS453 where you will be
working in a team. Your team will extend a JLex based scanner to
include all of the tokens in the MeggyJava language. An incomplete
regression testing system is provided. This testing system iterates
through all input files
fname.in
in a TestCases directory and compares output with
corresponding fname.in.OK
files. You are provided with a
MJPA2Driver.java
program that calls the scanner repeatedly and
outputs each symbols that is read in.
Example: The file plus.in contains:
+
+ + +
+
+ +
+ +
+ +
and scanning it will produce the following result:
symbol: #2 symbolValue: [+ at: (1,1) value: -1]
symbol: #2 symbolValue: [+ at: (2,1) value: -1]
symbol: #2 symbolValue: [+ at: (2,3) value: -1]
symbol: #2 symbolValue: [+ at: (2,5) value: -1]
symbol: #2 symbolValue: [+ at: (3,5) value: -1]
symbol: #2 symbolValue: [+ at: (4,3) value: -1]
symbol: #2 symbolValue: [+ at: (4,7) value: -1]
symbol: #2 symbolValue: [+ at: (5,1) value: -1]
symbol: #2 symbolValue: [+ at: (5,9) value: -1]
symbol: #2 symbolValue: [+ at: (6,2) value: -1]
symbol: #2 symbolValue: [+ at: (6,8) value: -1]
The symbol number "#2" corresponds to a constant for the PLUS token
(see sym.java
generated by the JLex / JavaCup tool). A Symbol
object contains a token and a SymbolValue objects. SymbolValue objects
contain a lexeme, line, position, and integer value. The default integer
value is -1
. This default value is used to indicate that no
extra value is associated with a PLUS token, but a ColorLiteral, a
ToneLiteral, or a number will have useful associated values.
See the Meggy Java Tokens
description in the Resources section of the website for a description of
Symbols and their associated values.
The Assignment
To complete this assignment you must:
- Extend mj.lex so that it scans all the tokens specified in the
Meggy Java
Tokens Description page. Do not change the order of the
terminal definitions in the bogus parser, as this would change
their symbol numbers.
- Run regress.sh and confirm all provided test cases pass.
- Add test cases for non provided token types (see Terminals doc)
- Add error cases for all token types (see Terminals doc)
You will start off by downloading
this tar.gz file.
Provided Test Cases
You are provided with various test cases. This set is incomplete.
For each token type: (Specials, Reserved Words, Reserved Phrases,
Int-Literal, Id, Comments) create files fnm.in and fnm.in.OK,
thoroughly testing that type, and provide files errfnm.in and errfnm,in.OK
thoroughly testing incorrect tokens of that type, e.g. an errspec.in could
contain ">@$" and more.
Submitting the Assignment
-
Make sure you test your implementations thoroughly.
-
Include all of the regression test terminal files ( .in and .in.OK)
that you wrote,
- Include a README file explaining the file structure (your test files)
and other comments you want your TA to know (e.g. features not
implemented).
-
Submit assignment using checkin utility.
~cs453/bin/checkin PA2 PA2_YourGroupName.tar
-
Sanity Check (procedure TA will use to grade your assignment):
# Unpack and build:
> tar xf PA2_YourLoginName.tar
> cd PA2
> cat README
> make
# Examine tests:
> cd TestCases
> find *.in | xargs -I % sh -c 'echo -e "----\n" % "\n-----"; cat %; \
echo -e "\n * * * \n"; cat %.OK; echo -e "\n\n\n"'
# Execute tests:
> ./regress.sh
Late Policy
Late assignments will be accepted up to 48 hours past the due date for a 10%
deduction. The assignment will not be accepted past this period.
Late means anything after 11:59pm
on the day the assignment is due, including 12 midnight.