web代做 | 代写GUI | 代做 c | 代做java | 代写assignment – Homework 01 (Due: Friday, March 5, 2021 ,11 : 59 : 00PM)

Homework 01

web代做 | 代写GUI | 代做 c | 代做java | 代写assignment – 这个题目属于一个web的代写任务, 涵盖了web/GUI/ c /java等程序代做方面, 这个项目是assignment代写的代写题目

java代写 代写java

CSCE 322

1 Instructions

In this assignment, you will be required to scan, parse, and check the semantics of a file that encodes the state of a variation of Gravity Maze. The definition of a properly formatted input file is given in Section 1.1. You will be submitting one.javafile and two.g4(ANTLR) files via web hand-in.

1.1 File Specification
  • The file contains two (2) labeled sections:MazeandMoves. Each section is enclosed by start and end tags (\begin{section}and\end{section}, respectively). The value of the section is set by the:: assignment operator.
  • Movesis an tilde-separated (~) list of move values that appear between\begin{moves}and\end{moves}. Valid moves arec(Clockwise rotation),cc(Counterclockwise rotation), and 180 (180 degree rota- tion).
  • Mazeis a two-dimensional array of space-separated entries that uses alphanumeric symbols to encode the state of the maze. Rows will be ended with a\and theMazewill be begun with a\begin{maze} and ended with a\end{maze}.
  • You may assume that tabs will not appear in the file.
An example of a properly formatted file is shown in Figure 1.
\\beginbegin{{sectionsection} \} \t i t l et i t l e{Moves{Maze}} : :: : \begin\begin{moves{maze}}cc  180  180   c  180  cc  c  c  cc  180  c\end{moves} \end{section}
xx            x x x x x x x x x x x x xx\\\\
xx        x      x    x  x xx\\\\
xx                    2    xx\\\\
xx    g 1   x   x     x    xx\\\\
\endx{mazex} x x x x x x x x x x x x
\end{section}
Figure 1: A properly formatted Gravity Game (G) encoding

The assignment is made up of two parts: scanning the text of the input file and parsing the information contained in the input file.

1.2 Scanning

Construct a combined grammar in a.g4 file that ANTLR can use to scan a supplied Gravity Game encoding. The logic in this file should be robust enough to identify tokens in the encoding and accurately process any correctly formatted encoding. The rules in your.g4file will be augmented with actions that display information about the input file. An example of that output is specified in Section 2.

1

The purpose of the scanner is to extract tokens from the input and pass those along to the parser. For the Gravity Game encoding, the types of tokens that you will need to consider are given in Table 1.

Type Form
Section Beginning \begin{section}
Section Ending \end{section}
Section Title \title{Moves}and\title{Maze}
Assign Value ::
Move Symbol c,cc, orl
Maze Symbol -,g,x, or one (1) or more numerical symbols
Numerical Symbol 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9
Row Ending \\
Maze Beginning \begin{maze}
Maze Ending \end{maze}
List Beginning \begin{moves}
List Ending \end{moves}
White Space (to be ignored) spaces, tabs, newlines
Table 1: Tokens to Consider

1.2.1 Invalid Encodings

For invalid Maze Game encodings, the outputThe unrecognizable token T appears in line L.should display.Twould be the symbol read andLwould be the line of input where the symbol was read. Your scanner should stop scanning the file after an unrecognized token is found.

1.3 Parsing

Construct a combined grammar in a.g4file that ANTLR can use to parse a supplied Gravity Game encoding. In addition to the rules for scanning, there are several parsing rules:

  • Each section appears once and only once. The sections may appear in eitherMoves/Mazeor Maze/Movesorder.
  • There must be more than five (5) rows in a validMaze.
  • There must be more than five (5) columns in a validMaze.
You may assume that each row has the same number of columns, and each column has
the same number of rows.
  • The first row, last row, first column, and last column of theMazemust contain onlyxsymbols.
  • There must be more than five (5) moves in theMovessection.
