- /* D I E S E L
-
- Dumb Interpretively Evaluated String Expression Language
-
- This "Dumb Interpretively Executed String Expression Language" is the
- kernel of a macro language you can customise by adding C code and
- embedding it into your program.
-
- It is short, written in portable C, and is readily integrated into any
- program. It is useful primarily to programs which need a very
- rudimentary macro expansion facility without the complexity of a full
- language such as Lisp or FORTH.
-
- DIESEL copies its input directly to the output until a macro
- character, "$" or quoted string is encountered. Quoted strings may be
- used to suppress evaluation of sequences of characters which would
- otherwise be interpreted as macros. Quote marks may be included in
- quoted strings by two adjacent quote marks. For example:
-
- "$(if,1,True,False)="""$(if,1,True,False)""""
-
- Status retrieval, computation, and display are performed by DIESEL
- functions. The available functions are as follows. User-defined
- functions are not implemented; what you see is all you've got.
- Naturally, if you embed DIESEL in your application, you'll add
- functions that provide access to information and actions within your
- own program. DIESEL's arithmetic functions accept either floating
- point or integer arguments, and perform all calculations in floating
- point.
-
- DIESEL String Functions
- -----------------------
-
- $(+,,,...)
- The sum of the numbers , , ... is returned.
-
- $(-,,,...)
- The result of subtracting the numbers through from
- is returned.
-
- $(*,,,...)
- The result of multiplying the numbers ,,... is
- returned.
-
- $(/,,,...)
- The result of dividing the number by ,... is
- returned.
-
- $(=,,)
- If the numbers and are equal 1 is returned,
- otherwise 0 is returned.
-
- $(,)
- If the number is less than 1 is returned, otherwise
- 0 is returned.
-
- $(>,,)
- If the number is greater than 1 is returned,
- otherwise 0 is returned.
-
- $(!=,,)
- If the numbers and are not equal 1 is returned,
- otherwise 0 is returned.
-
- $(,)
- If the number is less than or equal to 1 is
- returned, otherwise 0 is returned.
-
- $(>=,,)
- If the number is greater than or equal to 1 is
- returned, otherwise 0 is returned.
-
- $(AND,,,...)
- The bitwise logical AND of the integers through is
- returned.
-
- $(EQ,,)
- If the strings and are identical 1 is returned,
- otherwise 0.
-
- $(EVAL,)
- The string is passed to the DIESEL evaluator and the result
- of evaluating it is returned.
-
- $(FIX,)
- The real number is truncated to an integer by discarding
- any fractional part.
-
- $(IF,,,)
- If is nonzero, is evaluated and returned.
- Otherwise, is evaluated and returned. Note that the
- branch not chosen by is not evaluated.
-
- $(INDEX,,)
- is assumed to contain one or more values delimited by the
- macro argument separator character, comma. selects one of
- these values to be extracted, with the first item numbered zero.
-
- $(NTH,,,,)
- Evaluates and returns the argument selected by . If
- is 0, is returned, and so on. Note the difference
- between $(NTH) and $(INDEX); $(NTH) returns one of a series of
- arguments to the function while $(INDEX) extracts a value from a
- comma-delimited string passed as a single argument. Arguments not
- selected by are not evaluated.
-
- $(OR,,,...)
- The bitwise logical OR of the integers through is
- returned.
-
- $(STRFILL,,)
- Returns the result of concatenating of .
-
- $(STRLEN,)
- Returns the length of in characters.
-
- $(SUBSTR,,,)