Appearance
Lexical Structure
Before Coldwave Script can execute a program, the source text must be lexically analyzed. The text is broken down into the smallest units (tokens): keywords, identifiers, literals, operators, and comments. Understanding these building blocks helps prevent errors at the writing stage and clarifies how the language is designed.
Keywords
Keywords are reserved words with fixed meaning. They may not be used as variable names.
Examples:
vb
PROGRAM, END PROGRAM, DIM, CONST, IF, THEN, ELSE,
END IF, FOR, WHILE, DO, LOOP, NEXT, FUNCTION, END FUNCTION,
SUB, END SUB.Example:
vb
PROGRAM
DIM a AS INT = 5
IF a > 0 THEN
PRINT "a is positive"
END IF
END PROGRAMIdentifiers
Identifiers are names for variables, constants, or block instances.
Rules:
- Must begin with a letter (A-Z, a-z).
- May contain letters, digits, or
_afterwards. - No umlauts or special characters.
- Case-sensitive (
Counter≠counter).
Example:
vb
PROGRAM
DIM Counter AS INT = 0
DIM T AS TON
PRINT Counter
END PROGRAMLiterals
Numbers: 42, -123, 0xFF, 3.14, 1.2E6
Strings: "Hello World" (supports \n, \t)
Time formats: T#500ms, DATE#2025-01-01, TOD#12:00:00, DT#2025-01-01-12:00:00
vb
PROGRAM
DIM i AS INT = 42
DIM pi AS REAL = 3.14159
DIM text AS STRING = "Example"
DIM t AS TIME = T#2s
PRINT i, pi, text, t
END PROGRAMOperators
Arithmetic: +, -, *, /, MOD
Bitwise: SHL, SHR, AND, OR, XOR, NOT
Comparison: =, <>, <, <=, >, >=
vb
PROGRAM
DIM a AS INT = 5
DIM b AS INT = 2
PRINT a / b ' Output: 2 (integer division)
PRINT a MOD b ' Output: 1
PRINT a SHL 1 ' Output: 10 (binary 101 → 1010)
END PROGRAMComments
Comments document code and are ignored by the interpreter. They begin with ' or REM.
vb
PROGRAM
' This program counts to 3
DIM i AS INT
FOR i = 1 TO 3
PRINT i
NEXT i
END PROGRAMSummary
- Keywords are reserved and cannot be used as names.
- Identifiers have defined rules and are case-sensitive.
- Literals include numbers, strings, and time types.
- Operators cover arithmetic, bitwise operations, and comparisons.
- Comments improve readability and are ignored during execution.