Language and operators
This page covers the public source grammar and operators for Zen Studio Live. It complements the function, constant, and diagnostic appendices.
Script sections and declarations
Definition
define NAME = constant_expression;
Named compile-time integer
Replaced during compilation
Enumeration
enum { A, B, C };
Sequence of named compile-time integers
Replaced during compilation
Raw data
data(value, ...);
Immutable packed bytes
Read through data readers
Const array
const uint8 NAME[] = { ... };
Immutable typed data
Read by index/address
Const string
const string NAME[] = { "text" };
Immutable string data
Passed by const-data address
Const image
const image NAME = { ... };
Packed monochrome image
Passed by const-data address
Const ADT
const ps5adt NAME = { 11 bytes };
PS5 adaptive-trigger record
Passed by const-data address
Remap
remap INPUT -> OUTPUT;
Static report remap
Applied after main
Unmap
unmap OUTPUT;
Remove output forwarding
Applied after main
Variable
int name;
Mutable signed 32-bit state
Global, starts at zero
Runtime array
int name[SIZE];
Mutable slot array
Global, all elements start at zero
Init
init { ... }
One-time setup
All declared init sections are merged and run once before main
Main
main { ... }
Real-time report logic
All declared main sections are merged and run continuously top-to-bottom
User function
function name(args) { ... }
Reusable logic with integer return
Runs when called
Combo
combo name { ... }
Scheduled instruction sequence
Controlled with the documented combo_*, wait, and call forms
Fast combo
fcombo name { ... }
Zen combo variant
Uses the same documented control surface
At least one main section is required. Zen Studio Live accepts multiple init and main sections and merges each set into its combined phase. All runtime variable declarations are top-level. Only function parameters are local.
Const element types
int8
1
-128..127
Yes
uint8
1
0..255
Yes
int16
2
-32768..32767
Yes
uint16
2
0..65535
Yes
int32
4
signed 32-bit
Yes
string
variable
bytes plus string metadata/termination
String arrays only
image
variable
width, height, packed pixels
Arrays of image records
ps5adt
11
exactly 11 unsigned bytes
Arrays of ADT records
int32 is a const-data type, not a different runtime declaration type. Runtime int is already 32-bit in Live.
Literals
Decimal integer
123, -75
Signed integer expression
Hexadecimal
0xFF, 0x12345678
Useful for masks/data
Binary
0b1010
Useful for flags
Decimal/fractional source
2.5
Rounded by compiler with warning; avoid in production
String
"MENU"
Valid in const string declarations, not a general runtime value
Escape
"A\nB", "\x41"
Must be a recognized, complete escape
GPC has no runtime floating-point type. Runtime division truncates.
Primary compile-time forms
sizeof
Returns compiler-known size for a supported variable/array/element operand. It does not accept every bare type keyword or arbitrary expression.
Supported fixed-width type keywords can also be queried directly: sizeof(int8) and sizeof(uint8) return 1, sizeof(int16) and sizeof(uint16) return 2, and sizeof(int32) returns 4. Unsupported or target-inapplicable keywords produce a compiler error.
addr
Returns the const-data address required by APIs that consume string, image, or ps5adt records. The operand must resolve to valid const data.
Flow keywords
if
if(condition) { ... }
Run when condition is nonzero
else if
else if(condition) { ... }
Alternate conditional branch
else
else { ... }
Fallback branch
switch
switch(value) { ... }
Select matching case
case
case CONSTANT: { ... }
Compile-time constant branch
default
default: { ... }
No-case fallback
while
while(condition) { ... }
Pre-tested loop
do, while
do { ... } while(condition);
Post-tested loop; runs once minimum
for
for(init; test; step) { ... }
Counted/general loop
break
break;
Exit nearest loop or switch
continue
continue;
Start next iteration of nearest loop
return
return expression;
Exit user function with value
Switch case bodies require braces. case values must be unique compile-time integers.
Complete operator set
Conditional
condition ? true_value : false_value
Select one of two expression values
output = enabled ? 100 : 0;
Evaluation proceeds in two steps:
GPC evaluates
condition.If it is nonzero, GPC evaluates and returns
true_value. Otherwise, GPC evaluates and returnsfalse_value.
Only the selected expression is evaluated. The unselected branch does not run, so its function calls, assignments, increments, divisions, and other side effects do not occur.
This behavior is equivalent to assigning the result in an if/else, but the operator can be used wherever an expression value is accepted. Use parentheses around nested conditional expressions and prefer the longer if/else form when either branch needs several statements.
Two diagnostics relate to this operator: GPC2117 when the : is missing, and GPC4032 when a conditional is written as a statement instead of used as a value.
Assignment
=
assign
a = 5;
+=
add and assign
a += 2;
-=
subtract and assign
a -= 2;
*=
multiply and assign
a *= 2;
/=
divide and assign
a /= 2;
%=
remainder and assign
a %= 2;
|=
bitwise OR and assign
a |= MASK;
&=
bitwise AND and assign
a &= MASK;
^=
bitwise XOR and assign
a ^= MASK;
<<=
shift left and assign
a <<= 1;
>>=
shift right and assign
a >>= 1;
&&=
logical AND and assign
a &&= b;
||=
logical OR and assign
a ||= b;
^^=
logical XOR and assign
a ^^= b;
Arithmetic and increment
+
addition
10 + 5 → 15
-
subtraction/unary negate
10 - 5 → 5
*
multiplication
10 * 5 → 50
/
truncating integer division
10 / 3 → 3
%
integer remainder
10 % 3 → 1
++
increment
a++;
--
decrement
a--;
Logical
!
logical NOT
&&
logical AND
||
logical OR
^^
logical XOR
Comparison
==, !=, <, <=, >, >=
Bitwise
~
invert all bits
&
bitwise AND
|
bitwise OR
^
bitwise XOR
<<
left shift
>>
right shift
Shift counts must stay within 0..31 for Live integers.
Operator precedence
Lowest binding strength is listed first; parentheses override the table.
1
= += -= *= /= %= &= |= ^= <<= >>= &&= ||= ^^=
assignment, right-to-left
2
? :
conditional selection; use parentheses for nested forms
3
||
logical OR
4
^^
logical XOR
5
&&
logical AND
6
|
bitwise OR
7
^
bitwise XOR
8
&
bitwise AND
9
== !=
equality
10
> >= < <=
relational
11
<< >>
shift
12
+ -
additive
13
* / %
multiplicative
14
! unary - ~ prefix ++ prefix --
unary, right-to-left
15
postfix ++ postfix -- [ ] ( )
postfix/call/subscript
16
literals, identifiers, sizeof(), addr(), grouping ( )
primary
Classic trap:
flags & MASK == MASK evaluates equality before bitwise AND.
Remap timing
main reads/writes original identifiers. Static remap/unmap finalization happens afterward. An unmapped input remains readable by the script.
Function rules
Parameters are local signed integers passed by value.
Globals remain visible.
No block-local variable declarations exist.
No reached
returnmeans an automatic return value of zero.Do not mix valued and bare returns.
Recursion is accepted with a stack warning; avoid it in real-time code.
A built-in marked as returning a required value must have that value consumed.
Namespace and mutability
Variables, definitions, enum members, and const-data names share the data-symbol namespace. User-function names and combo names are resolved separately from it, and function parameters are local to their function. Language keywords and built-in names remain reserved. Only runtime variables, runtime-array elements, and supported variable parameters are writable; const data, definitions, enum members, literals, and built-in constants are not assignment targets.
Comments
Block comments terminate at the first */ and cannot nest.
Public/private boundary
This edition documents the current reader-facing language surface, including combo controls, combo-only commands, bit helpers, math helpers, device functions, BVAR read/write, and OLED drawing.
Last updated

