Module
Variable, Command, Substitution, Grouping
-
Variable
A Snaml Generic variable is a string with letters, digits, and underscores. It's case sensitive. A variable can be used anywhere without declaring its type. In addition, you may assign a value to a variable and access its value.
-
Command
The command-line syntax of Snaml has the form:
command argument1 argument2 ...
where command is a buildin or a defined procedure in the Snaml. Spaces separate a command name and its arguments in a line. Newline and semicolons are line or command terminators. To continue arguments on the
next line, a command must have a backslash in the end of a line. Each command has a return value. To evaluate a command, interpreter substitutes command-line arguments from left to right. It makes a single passing substitution. Snaml commands are cataloged as regular, block, empty, and inline.
-
Regular Command
Regular Command has a typical command-line syntax. Its number of argument is unlimited. There is no direct relation for two commands. A new command can be defined by proc command. For example, set command assigns a value to a variable.
set var value
-
Block Command
Block Command may specify a scope of a set of commands. start command is the beginning of a block command. Snaml specifies the satrt command name with the underscore prefix such as '_command'. A start command may have zero to two arguments called attributes. end command is the end of a block command. The command name has the underscore postfix such as 'command_'. An end command has no argument. The commands between the start and end commands are called content.
Attribute is a list of key/value pairs separated by whitespace. A pair has the format key='value' where key must be a character string (include letters, digits, hypen, period, and underscore). The value may be any of strings or variables. The single quote ' ' groups the value. A key that is not defined as an attribute of a start command will be ignored. A non-declared key will be assigned to its default value when a start command is invocated.
Block commands may be nested. A difference between the block command and regular command is that the attributes of block commands may be inherited. The inner commands in the content of a block command may inherite the attributes of the outer block command. A command in the content is called a child of the outer block command. In contrast, the outer block command is a parent of the inner commands. Finally, the block commmands should be properly paired.
_font "face='verdana' size='2' color='green'"
_b
quote "a block command example."
b_
font_
-
Empty Command
Empty command is a special case of the block command where the content is empty. It has a special syntax with double underscore prefix such as '__command'. It is convenient for a parser to check a program for empty command since there is no end command is expected. Empty command is consistent to the XML syntax such as <element/>.
__img "src='try.gif' width='320' height='240'"
-
Inline Command
Inline command is a shorthand of block command. But it is limited to be a command in the square brackets and acts as an element of an argument. An inline command is represented as '_command_' where two underscores are prefix and postfix of a block command name. Usually it has two arguments: the first one is the attribute of the block command; the second one is the content of the block command. The content of an inline command must be a group of string, a regular or inline command. Inline command must return a value. If inline command has only one argument, this argument is considered as content rather than an attribute. To make one argument consider as attribute you must use the inline empty command. It has the double underscore prefix and one underscore postfix as '__command_'. Typically, an inline command is used inside a short text description.
quote "a inline command [_b_ bold]"
-
Substitution
Dollar sign $ enables variable substitution. It replaces the variable with its value. Variable are useful to mix with other special characters.
set x variable
Square brackets enable command substitution. A command must be inside the brackets. After evaluation of the command, the return value will replace the square bracket string. The brackets maybe nested.
[clock seconds]
Backslash enables next character substitution. The next character or group after the backslash will be replaced by a new representation of the character. Usually backslash \ is widely used to quote a specific character
"inside double quote \" "
"newline \n and tab \t"
-
Grouping
Double quote " " enable inside string substitution. The " character inside the double quote must be disabled with the backslash \" quoting. The grouping value of double quotes is the string inside after substitution.
dobule quote enable variable substitution {$variable}
and command substitution [clock seconds]
Curly braces {} disable substitution inside. All the characters include whitespace, double quotes, even nested curly braces (exclude outmost curly braces) are value of the group. When curly braces are inside the double quote, they will not work as grouping.
curly braces disable variable substitution {$variable}
and command substitution [clock seconds]
|
Copyright© 2000-2002, Neatware. All Rights Reserved.
|
|