r/Compilers • u/PacsfuryTemp • Jul 31 '26
Developing my programming language: Gravel
It all started just as a side and fun project, but I feel like it's now getting a shape.
Thats why I would love to receive some honest and contructive feedback, issue creations or code contributions.
If you have any question regarding the language, please ask me.
Here's the repo: https://github.com/Pacsfury/Gravel-Launcher
Its written in C and uses LLVM IR as backend.
AI use: debugging, teaching more about compilers and some punctual code writing
16
Upvotes
View all comments
Show parent comment
2
u/PacsfuryTemp Aug 01 '26 edited Aug 30 '26
OK, so Gravel will have two types of classes: type classes and organitzation classes.
Type classes are defines like this:
class name: type
end
As a example of these, we have the string class, located at libs/string.grv.
These will act exactly as any other type, like int.
You can only define them using explicit vars like this:
name var = this
And, if the class has a __USE__ function, it will be triggered at that line, and the extl value would be this.
For example:
end
when you do string name = "Welcome", this happens:
__USE__ triggers, and text becomes "Welcome" and length becomes 8 or 7, depending of how sizeof will work (I dont know if to change the name, or if to define better how it will work).
So after that, you can use this as variables:
name = "hi" // USE reruns
name.text = "hi" // USE wouldnt rerun, this should be read-only (maybe it will run, we still have to decide it)
name.lenght = 5 //ERROR: impl values can't change (as are defined internally for the class and are read only)
name.__USE__() //reruns use, for example, you can do this when you manually change name.text
The other class type are for organization, and these can't be used as a type, you can just create and modify instances, like this:
class Calculator:
char[] name
int points
fun __CONSTRUCT__(char[] name, int points)
this.name = name
this.points = points
end
end
so you can't use extl, impl nor use.
To instantiate a organization class, use
Calculator calc = new Calculator
calc.name, etc etc.
Notes:
* Sizeof working is still undefined, and it will be repalces for the standard function to know the lenght of a char array