Namespace BOOSE
Classes
- AboutBOOSE
V1.09
Basic Object Orientated Software Engineering.
This is a set of classes for implementing the BOOSE language.
To replace class functionality you can either implement the relevant interface to completely replace all functionality, or extend the relevant class and override the interface methods, which will allow the calling of base methods in the original class.
Example of adding a command to BOOSE. Here I will call the new program AppBOOSE and append App to class names (but you can call them what you like).
step 1 extend ICanvas to have your new draw command that will be called when its command is executed, IAppCanvas.
step 2 extend this new interface with a class (AppCanvas) which creates a drawing object (bitmap?) does all the actual drawing.
step 3 extend appropriate command Interface to create a new command class. i.e. Rect(width, height) would extend ICommandTwoParameters.
step 4 extend the original factory if you want to use any of its existing commands (by calling base.MakeCommand() after looking for your new commands) or ICommandFactory if completely replacing it.
BOOSE is restricted via a set of constants that limit its functionality unless the restrictions are turned off. They can only be turned off at the source code level (i.e. by the author only).
1.04 reduced restrictions on graphics commands.
1.06 added restrictions method in evaluation, to move where restrictions are located.
1.08 added new restrctions to Array, moved restrictions from evaluation to Int, Real and Boolean.
1.09 added new restrictions to compound commands and methods, made program size simpler.
1.1 fixed bug stopping restrictions on arrays.
- Array
An array command takes the form "array int myArray 10,2" or "array real prices 10" [array][(type)][(size)][(optional dimentions, 1 if not given)]
- BOOSEException
Generic BOOSE Language exception Extends Exception
- Boolean
Boolean datatype, also used for Conditional Commands.
- Call
Comand to call a previously defined method.
- Canvas
Abstract class that implements CanvasInterface. See CanvasInterface documentation for what to implement. This class handles all the drawing on your system according to above ocumentation. BOOSE does not by default specify a default drawing Canvas (only this).
- CanvasCommand
Derived class to add a drawing surface that implements the ICanvas interface.
- CanvasException
Exception generated by the Canvas class.
- Cast
Cast real values to int values.
- Circle
Draw a circle round the current cursor position.
- Command
Abstract class for commands with a parameter list or expression. This class will seperate the parameters or expression from the command and store in the "ParameterList". The Command's Compile() method is called by the parser and this is expected to set the Command's parameters. CheckParameters
- CommandException
Exception genereted by the StoredProgram class.
- CommandOneParameter
Commands with two parameters. Each command has an Xpos and Ypos that operates from the current cursor position.
- CommandThreeParameters
Commands with two parameters. Each command has an Xpos and Ypos that operates from the current cursor position.
- CommandTwoParameters
Commands with two parameters. Each command has an Xpos and Ypos that operates from the current cursor position.
- CompoundCommand
CompoundCommand is a building block for shared functionality between CompoundCommands, such as ELSE and ENDS
- ConditionalCommand
Extends Var because it has an expression, only this time it directly affects execution.
- DrawTo
Draw a line from to current cursor position to the provided x,y position.
- Else
An Else is like an Endif but it pops the corresponding If off the stack and pushes itself on so that it becomes the corresponding command to the end
- End
End command for If/While/For/Method. BOOSE has only one End type command which has a parameter to say what it belongs so eg. "end if". End checks Boose types for the ciorresponding command (If/While/For/Method) and will likely require a complete rewrite to replcae those commands. It would probbaly be easier to replace Parser, StoredProgram, CompoundCommand and this. Look at the metghods each provides, if you like, and try and fill in their fucntionality.
- Evaluation
An evaluation encompasses all things that can have a value, such as variables, expressions and conditions used in loops and ifs.
- FactoryException
exception genereted by the StoredProgram class
- For
For command. Adds processing at compile() and execute() to process a for command.
- If
If command. Adds processing at compile() and execute() to process an if command.
- Int
Command Class to define and store integer values.
- Method
Method declaration command. Overcoming method restrictions will require a complete rewrite. It would be simpler to do this after Parser and StoredProgram. You are getting to the stage where you need to do a big rewrite.
- MoveTo
Set the cursor position, for subsequent drawing operations, to the provide x,y position.
- Parser
The parser takes a program, who's lines are seperated by "\n", and attempts to create a StoredProgram. Once the SToredProgram has been created it then can be run. As much processing that can be done is done here because it has no run penalty (other than starting the program). Command objects are created and their parameters processed as much as possible. Variables are checked for existance but expressions cannot be processed until runtime.
- ParserException
exception genereted by the Parser class to denote syntax errors
- Peek
Peek an array, i.e. get the value of an array cell. [variable] = peek [array name] [row] [optional column]
- PenColour
Set the pen for the next drawing operations to the provided r,g,b colour.
- Poke
Poke an array, i.e. set the value of an array cell. poke [array name] [row] [optional column] = [value]
- Real
Class for a Real Number Variable.
- Rect
Draw a rectangle of provided with and heigh with the current cursor position being the top left corner.
- RestrictionException
Exception thrown when restrictions are breached. If you get this you need to write your own code for the facility.
- StoredProgram
A collection class for storing a program of Command objects, extends ArrayList to add a program counter and a flag to indicate that the syntax is ok and the program valid. Adds methods below to process variables and methods and implements flow of control for ifs and loops.
- StoredProgramException
exception genereted by the StoredProgram class
- VarException
Exception raised by variable commands.
- While
While command. So far blank as it doesn't do anything beyond ConditionalCommand but it makes the code clearer (in the factory).
Interfaces
- ICanvas
Implement ICanvas for your BOOSE renderer. It has an Xpos and Ypos of the current cursor position, and a pen colour. Your class should implement the methods below to draw on its "bitmap" (i.e. it may not be a bitmap, it could draw in ASCII text for example).
- ICommand
Interface for new commands. Any new Command class should implement this interface and be generated by a CommandFactory that implements the ICommandFactory interface. Contains methods to set the Command up after its creation, manage its parameters when it is compiled and execute it when it is called.
- ICommandFactory
To add commands to BOOSE you must create a CommandFactory that uses this interface. You should extend the existing BOOSE:CommandFactory (which implements this interface) and then implement the MakeCommand() method. It shoudld create a new command object based on the string passed. Any standard BOOSE commands can then be made by calling base.MakeCommand();
- IEvaluation
IEvaluation adds properties to get and set an Evaluations name, value and expression. An evaluation can be a variable declaration, such as "int total" or "real area". It can be change of value of a variable, such as "total = total + 1", the part after the "=" is an referred to as an "expression". In the first two cases the parser will generate an Int object and a Real Object. In the third case it will generate a "Evaluation" object.
- IParser
The Parser Class takes a BOOSE program as a String with each command seperated by '\n' and creates command objects for each valid command and stores them in the passed in StoredProgram. Exceptions are generated for any syntax errors. When each valid command is generated its Compile() method is called. The valid command will have its parameters processed and any variables identified. It is the role of StoredProgram to run the commands.
Enums
- ConditionalCommand.conditionalTypes
Enumerated type to represent individual conditional commands.