Statement1Parse1 - import import import import import...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
import components.queue.Queue; import components.simplereader.SimpleReader; import components.simplereader.SimpleReader1L; import components.simplewriter.SimpleWriter; import components.simplewriter.SimpleWriter1L; import components.statement.Statement; import components.statement.Statement1; import components.utilities.Reporter; import components.utilities.Tokenizer; /** * Layered implementation of secondary methods {@code parse} and * {@code parseBlock} for {@code Statement}. * * @author --- * */ public final class Statement1Parse1 extends Statement1 { /* * Private members -------------------------------------------------------- */ /** * Converts {@code c} into the corresponding {@code Condition}. * * @param c * the condition to convert * @return the {@code Condition} corresponding to {@code c} * @requires [c is a condition string] * @ensures parseCondition = [Condition corresponding to c] */ private static Condition parseCondition ( String c) { assert c != null : "Violation of: c is not null"; assert Tokenizer . isCondition (c) : "Violation of: c is a condition string"; return Condition . valueOf (c.replace('-', '_').toUpperCase()); } /** * Parses an IF or IF_ELSE statement from {@code tokens} into {@code s}. * * @param tokens * the input tokens * @param s * the parsed statement * @replaces s * @updates tokens * @requires [<"IF"> is a proper prefix of tokens] <<<<<<< .mine * @ensures * * <pre> * if [an if string is a proper prefix of #tokens] then * s = [IF or IF_ELSE Statement corresponding to if string at start of #tokens] and * #tokens = [if string at start of #tokens] * tokens
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
* else * [reports an appropriate error message to the console and terminates client] * </pre> */ private static void parseIf (Queue<String> tokens, Statement s) {
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern