Aspen SCM‎ > ‎Expert System‎ > ‎2. Flow of Control‎ > ‎

2.5 Comments

Types of Comment

There are two types of comment which may appear in the Description of a rule:

  • “in-line” comments beginning /* and ending */

  • lines where NOTE is the first token in the Code.

In addition, where the Code of a line gives the name of a rule, the Description is treated as a comment. More generally, the contents of Descriptions are ignored between the end of the conclusion for one rule in a rule set and the IF clause at the start of the next rule.

In-line Comments

Although having the same appearance as the delimiters of in-line comments in other languages, /* and */ behave more as tokens in Aspen SCM Expert System. The start of an in-line comment is only recognised if the /* is preceded by whitespace or a bracket. Once an in-line comment has started, there is no further need for whitespace and the in-line comment ends when */ is found. A statement or structural keyword (AND, OR or brackets) can follow immediately after the / of */ without further whitespace. This means that it is safe to let in-line comments continue to the end of a line even if the next line starts in column 1 of the Description.

In-line comments can continue over many lines but may not be nested. This is because the parser only recognises a single state of “being in an in-line comment” rather than the “depth of in-line commenting”. Thus however many /*’s are recognised, the parser remains in the state of “being in an in-line comment”. When it reaches the first */ it switches back out and tries to interpret the tokens as statements. In order to avoid problems when cutting and pasting code, it is safer to make each line self-contained with its own /* at the start and */ at the end.

In-line comments are not permitted within a statement (i.e. the sequence of up to 10 tokens) but can appear anywhere among the structural keywords AND and OR and brackets.

NOTE

Whole lines can be commented out by putting NOTE as the first token in the Code. So long as there is a blank after NOTE, it is possible to have further characters in the Code. This means that if you may wish to remove the NOTEs later, for instance because you are commenting out executable code, you can replace AND by NOTE AND and OR by NOTE OR.

Beware of mixing NOTEs and in-line comments: in some circumstances the interpreter mis-branches if NOTE appears in the Code on the next line after a Description which ended with an in-line comment.


Back                                Next
Comments