General Definitions
Infix Expressions
<expression> ::= <arithmetic expression> |
<string expression> | <character expression>
| <boolean expression> | <if-then-else expression>
| <Lisp function> | <list expression>
| <table lookup> | ( <expression> )
| print( <expression> )
Print is a function that can be applied to any list of expressions that will print the resulting value of the expressions to the Lisp Interpreter Window and return the value of the last expression as its result.
Expressions inside functions or if-then-else constructs should be place in parentheses for proper grouping. For example, sqrt((2 + 2)), not sqrt(2 + 2).
Lisp expressions, table lookups, parenthesized expressions, and printed expressions will return a value of one of the four basic types: arithmetic, string, character, or boolean.
Arithmetic Expressions
<arithmetic expression> ::= <number> | <arithmetic attribute reference> | <arithmetic function> | <unary arithmetic operator> <arithmetic expression>| <arithmetic expression> <binary arithmetic operator> <arithmetic expression>
- An <arithmetic attribute reference> is simply an attribute reference in which the attribute contains a numeric value. For example, the geometry rules reference the user-entered attributes such as length, width, and height.
- The arithmetic functions
are:
- absolute value (abs)
- arc-tangent (atan), cosine (cos), and sine (sin) for radian values
- exponential (exp)
- modulus (mod)
- square root (sqrt)
- minimum (min)
- maximum (max)
Arithmetic functions are written as follows:<arithmetic function> ::= abs(<arithmetic expression>)| atan(<arithmetic expression>) | cos(<arithmetic expression>) | sin(<arithmetic expression>) | exp(<arithmetic expression>) | mod(<arithmetic expression> <arithmetic expression>)| sqrt(<arithmetic expression>) | min( { <arithmetic expression> }+ ) | max( { <arithmetic expression> }+ )
- A unary arithmetic
operator applies positive or negative value to an expression:
<unary arithmetic operator> ::= + | -
- While a binary arithmetic
operator is one of the mathematical operations: exponents (** or ^),
multiplication (*), division (/), addition (+), and subtraction (-).
<binary arithmetic operator> ::= ** | ^ | * | / | + | -
Exponentiation is not valid for fractional powers of negative numbers.
inches-or-mm(4.0 100.0)would return 4.0 if the project units is set to inches and 100.0 if project units is set to metric.
String Expressions
<string expression> ::= ‘{<character>}*’ | <string attribute reference> | <string function> | <string expression> + <string expression>
- A <string attribute reference> is simply an attribute reference in which the attribute contains a string value. For example, the label element of a piece of equipment refers to the string that is the display name or tag of the equipment.
- The string functions are:
- make-string returns the string representation for the result of its argument expression; and
- string-search determines if the target string is contained within the string being searched.
<string function> ::= make-string(<expression>)| string-search(<target-string> <string-to-search>)
To eliminate items that contain a specific string, preface the function with not, for example:not(string-search("pump" equipment.display_name))
- + denotes concatenation when used with two strings.
Character Expressions
- First-char which returns the first character of the string expression for the result of its argument expression. (i.e. first-char(abc) would return a)
- Second-char which returns the second character of the string expression for the result of its argument expression. (i.e. second-char(abc) would return b)
<character expression> ::= first-char(<string-expression) | second-char(<string-expression)
first-char(<string expression> is #\<character>)
Boolean Expressions
<boolean expression> ::= <expression> | not <boolean expression> | <boolean expression> or <boolean expression> | <boolean expression> and <boolean expression> | <arithmetic expression> <math comparison operator> <arithmetic expression> | <string expression> <equality comparison operator> <string expression> | <character expression> <equality comparison operator> <character expression> | <boolean expression> <equality comparison operator> <boolean expression>
<equality comparison operator> ::= is | == | !=
Equality comparison operators are typically used in if clauses in
expressions or when statements for rules. For example, the phrase
WHEN nozzle.type is inlet is used to define the placement of
inlet nozzles on equipment.
- The mathematical comparison operators are:
- less than (<)
- less than or equals to (<=, =<)
- greater than (>)
- greater than or equals to (>=, =>)
- equality (is, ==)
- inequality (!=)
<math comparison operator> ::= < | <= | => | > | >= |
=> | is | == | !=
If-Then-Else Expressions
<if-then-else expression> ::= if (<expression>) then (<expression>) [else (<expression>)]
Lisp Functions
<Lisp function> ::= lisp-function(<Lisp function name> {<expression>}* ) | <list expression> | dpp-xpos(<list expression> | dpp-ypos(<list expression> | dpp-zpos(<list expression>Dpp-xpos, dpp-ypos, and dpp-zpos get the first, second, and third values of a list to decompose a 3D point into coordinates.
List Expressions
<list expression> ::= point(<arithmetic expression> <arithmetic expression> <arithmetic expression>) | <list-valued attribute reference> | <expression> & <expression> | <list expression> + <list expression> | <list expression> - <list expression> | <list expression> > <list expression> | <list expression> < <list expression> | <list expression> >= <list expression> | <list expression> <= <list expression> | <expression> in <list expression>
- Point constructs a list from its three arguments.
- & forms a list of its arguments if they are not lists or appends the lists together if they are lists.
- + and - perform vector addition and subtraction if the lists are numeric and the same length.
- < and > are comparison operators: proper subset of and proper superset of, respectively. Likewise, <= and >= mean subset of and superset of.
- in is true if the result of the first expression is an element of the second.
Table Lookup
Table lookup allow syou to pull information from one of the data tables (see Appendix A - Default Data Tables).
<table lookup> ::= table-lookup(<table name> {<expression>}+) | table-round(<table name> {<expression>}+) | table-round-up(<table name> {<expression>}+) | table-round-down(<table name> {<expression>}+) | table-interpolate(<table name> {<expression>}+) | table-project(<table name> {<expression>}+)The table name and any column names should be strings. Expressions may be used to specify key values.
Descriptions of table lookup functions is in Table Functions.