$24
Space : Empty
...
Space : Empty
End of Row
Space : Empty
...
Space : Empty
End of Row
Space : Empty
...
Space : Empty
End of Row
Space : Empty
Space : Empty
Space : Empty
Number : 2
Space : Empty
Space : Empty
Space : Empty
Number : 1
Space : Empty
Space : Empty
End of Game
End of Section
End of File
Figure 2: Truncated Output of Scanner for File in Figure 1
For a correctly formatted le in Part 2, the output would be: p pieces have been played where p is the number of pieces in the Game . For the le in Figure 1, the output would be
2 pieces have been played.
2.1.1 Invalid Syntax & Semantics in Parsing
For invalid encodings in Part 2, the message SYNTAX PROBLEM ON LINE L should be displayed where L is the line number where the error occurred. For a semantic rule violation, the output
SEMANTIC PROBLEM P should be displayed, where P is the number of the rule (from List 1.3) that was
Page 3
violated, but parsing should continue.
Syntax errors in Part 2 should be reported in the syntaxError method of csce322assignment01partt02error.java.
Naming Conventions
The ANTLR le for the rst part of the assignment should be named csce322assignment01part01.g4. The ANTLR le for the second part of the assignment should be named csce322assignment01part02.g4. Both grammars should contain a start rule named connectFour. The Java le for the second part of the assignment should be named csce322assignment01part02error.java.
webgrader
The webgrader is available for this assignment. You can test your submitted les before the deadline by submitting them on webhandin and going to http://cse.unl.edu/~cse322/grade, choosing the correct assignment and entering your cse.unl.edu credentials
The script should take approximately 2 minutes to run and produce a PDF.
4.1 The Use of diff
Because Part 1 of this assignment only depends on the symbols in the le, the order in which they are displayed should not be submission dependent. Therefore, diff will be used to compare the output of a particular submission against the output of the solution implementation. In Part 2, the output is sorted and the unique lines extracted, so the order and number of times a semantic error is reported will not a ect the di .
Point Allocation
Component
Points
Part 1
35
Part 2
65
Total
100
6 External Resources
ANTLR
Getting Started with ANTLR v4
ANTLR 4 Documentation
Overview (ANTLR 4 Runtime 4.7.2 API)
7
Commands of Interest
alias
antlr4 = ' java - jar / path / to / antlr -4.7.2 - complete . jar '
alias grun =' java org . antlr . v4 . gui . TestRig '
export
C LA SS PA TH ="/ path / to / antlr -4.7.2 - complete . jar : $C L A S S P A T H "
antlr4
/ path / to / c s c e 3 2 2 a s s i g n m e n t 0 1 p a r t 0 #. g4
javac
-d / path / for /. c l a s s f i l e s / path / to / c s c e 3 2 2 a s s i g n m e n t 0 1 p a r t 0 #*. java
java
/ path / of /. c l a s s f i l e s c s c e 3 2 2 a s s i g n m e n t 0 1 p a r t 0 2 d r i v e r / path / to / i np ut fi le
grun
c s c e 3 2 2 a s s i g n m e n t 0 1 p a r t 0 # c o n n e c t F o u r - gui
Page 4
grun c s c e 3 2 2 a s s i g n m e n t 0 1 p a r t 0 # grun c s c e 3 2 2 a s s i g n m e n t 0 1 p a r t 0 # grun c s c e 3 2 2 a s s i g n m e n t 0 1 p a r t 0 #
c o n n e c t F o u r - gui / path / to / i np ut fi le
c o n n e c t F o u r
c o n n e c t F o u r / path / to / i np ut fi le
Page 5