Class BlockStatments

All Implemented Interfaces:
KeyListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class BlockStatments extends Console
Example code illustrating how block control structures could be implemented.

Sample session

JEP > a=3
3.0
JEP > IF a>2
JEP  > IF a>3
JEP   > b=4
skipped
JEP   > ELSE
JEP   > b=3
3.0
JEP   > ENDIF
JEP  > ELSE
JEP  > b=2
skipped
JEP  > ENDIF
JEP > b
3.0
JEP >
This code does currently allow looping statements.
See Also:
  • Field Details

    • states

      protected Stack states
      Indicates current state where in
    • conds

      protected Stack conds
  • Constructor Details

    • BlockStatments

      public BlockStatments()
  • Method Details

    • main

      public static void main(String[] args)
      Creates a new Console object and calls run()
    • testSpecialCommands

      public boolean testSpecialCommands(String command)
      Catches macros which are not handled by JEP
      Overrides:
      testSpecialCommands in class Console
      Parameters:
      command -
      Returns:
      false - stops further processing of the line
      See Also:
    • processEquation

      public void processEquation(Node node) throws ParseException
      Evaluates a node, but only if the state corresponds to the conditionValue. Also saves the result of evaluation in conditionValue for use in subsequent calls
      Overrides:
      processEquation in class Console
      Parameters:
      node - Node representing expression
      Throws:
      ParseException - if a Parse or evaluation error
    • printIntroText

      public void printIntroText()
      Prints introductory text.
      Overrides:
      printIntroText in class Console
    • getPrompt

      public String getPrompt()
      Description copied from class: Console
      Prints the prompt string.
      Overrides:
      getPrompt in class Console
    • printHelp

      public void printHelp()
      Description copied from class: Console
      Print help message.
      Overrides:
      printHelp in class Console