CT Language Reference
Overview
A CT source file consists of a list of statements. Every statement ends with a semicolon. Comments can be included in the source by prefixing the comment text with //.
Declaring variables
A variable declaration statement begins with the variable's type followed by the variable's name, and then an optional assignment.
Variable names must start with either an alphabetic character or an underscore, and can contain:
- alphabetic characters
- numbers
- underscores
- dashes
Example variable declaration:
Assigning Values to Variables
Values can be assigned to variables using the assignment operator (=). The value being assigned can be one of:
- A literal value
- A method call
- A member of a collection
- Another variable
Example of assigning a value to a variable:
Literal Values
Literal RGBA hex colors
Literal hex colors are written as a hash (#) followed by either:
- 6 hex digits for RGB
- 8 hex digits for RGBA
Example:
Literal strings
String literals are any text enclosed in double quotes. A double quote character can be included in a string by escaping it with a backslash.
Example:
Literal collections
Collections start with { and end with }.
Example:
Literal templates
Templates start with {{{ and end with }}}
Example:
Method Calls
The return value of static methods defined in Java classes can be assigned to a variable. The method must be imported before it can be called.
Example:
Member of a Collection
Example: