Syntax and Reserved Keywords
We tried to talk it over...
But the words got in the way.
- Leon Russell
General Syntax Rules for the Aztec Programming Language
Aztec is an expressive programming language with a relatively small number of rules. This page describes Aztec identifiers, literal constants, reserverd keywords, statement types, comments and general syntax rules. At a high level, an Aztec program consists of one or more source modules. Each module (a source file or a source string) is simply a collection of separate Aztec statements, and each statement is governed by a set of syntax rules. The general rules which apply to all statements are listed here, and any statement specific rules are listed on the pages describing those statements.
♦ The following rules define a valid Aztec identifier, applicable to all names in the language, including data, methods, classes, types and spaces
♦ The first character in every Aztec identifier must be a letter (‘A’–‘Z’ or ‘a’–‘z’) or an underscore character (‘_’).
♦ All other characters in an Aztec identifier must be a letter, a number (0-9) or an underscore.
♦ Aztec identifers are case sensitive and can be any length.
♦ Aztec Comments
♦ # - Single line comment. All characters following the ‘#’ character are treated as comments.
♦ /*..*/ - Multi-line comment. All characters within ‘/*’ and ‘*/’ characters are treated as comments.
♦ General Syntax Rules
♦ Any number of white space characters are allowed between two tokens. No spaces are required between identifiers/keywords and operators or parentheses, but when separating two identifiers or keywords, at least one white space character is required.
♦ Statements can be automatically continued onto the next line. The compiler will keep searching to the next line to satisfy the syntax requirements of the statement it’s processing.
♦ The semi-colon delimiter (‘;’) for end of statement is OPTIONAL, and is typically not used. If a statement ends on the same line that the next statement begins, a semi-colon is required between those two statements.
♦ Blank lines are permitted anywhere to improve readability.
♦ Valid white space characters include space (Char(32)), formfeed (Char(12)), and horizontal/vertical tabs (Char(9),Char(11)). Each source code record can be terminated using a single line feed character (Char(10)) or a carriage return / line feed combination (Char(13),Char(10)).
♦ Literal Constants
♦ Integer Constants
♦ An integer constant can begin with a positive sign (+) or a negative sign (-). The number is positive if no sign is used.
♦ An integer value can be specified as decimal (126), binary (0b01111110) or hexadecimal (0x7e). Octal support will be added in the future.
♦ Floating Point Constants
♦ A floating point constant can begin with a positive sign (+) or a negative sign (-). The number is positive if no sign is used.
♦ A floating point value can be specified with or without a decimal exponent (-583.02 or -5.8302E2).
♦ String Constants
♦ A string constant is surrounded by either single quote (') or double quote (") characters.
♦ When single quote characters are used, a double quote is treated as a normal string character and vice-versa.
♦ When single quote characters are used, two consecutive single quotes are treated as a single quote character within the text of the string. The same rules apply to double quote characters.
♦ Valid string constants include "This is a string", 'This is a string', "It's a string" and 'It''s a string'.
♦ Boolean Constants
♦ The 'bool' data type is an enumeration defined as "public enum expose bool { false, true }", so "bool.false" and "bool.true" are the two valid boolean constants.
♦ Since 'bool' is defined with the 'expose' keyword, each enumeration value can be used directly without preceding it with the data type (false and true).
The following table lists all valid Aztec statement types, and describes where each type of statement can be used. There are three separate "regions" where Aztec statements can potentially be used.
♦ Module level (not inside a class and not inside a method)
♦ Class level (inside a class definition, but outside of a method)
♦ Method level (inside a method definition)
.
♦ The 'class', 'type' and 'enum' statements can only be defined at the module level. Visibility can be controlled using 'public', 'module', 'space' and 'unit', individually or in some combinations.
♦ Several notes related to the 'data' statement.
♦ The 'data' statement can be used at the module level, making the data item persistent for the entire execution of the Aztec script/application. Visibility can be controlled using 'public', 'module', 'space' and 'unit', which can be used individually or in some combinations.
♦ If the 'data' statement is used at the class level, it can be used as an instance data member (data item is unique for each object instance of the class) or as a 'shared' data member (data item is persistent and common to all object instances). Visibility can be controlled using 'public', 'private', 'module', 'family', 'space' and 'unit', which can be used individually or in some combinations.
♦ If the 'data' statement is used at the method level, the data item will normally be unique for each instance of the method being called. If the method level data item is marked as 'shared', the data item will be persistent and common across all instances of the method being executed. No visibility keywords are used for data items defined inside a method. Only the source code inside the method can see them.
♦ A module level data item can be marked as 'compiler', making it available for use during compile-time logic.
♦ Several notes related to the 'method' statement.
♦ The 'method' statement can be used at the module level. Visibility can be controlled using 'public', 'module', 'space' and 'unit', individually or in any combination.
♦ If the 'method' statement is used at the class level, it can be used as an instance method (access to instance data from the class within the method) or as a 'shared' method (access only to 'shared' data from the class). Visibility can be controlled using 'public', 'private', 'module', 'family', 'space' and 'unit', which can be used individually or in some combinations.
♦ A 'method' can be marked as 'compiler', making it available for use during compile-time logic. The source code inside a 'compiler' method can use full expression evaluation and all flow control statements (except 'exceptions' statement).
♦ A 'method' statement cannot be used inside another method.
♦ The 'if' statement, method call statement and assignment statements can be used at the module or class level for use during compile-time logic.
♦ An Aztec Statement Block can be used anywhere an Aztec Statement can be used. It is used in the definition of the Flow Control statements, and is comprised of one or more valid Aztec statements. If the block contains more than one Aztec statement, it must be enclosed in curly braces ( { } ). If the block contains a single Aztec statement, the braces are optional. All statements in a block must conform to the rules described above relative to location within the source module.
Aztec Programming Language Reserved Keywords
The Aztec Programming Language reserves the following 56 keywords. These names cannot be used when creating an identifier (data, method, class, type, enum).
♦ The following reserved keywords are used for data definition, method definition, class definition and identifier visibility as shown. They are described in more detail on the web page describing each statement.
♦ These reserved keywords are used specifically for flow control.
♦ The remaining reserved keywords are used for data types, expressions and object creation.