DiploInterpreter is currently under development.
No downloads available for now.
Refer to TheBoloss/DiploInterpreter to consult source.
The DiploInterpreter project is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License (CC BY-NC-ND 4.0). See License file
Diplo language works with pointer and values.
- Interpreter creates an array of 65536 cases.
- Each case has its own value that can be changed in the program (0 by default). The pointer designates the selected case.
Diplo is not case sensitive, so INSERT
is the same as Insert
or insert
.
Statements can take arguments as follow:
<Required> [Optional1|Optional2]
<Statement> [Arg1], [Arg2], ...
By default, pointer is initialized to 0.
Minimum value is 0 and maximum value is 65535.
Pointer <AbsoluteValue|RelativeValue>
- With
AbsoluteValue
unsigned integer. - With
RelativeValue
'+' or '-' + [unsigned integer].
Pointer 10 // Sets pointer to 10
Pointer 0 // Set pointer to 0
Pointer + // Adds 1 to pointer (increments pointer)
Pointer +2 // Adds 2 to pointer
Pointer - // Removes 1 to pointer (decrements pointer)
Pointer -5 // Removes 5 to pointer
This section shows how to change the pointed value.
By default, value is initialized to 0.
Minimum value is 0 and maximum value is 255.
Insert <AbsoluteValue|RelativeValue>
- With
AbsoluteValue
unsigned integer. - With
RelativeValue
as follow:+n
to addn
to value-n
to removen
to value*n
to multiply value byn
/n
to divide value byn
(integer division)%n
to set value to value modulon
Changes the pointed value.
InsertL <AbsoluteValue1>, [AbsoluteValue2], [...]
- With
AbsoluteValue1
,AbsoluteValue2
... unsigned integers.
Changes to pointed value to AbsoluteValue1
and next pointed value to AbsoluteValue2
, etc...
Insert 10 // Sets value to 10
Insert 0 // Sets value to 0
Insert + // Adds 1 to value (increments value)
Insert +2 // Adds 2 to value
Insert - // Removes 1 to value (decrements value)
Insert -5 // Removes 5 to value
Insert *2 // Multiplies pointed value by 2
Insert /2 // Divides
Insert %2 // Sets value to value%2
InsertL 97, 98, 99 // Sets pointed then next values to 'a', 'b' and 'c' -> "abc"
Prints the corresponding ASCII character of pointed value to the console.
Out
Insert 97
Out
// Prints 'a'
Prompt user for a character in the console and puts it into pointed value.
Get
Get
Out
// Prints the character user entered.
Exit <ErrorCode>
With ErrorCode
integer corresponding to program exit code.
Exit 0
// No error
Compares 2 values.
Comparison result can be used in Conditional jumps (see below).
Comp <Value1>, <Value2>
With Value1
and Value2
integers or variables.
$value
returns the pointed value.$pointer
returns the pointer value.
Comp $value, 97
JumpGreaterEq isLetter
Exit 0
Label isLetter
// Code if is letter
Labels can be defined to mark a specific place in the program and to create loops.
Label <LabelName>
Defines the label '<LabelName>'.
With LabelName
char string containing only [a-z A-Z 0-9].
Jump <LabelName>
Jumps to label '<LabelName>'.
Using a
and b
as arguments of last condition:
-
JumpEq <LabelName>
Jumps to label '<LabelName>' if a == b. -
JumpNotEq <LabelName>
Jumps to label '<LabelName>' if a != b. -
JumpGreater <LabelName>
Jumps to label '<LabelName>' if a > b. -
JumpGreaterEq <LabelName>
Jumps to label '<LabelName>' if a >= b. -
JumpLess <LabelName>
Jumps to label '<LabelName>' if a < b. -
JumpLessEq <LabelName>
Jumps to label '<LabelName>' if a <= b.
Insert 97
Label loop
Out
Jump loop
// Prints 'a' forever.
Use //
to comment your code.
Insert 1
// This is a comment!
Diplo errors are 32 bits based hexadecimal numbers.
- 15 bits for the line where error occured.
- 10 bits for the error detail (eg: Expected argument).
- 6 bits for the error type/domain (eg: Argument error).
- 1 bit (bool) for the error fatality (was the program halted?).
-
// Register "Hello World!" InsertL 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33 // Print char until string ends (0x00) Label PrintLoop Out Pointer + Comp $value, 0 // If string does not end, prints the next char JumpNotEq PrintLoop // Exits program properly Exit 0
A syntax highlighting extension for VS Code is available.
Download Diplo Language (ID: TheBoloss.diplo-lang)
- Eugène Villotte (TheBoloss)