Interface Statement

All Superinterfaces:
Standard<Statement>, StatementKernel
All Known Implementing Classes:
Statement1, StatementSecondary

public interface Statement extends StatementKernel
StatementKernel enhanced with secondary methods.
  • Method Details

    • prettyPrint

      void prettyPrint(SimpleWriter out, int offset)
      Pretty prints this to the given stream out offset spaces from the left margin using Program.INDENT_SIZE spaces for each indentation level.
      Parameters:
      out - the output stream
      offset - the number of spaces to be placed before every nonempty line of output; nonempty lines of output that are indented further will, of course, continue with even more spaces
      Updates:
      out.content
      Requires:
      out.is_open and 0 <= offset
      Ensures:
      out.content =
       #out.content * [this pretty printed offset spaces from the left margin
                       using Program.INDENT_SIZE spaces for indentation]
    • parse

      void parse(Queue<String> tokens)
      Parses a single BL statement from tokens into this.
      Parameters:
      tokens - the input tokens
      Updates:
      tokens
      Replaces:
      this
      Requires:
      [<Tokenizer.END_OF_INPUT> is a suffix of tokens]
      Ensures:
      if [a statement string is a proper prefix of #tokens] then
      this =
       [Statement corresponding to statement string at start of #tokens]  and
      #tokens = [statement string at start of #tokens] * tokens
      else
      [reports an appropriate error message to the console and terminates client]
    • parseBlock

      void parseBlock(Queue<String> tokens)
      Parses a maximally long sequence of BL statements from tokens into the BLOCK this.
      Parameters:
      tokens - the input tokens
      Updates:
      tokens
      Replaces:
      this
      Requires:
      [<Tokenizer.END_OF_INPUT> is a suffix of tokens]
      Ensures:
      if [there is a block string b that is a prefix of #tokens]  and
        [the first token past b in #tokens cannot begin a statement string] then
      this =
       [BLOCK Statement corresponding to a block string at start of #tokens
        that is immediately followed by a token in #tokens that cannot begin
        a statement string]  and
       #tokens =
        [a block string at start of #tokens that is immediately followed
         by a token in #tokens that cannot begin a statement string] * tokens
      else
      [reports an appropriate error message to the console and terminates client]