3. Syntax
Since mCL is a clone of Tcl (Tool Control Language), its syntax is similar to Tcl that consists of variable, command, substitution and grouping.
A variable is represented as a string of case sensitive letters, numbers, and underscore bars. You can use a variable without declaring its type, assign a value to a variable, and get a variable value by substitution. A mCL command has the format
command argument1 argument2 ...
Where command is a build-in or a defined procedure in the mCL. Spaces separate a command name and its arguments in a line. Newline and semicolons are command terminators. To evaluate a command, mCL engine substitutes command arguments from left to right, which makes a single passing substitution, then executes the command and return a value.
set app [application]
$app create
In this example, set command assigns a value returned from application to variable app. The square brackets [...] enables command substitution, that is a command inside the brackets is evaluated and its value is the return value of the command. The brackets maybe nested.
A command name could be a variable to represent an object. app is an object variable and $app is its value. The dollar sign $ means variable substitution with its value. ${variable} is used to distinguish variable from other special characters.
Like C language the backslash \ enables next character substitution. For example, the \" and \$ disable the special meaning of these characters in mCL. The \n and \t are interpreted as newline and table in a string. The backslash also allows a line continue when a line is too long to write.
Double quote "..." and curly braces {...} collect several items as one item. The double quote enables inside substitution and curly braces disables inside substitution. It is important to have the balanced curly brace pair.
|