Package components.statement
Interface Statement
- All Superinterfaces:
Standard<Statement>,StatementKernel
- All Known Implementing Classes:
Statement1,StatementSecondary
StatementKernel enhanced with secondary methods.-
Nested Class Summary
Nested classes/interfaces inherited from interface components.statement.StatementKernel
StatementKernel.Condition, StatementKernel.Kind -
Method Summary
Modifier and TypeMethodDescriptionvoidParses a single BL statement fromtokensintothis.voidparseBlock(Queue<String> tokens) Parses a maximally long sequence of BL statements fromtokensinto the BLOCKthis.voidprettyPrint(SimpleWriter out, int offset) Pretty printsthisto the given streamoutoffsetspaces from the left margin usingProgram.INDENT_SIZEspaces for each indentation level.Methods inherited from interface components.standard.Standard
clear, newInstance, transferFromMethods inherited from interface components.statement.StatementKernel
addToBlock, assembleCall, assembleIf, assembleIfElse, assembleWhile, disassembleCall, disassembleIf, disassembleIfElse, disassembleWhile, kind, lengthOfBlock, removeFromBlock
-
Method Details
-
prettyPrint
Pretty printsthisto the given streamoutoffsetspaces from the left margin usingProgram.INDENT_SIZEspaces for each indentation level.- Parameters:
out- the output streamoffset- 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
Parses a single BL statement fromtokensintothis.- 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
Parses a maximally long sequence of BL statements fromtokensinto the BLOCKthis.- 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]
-