You will be using a Stack to manipulate operator Strings, and a Queue to cretae the postfix expression. Therefore, you need to implement a Stack of Strings and a Queue of Strings. The Stack and Queue operations are declared in the provided interfaces StackIF and QueueIF. Also two classes StackException and QueueException are provided. The TestDriver reads input file in line by line and exercises your In2Post code. Copy the following starter codes and input file, and put them in an Eclipse project:
TokenIter.java
StackIF.java
StackException.java
Stack.java
QueueIF.java
QueueException.java
Queue.java
In2Post.java
TestDriver.java
in
You need to work on the following codes.
A regular definition is a
name = regular expressionwhere name can be used in in other regular definitions.
Valid tokens are numbers and operators, defined by the following regular definitions:
digit = [0-9] number = (digit)+ operator = "+" | "-" | "*" | "/" | "(" | ")"The main method exercises TokenIter; it prints every next token surrounded by square brackets, to check for the lack of white space in the tokens, and produces the following output:
line: [ 15*(26+37) - 489/5*61 - (723-8456789) ] next token: [15] next token: [*] next token: [(] next token: [26] next token: [+] next token: [37] next token: [)] next token: [-] next token: [489] next token: [/] next token: [5] next token: [*] next token: [61] next token: [-] next token: [(] next token: [723] next token: [-] next token: [8456789] next token: [)]
resDB
contains the result of running TestDriver for
input file in
, when in debug mode.
res
contains the TestDriver result for
input file in, when not in debug mode.
Use the Checkin webserver to exercise and submit your code. Submit your a P2.jar file containing Stack.java, Queue.java, and In2Post.java, and TokenIter.java**ONLY**.
Make sure you put ***java** files in your jar (not class files). The TAs can help you creating a proper jar file.