# Map to the BeanShell Source

This is a rough guide to the BeanShell source code. See comments in the individual files for more information.

## Package Areas

- bsh Primary bsh source package
- bsh/util Optional bsh utilities
- bsh/commands Bsh scripts and Java code which implement Bsh commands
- bsh/lib Bsh support files

### The bsh package

Parse Tree Classes

- BSH*.java
  e.g. BSHAllocationExpression.java, BSHAmbiguousName.java, BSHArguments.java

  These are the abstract syntax tree nodes (subclasses of SimpleNode) - the internally compiled form of a bsh script. Instances of these nodes are created by the parser to represent the bsh syntax read from a script.

  The original class structure was created by JJTree but these files are *not* automatically generated any longer. They have been implemented with the real code that executes their syntax.

  Most BSH nodes are referenced only through their eval() method which causes them to evaluate any child nodes and execute their behavior, returning an object to the caller.

- SimpleNode.java Base class for BSH nodes.
- ReturnControl.java Support for control flow of a return statement.

I/O support

- CommandLineInputStream.java Basic support for command line input.
- Console.java Support for starting a GUI console.
- ConsoleInterface.java
- File.java File I/O that works relative to the bsh notion of the working directory.
- ExternalVars.java Interface for setting/getting variables on a bsh interpreter.

Exceptions

- EvalError.java A problem occurred while parsing or running a bsh script.
- InterpreterError.java A fatal internal error occurred.
- TargetError.java The target of a bsh operation threw an exception which the script is allowed to handle.

Name Resolution Support

- Name.java
- NameSpace.java
- ForBodyNameSpace.java

Object / Primitive Wrappers

- Primitive.java Wraps a primitive numeric value, char, boolean, void, or null.
- LHS.java Wraps the left hand side of an assignment

Reflection Support

- Reflect.java
- ReflectError.java

Bsh Scripted Object Support

- This.java The type of a bsh scripted object (a 'this' reference).
- JThis.java For backwards compatibility with jdk1.2. Adds explicit Swing support.
- XThis.java Extended 'this' with support for the new jdk1.3 proxy mechanism.

Automatically Generated Files
The following files are automatically generated by JTree or JavaCC and should *not* be modified directly.

- Interpreter.java This is the actual parser class.
- ASCII_UCodeESC_CharStream.java
- TokenMgrError.java
- Token.java
- ParseException.java
- InterpreterConstants.java
- InterpreterTokenManager.java
- InterpreterTreeConstants.java
- JJTInterpreterState.java
- Node.java