Difference between revisions of "NumML Language Reference"
| Line 38: | Line 38: | ||
==Syntax Rules for <code>@=</code>== | ==Syntax Rules for <code>@=</code>== | ||
''LHS'' can be | ''LHS'' can be: | ||
:An identifier | |||
:A call expression of the form: | |||
::<code>deriv(''ident'')</code> | |||
::<code>initial(''ident'')</code> | |||
::<code>update(''ident<sub>1</sub>'', ''ident<sub>2</sub>'', ...)</code> | |||
''RHS'' can be | |||
: A computation expression when ''LHS'' is either <code>deriv</code> or <code>initial</code> | |||
: An identifier when ''LHS'' is <code>update</code> | |||
Revision as of 18:08, 4 July 2025
What is NumML?
NumML is a small, domain-specific language (dsl) for coding SD models and configuring the UI of a Numerus WebKit (NWK) site. It is used in URAM models and in the Configuration Window. This document serves as reference for NWK authors and users wishing to use NumML in their designs.
NumML Operators
NumML uses Javascript syntax extended with 2 infix operators (@= and #=) that are not recognized as meaningful to Javascript. NWK uses a Javascript parser extended to accept these operators to analyze NumML code and respectively generate code or change the value of specific configuration parameters. Each NumML statement has the form:
LHS
@=RHS
LHS@#RHS
with slightly different rules for what is allowed on each side of the operator. In discussing NumML syntax we use the following terms:
Language Categories
- Constant
- Either a string constant enclosed in single or double quotes (
"SIR Model"",'Infection Stats') or a number in decimal (3.1415) or scientific notation (3.14159e5). - Identifier
- Equivalent of a Javascript variable such as
Sigma,N,beta, etc. - Unary Expression
- An unary operator modifying a term, such as
-10or-Sigma. - Call Expression
- A function name followed by a comma-separated sequence of arguments enclosed in parentheses. The function name must be an identifier; the arguments can be any list of terms.
- Term
- Either a constant, identifier, unary expression, or a call expression using one of the following function names, which differ for
@=and@#. These functions are discussed below. @=:
choose,multinomial,binomial,chooseUniform,poisson,flip,normal,irandom,random,PI,PI2,Pi2,Pi34,degToRad,radToDeg,cos,sin,tan,acos,asin,atan,atan2,cosh,sinh,tanh,acosh,asinh,atanh
@#:
legend,phase,title,statDat,statParam,integration,statRuns,statLo,statHi,min,max,step,value,dom,xlabel,ylabel,interval
- Computational Expression
- A single term or a sequence of terms connected using arithmetic operators
+,-,*/, or any other legal Javascript operators. - Array
- A comma-separated sequence of terms enclosed in square brackets; e.g.,
[Sigma, foo(1,2,3), 15.123e3].
Syntax Rules for @=
LHS can be:
- An identifier
- A call expression of the form:
deriv(ident)initial(ident)update(ident1, ident2, ...)
RHS can be
- A computation expression when LHS is either
derivorinitial - An identifier when LHS is
update