Language Specification

This is a quick introduction to the language itself. It was designed to be a simple language - such that non-technical people could actually read and write it. It should therefore not be too difficult to learn. There is, however, one or two catches that may seem unintuitive to a programmer.

“The Result”

The most important part of the language is that every statement applies in some way to “The Result”. This means that you won’t find a statement that explicitly assigns the result to some value.

Multi-part Result

That said, the Result does exist of multiple parts: * Named: Each part of the result will have a name. A statement can be applied to a particular named part of the result where applicable. * Default: There is also the default Result. This is essentially the part of the result that does not need to be named in a statement.

The Environment

When a BBL program is executed, a set of variables will be set in what we will call the Environment. These variables are available for use in the program.

The intention with the Basic Business Language is that it will be run as part of a larger system. This system is therefore responsible for setting up an appropriate environment for the BBL programs to run in. That said, the BBL also provides a statement - With (see below) - that allows the user to override an existing variable, or define a new one.

Statements

A program is a collection of Statements. The lowest level statements modify “The Result”.

Conditions

Most statements can have a condition that determines whether that statement is evaluated or not. This is where the “rules engine” part of the Basic Business Language comes in.

Statements that Do

Modification statements modify the result. Current Modification statements include:

Add

Adds the given value to the current result. It can take an optional condition.

add <value> [ if <condition> ]

The value can be any arithmetic expression, and will be added to the current result.

Set

Sets the current result to a given value. It can take an optional condition.

set <value> [ if <condition> ]

Statements that Set Scope

Scoping, or Blocking statements does not modify the result, but it modifies the environment in order to steer the Modification statements towards doing the right thing. Current Scoping statements include

Do

The Do statement will group a list of statements together. It takes an optional condition.

do [ if <condition> ]
  (Statement)+
end

This is useful for performing a series of modifications to the current result if one particular condition is met.

With

The With statement allows you to set one or more variables in the environment for the duration of one statement. This one statement can be a Do statement, which allows you to essentially set a variable for multiple statements.

with ( <variable name> = <value> )+ statement

For

The For statement allows you to do a modification to a specific part of a multi- part result. All modification statements will modify the “current result”, which means either the default result, or a specific named result, as specified by the For statement.

for <result name> Statement

Any name can be given for as the result that should be updated. If it doesn’t exist, it will be created and added to the multi-part result.