Comments and Whitespace

Comments that you include are read as whitespace during the compilation of source code. Comments can document code or can prevent code from compiling.

// Enable axes
Enable
([X, Y])

/* Home axes
   Home([X, Y]) */

Comments can be single-line comments or multi-line comments. For information about how to add metadata comments to your AeroScript program or library, see Metadata Comments.

Single-Line Comments

The syntax of a single-line comment must match the regular expression that follows.

["//";'][^\n]*\n

A single-line comment must start with a double forward slash (//), a semicolon (;), or a single quote character ('). All characters between the start of a comment and the next new line (or the end-of-file if the comment starts on the last line in the file) are ignored during compilation.

You can include single-line comments at the end of a line that contains code.

Enable([X, Y]) // Enable axes

Multi-Line Comments

The syntax of a multi-line comment must match the regular expression that follows.

["/*"].*[^"*/"]

That is, a multi-line comment starts with a forward slash followed by an asterisk (/*), contains any number of characters in between (including newlines), and ends with an asterisk followed by a forward slash (*/).

Multi-line comments do not need to span multiple lines. They can start and terminate on the same line.

/*
  Everything in this block is ignored by the compiler
   Enable([X, Y, Z])
   Home([X, Y, Z])
   BrakeOff([X, Y, Z])
*/

Disable([X, Y, Z]) /* Multi-line comment on a single line */

Whitespace

You can use whitespace to make the readability of your AeroScript programs better. Whitespace in AeroScript is made up of spaces, tabs, and newlines. Spaces and tabs can be used to separate expressions and operators that are on the same line. Most statements and expressions in AeroScript show on a single line, but in some constructs, you can include newlines that won't have an effect on compilation. These constructs include:

  • Function declarations and function call expressions

  • Binary expressions

  • Array dimensions in array declaration statements

  • Array indices in array access expressions

  • Array and struct initializer expressions

Refer to the example that follows to see how whitespace can be used in these constructs.

/* You can place newlines after the comma for each argument
   in a function declaration or a function call expression. */
function MyAdd($val1 as integer,
               // An arbitrary amount of newlines is allowed.
               $val2 as integer) as integer
   return $val1 + $val2
end
				
program
   var $sum as integer = MyAdd(1, 
                               2)

/* You can place newlines after the binary operator in
   a binary expression. */
var $otherSum as integer = (2 +
                            2)
if ($sum ˃ 0) &&
   /* This rule is valid even if the expression is not surrounded
      by parentheses. */
   $otherSum > 0
   $sum = $sum + $otherSum
end

var $matrix[2 /* Newlines can be placed inside array dimensions,
                 but not between the square brackets in a 
                 multi-dimensional array declaration. */ 
][2] = [
        [1,   0], // Notice that spaces are ignored
        [0,1]     // between values in an initializer.
       ]

var $isIdentityMatrix as integer = ($matrix[0][0] && $matrix[1
/* The same rule for multi-dimensional array declaration
   applies for multi-dimensional array access. */
                                    ][1])
end

Next Topic: Metadata Comments