Back

Keszeg 4

Keszeg 4 Language Documentation

Keszeg 4 is a simple interpreted language supporting variables, arrays, functions, references, and basic I/O and arithmetic operations.


Function Declarations

Functions are declared using FUN and ended with EF.
Parameters are declared after the function name, using @ for value parameters and & for reference parameters, followed by the name and type.

Reference parameter example:

FUN SWAP & A INT & B INT
        @ TEMP INT
        TEMP = A
        A = B
        B = TEMP
    EF

Value parameter example:

FUN ADD @ X INT @ Y INT
        @ RESULT INT
        RESULT = X + Y
        print $ RESULT
    EF

Variables

Variables are declared with @ name TYPE. Supported types: INT, FLOAT, BYTE, IARRAY, FARRAY, STRING.

@ X INT
    @ ARR IARRAY

References

Reference parameters allow passing variables by reference to functions. Use & name TYPE in the function declaration. When calling, pass the variable name.

FUN INCREMENT & X INT
        X += 1
    EF

    CALL INCREMENT X

Instructions

Assignment

Arithmetic

Arrays

String Operations

Input/Output

File Operations

Control Flow

Function Calls

Return

Random

Sleep

Exec


Syntax Notes

Comments

Any text after a # character on a line is treated as a comment and ignored by the interpreter.

Escaped Characters

In string constants, you can use escape sequences:

Multiple Instructions per Line

You can write multiple instructions on a single line by separating them with a comma ,.


Notes

View on GitHub - Kotlin View on GitHub - C Some example code