mathenslaver v1.0.0
MathEnslaver
A project that will eventually do lots of calculations
The scripting language
The scripting language consists of statements, one per line. Lines are read until the first #
. Empty lines are
ignored too. Statements define components, the parts that your model is made of.
Statements are written as follows:
type name:argument1;argument2;...;argumentn
where type
is the type of statement (refer to the table for possible types), name
is the a unique name for the
component that this statement defines. argument...
are arguments for this statement. More arguments can be added
by appending another semicolon (;
) and the next argument to the statement.
The first statement in a script must be a model
statement.
Two components are added by default. The first component, t
is a state which counts the amount of seconds in the
simulation since the start. The second component, interval
is a constant which determines how much of a second
passes in every update of the model. Lower values for the interval result in a more accurate model but also increase
the time it takes to run. Both of these components have settings in the model statement.
Statements
These are all statement types.
model:start;step;condition
Provides information about this model. There must be exactly one of these statements in every script.
start
: the first value oft
;step
: the amount to incrementt
with on every iteration. (The value of the interval constant);condition
: a condition that is checked after every iteration. If it evaluates to false, no more calculations will be done.
const:value
Defines a constant that can be used in other statements.
value
: the value of this constant.
funct:expression
Defines a function. Actually, a function is just a mathematical expression.
expression
: the expression to calculate the value of the function with. This can contain values returned by other statements.
state:start;components
Defines a state.
start
: The value for this state to start at;components
: A list of values, seperated by commas (,
), that are added to the current value of this state on every step.
Names
Names are how you will use components inside other components. They can be of any length. However, names may only
consist of letters (both upper and lower case) and underscores (_
).
Expressions
Expressions are a series of characters. Names of components can be used, and so can mathematical operators.
Conditions
TODO