- CAPSLOCK for keywords, such as
IF, REPEAT, PROCEDURE - camelCase for identifiers (variables, functions, etc.) such as
myVariable, myFunction() - Indentation
- Comment using
//
DECLARE myVariable: INTEGER
DECLARE myArray: ARRAY[1:10] OF INTEGER
DECLARE my2DArray: ARRAY[1:10, 1:10] OF INTEGER
CONSTANT myConstant = 69
myVariable <- 69
myVariable <- myVariable + 1
myArray[1] <- 69
my2DArray[1, 1] <- "*"
INPUT myVariable
OUTPUT myVariable
OUTPUT "Goodbye World"
- Arithmetic:
+, -, *, / - Integer division:
MOD, DIV - Relational:
=, <> (not eq), <, >, <=, >= - Logical:
AND, OR, NOT
- Must be done using a loop, python style slicing is not allowed
IF <condition>
THEN
<statements>
ELSE
<statements>
ENDIF
CASE OF myVariable
<value1>: <statements>
OTHERWISE: <statements>
ENDCASE
// Loop on INTEGER
FOR i <- 1 to 10 STEP <increment> (optional, can be negative)
<statement>
ENDFOR
// Loop on STRING or ARRAY
FOR i <- 1 to LENGTH(myString)
<statement using myString[i]>
ENDFOR
REPEAT
<statements>
UNTIL <condition>
WHILE <condition> DO
<statements>
ENDWHILE
PROCEDURE myProcedure(param1: INTEGER, param2: INTEGER)
<statements>
ENDPROCEDURE
CALL myProcedure(1, 2)
FUNCTION myFunction(param1: INTEGER, param2: INTEGER) RETURNS INTEGER
<statements>
RETURN <something>
ENDFUNCTION