This is test of making a programming language in C with the least amount of help from google as possible. This will be small interpreted language.
NOTE: this is my first C code. I only used C++ (as the most SIMILAR language to C).
| OS | Status (tested) | Runs as should | notes |
|---|---|---|---|
| Windows | ✅ | Yes | |
| Linux | ✅ | Yes | |
| Android | ✅ | Yes | Termux needs to be used |
| FreeBSD | ✅ | Compiled, more testing needed | |
| iOS | ✅ | Compiled, more testing needed | a-shell needs to be used (with clang), seems to have some issue with python test script but seems that it works |
| Mac (Intel) | ✅ | Yes | |
| Mac (Apple silicone) | ✅ | Compiled, more testing needed | |
| OpenBSD | ❌ | Was not tested in any way but is planned to be supported in either releases or as working on that platform if compiled | |
| NetBSD | ❌ | Was not tested in any way but is planned to be supported in either releases or as working on that platform if compiled | |
| HaikuOS | ❌ | Was not tested in any way but is planned to be supported in either releases or as working on that platform if compiled | |
| ReactOS | ❌ | Was not tested in any way but is planned to be supported in either releases or as working on that platform if compiled |
Release cycle ins't set in any way. Time between any versions can be as long (or as short) as needed for that version. Any code in main branch (Development branch) is not meant as stable code, only stable code is in the release. Version are if format: Major.Minor.Patch (as most software).
Current platforms in releases (current and future):
- Windows
- Linux
- MacOS (Intel CPU)
- Android
- iOS (version 0.1.1+)
- FreeBSD
NOTE: although Apple Silicone should work, I can't reliably compile for it because I don't own any machine like this
Any code that's not in release is not meant as stable version, the main branch is more so development. Please for any project use any version from release.
Note: currently there are no releases
To compile it run in the root of this repository command:
python3 ./scripts/compile.pyThis automatically runs the language with params from ./scripts/CompileRunParams.txt (which is usually examples/ex[num].dio).
Dio is procedural, statically typed that's weakly typed programming language. Working directory is generated through "-file" input, if you input "-file example/ex2.dio", DIO uses ./examples/ as it's working directory.
The name Dio comes from ancient Greek philosopher Diogenes of Sinope and his bowl story. Essentially, Diogenes saw kid drinking water from river with his hands, so he threw away his bowl (one of two things he owned). It's called Dio because it's trying to be minimalistic language (not in line count, but with how much it can do).
DIO supports three file extensions:
- .dio (original)
- .diogenes
- .diogenesdesinope
Everything else should raise error.
This parametre tells dio which file to use.
If this parametre isn't technically needed, it'll open "REPL" mode, which isn't finished, so it doesn't fully works, please don't use it, it's not finished.
This is now only used for writing out some values for this software (like version etc.).
- int - basic number type, it's internally used as float
- float - basic number type, can be used with +, -, *, /, <, >, <=, >=, ==
- string - basic text (can only be used as output and be concatenated with "+")
- bool - basic booleans
- number arrays - part of int
NOTE: booleans internally are used as integers/floats, meaning the constrains for valid bools are checked while creating the variable not while using it. You can make boolean equal non boolean values AFTER you initialize it.
Dio uses >> as the symbol for single-line comments. Comments end when lexer either find ending of the line or the file ends.
Dio uses construction of >* (start) and *< (end) as multi-line comment. These comments end either when the file ends or when it finds the end symbol.
Note: if you only ues
>*everything afterwards will be taken af part of the comment.
>>Declaration
int a = 10;
>>use
int b = a + 1;
>>arrays
int arr = {1,2,3.5,7}All normal booleans (true, false) are here, represented by either the word "true" or "false" (this is changed in lexer to 1 and 0 respectively). Dio also has special boolean, maybe, which is either 1 or 0 (determined in the parser).
def name()::void
>>code
end
def withParams(type : name, type2 : name2 ...)::void
>>they can have any amount of inputs
end
>>call
name()
withParams(a, 10) >> example, use variable and 10
>>NOTE: var types are now not fully used, so function can be parsed any argument Functions can be declared without the "::void" but they can't return anything
>>Showing params and how chain functions
def a()::int
return 7
end
def b(int : a)::void
out(a)
end
def c(int : a)::int
return a + 1
end
int retVal = a():c()
b(retVal)
>>Writes out 7, because chain functions pair together so "a" returns 7 which then "c" adds 1 making it 8Note: functions used in chain can't have more than one input for now, this will feature will be added
int i = 0;
while(i < 10)
i = i + 1
out(i)
end
>>outputs 1 -> 10for (int i = 0; i < 10; i = i + 1)
out(i)
end
>>outputs 0 -> 9NOTE: walrus operators are not implemented, you have to use "n = n ..."
if (condition)
>>code
elseif (condition)
>>code
else
>>code
end>>this is without any condition
::gotoName::
>>code
goto ::gotoName::
>> goto with condition
::gotoName::
>>code
goto (condition) ::gotoName::NOTE: if you don't use condition, it will run always
int a = 5
out(a)Out is print function that prints out the variables or what you put into it.
int a = {1,2,3}
int len = length(a)
out(len)Length returns the integer length of array type variables (string or number array).
Raises error, similarly as the language does errors. This makes the program instantly exit with some error code.
Raises warning, this only writes out text but does not stop executing other code.
Executes shell commands.
Writes out the text input and takes input, which is then returned as what the user writes.
Middle processor is kind of middle ware used to add code or change how lexing works. This is imitating (in a way*) pre-processor from C (or that's the idea behind itq*). All mid processor calls are prefixed with '#'.
- Takes argument of file.
- Adds the file into the program you're making, this is used to import to other file for multi-file support.
#def *name*: *valid dio code*this makes macro which can be used with command#use *name
- Using
#WIN *valid dio code*will make this piece of code run only and only on windows - Using
#LINUX *valid dio code*will make this piece of code run only and only on linux - Using
#MAC *valid dio code*will make this piece of code run only and only on mac OS - Using
#FREEBSD *valid dio code*will make this piece of code run only and only on freeBSD - Using
#ANDROID *valid dio code*will make this piece of code run only and only on Android
- declaring "#pragma once" at the start of the programme it'll make it so it can be loaded only once