package csc143.data_structures; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; /** * @author Vita Wiebe * @version PA9: Stack/Queue Use, Parser * This program takes a mathematical expression, user-input in * the standard, infix notation, and produces an equivalent * expression written in postfix notation. */ public class Parser extends UnboundedArrayQueue implements ParserInterface { // Fields // String s, the input string from user. // Pre-condition: non-empty. private String s; // Our data structures, for handling the input, reordering, // and eventual output of the postfix form of input. private UnboundedArrayQueue inputQ; private UnboundedArrayQueue outputQ; private UnboundedArrayStack transformStack; // For comparison when parsing the input string. public final String operators = "+-/*%"; /** * Our class constructor. */ public Parser() { } /** * This method parses the input string into individual tokens. *
* For the minimal version of the assignment, this means breaking * the input string into single-character tokens, discarding all * white space. * For the standard version of the assignment, this entails * breaking the input string into contiguous "runs" of alphanumeric * characters (identifiers and integers) and punctuation (operators). *
* Negative numbers are not handled by this tokenizer.
*
* @param input The input string.
* @return A queue object containing the individual tokens.
*/
public UnboundedArrayQueue