The semantics of a properly formatted Maze Game encoding are:
  1. Between one (1) and four (4) (inclusive) players must appear in theMaze.
  2. TheMazemust contain exactly one (1)gsymbol.
  3. The number ofxsymbols in theMazemust not exceed 60% of all symbols in theMaze.
  4. c,cc, and 180 must each appear at least once in theMoves.
  5. Extra Credit ( 10 points or Honors contract): The goal must not be adjacent to anxsymbol (considering only the up, down, left, and right directions).

2 Output

2.1 Scanner

Your.g4file should produce output for both correctly formatted files and incorrectly formatted files. For the correctly formatted file in Figure 1, the output would have the form of the output presented in Figure 2

Open Section: \begin{section}
Section Title: \title{Moves}
Designation: ::
Open Moves: \begin{moves}
Move: cc
...
Move: c
Close Moves: \end{moves}
Close Section: \end{section}
Open Section: \begin{section}
Section Title: \title{Maze}
Designation: ::
Open Maze: \begin{maze}
Location: x
...
Location: x
Close Row: \\
Location: x
...
Location: x
Close Maze: \end{maze}
Close Section: \end{section}
Close of File
Figure 2: Truncated Output of Scanner for File in Figure 1

For a correctly formatted file in Part 2, the output would be:This game has p players.wherepis the number of players in theMaze. For the file in Figure 1, the output would beThis game has 2 players..

2.1.1 Invalid Syntax & Semantics in Parsing

For invalid Maze Game encodings in Part 2, a message describing the error should be displayed. For a syntax error (violation of the syntax rules), the output Something unexpected happened on Line L.should be displayed, whereLis the line number where parsing stopped. For that error, the parser should stop processing the file. For a semantic rule violation, the output

The semantic rule R was violated.should be displayed, whereR is the number of the rule (from List 1.3) that was violated, but parsing should continue. Syntax errors in Part 2 should be reported in thesyntaxErrormethod of csce322hw01pt02error.java.

3 Naming Conventions

The ANTLR file for the first part of the assignment should be namedcsce322hw01pt01.g4. The ANTLR file for the second part of the assignment should be namedcsce322hw01pt02.g4. Both grammars should contain a start rule namedgravityGame. The java file for the second part of the assignment should be namedcsce322hw01pt02error.java.

4 webgrader

The webgrader is available for this assignment. You can test your submitted files before the deadline by submitting them on webhandin and going to http://cse.unl.edu/ cse322/grade, choosing the correct assignment and entering yourcse.unl.educredentials 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 file, the order in which they are displayed should not be submission dependent. Therefore,diffwill be used to compare the output of a particular submission against the output of the solution implementation. In Part 2, output will be sorted (and duplicate lines removed), sodiffwill also be used to compared submission and solution output.

5 Point Allocation

Component Points
Part 1
Test Cases 2% 10
Compilation 15%
Total 35%
Part 2
Test Cases 3% 15
Compilation 20%
Total 65%
Total 100%

6 External Resources

ANTLR

Getting Started with ANTLR v ANTLR 4 Documentation Overview (ANTLR 4 Runtime 4.9 API)

7 Commands of Interest

alias antlr4='java -jar /path/to/antlr -4.9.1 - complete.jar'
alias grun='java org.antlr.v4.gui.TestRig'
export CLASSPATH ="/ path/to/antlr -4.9.1 - complete.jar:$CLASSPATH"
antlr4 /path/to/csce322hw01pt0 #.g
javac -d /path/for/. classfiles /path/to/csce322hw01pt0 #*. java
java /path/of/. classfiles csce322hw01pt02driver /path/to/inputfile
grun csce322hw01pt0# gravityGame -gui
grun csce322hw01pt0# gravityGame - GUI /path/to/inputfile
grun csce322hw01pt0# gravityGame
grun csce322hw01pt0# gravityGame /path/to/inputfile