https://github.com/phase/granite
:dragon_face: Granite Programming Language
https://github.com/phase/granite
Last synced: 7 months ago
JSON representation
:dragon_face: Granite Programming Language
- Host: GitHub
- URL: https://github.com/phase/granite
- Owner: phase
- Created: 2015-11-01T22:53:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-01T23:52:26.000Z (over 10 years ago)
- Last Synced: 2025-01-24T22:29:37.295Z (about 1 year ago)
- Language: D
- Size: 111 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#Granite
The Granite Programming Language & other stuff relating to it.
##Why another language?
Compilers are fun to make.
##Ideas
It will transcompile to C, and compiler will be written in D.
###Data Types
type|size|range
----|----|-----
byte | 1 byte | -128 to 127
ubyte | 1 byte | 0 to 255
short | 2 bytes | -32,768 to 32,767
ushort | 2 bytes | 0 to 65,535
int | 4 bytes | -2,147,483,648 to 2,147,483,647
uint | 4 bytes | 0 to 4,294,967,295
###Hello World
```c
//imports take local files over installed headers
//i.e. search through local files for this, if found
//use ""; if not found, use <>
import stdio
//return void is implied
main() {
//optional semicolons
printf("Hello, World!")
}
```
Gets compiled to
```c
#include
void main() {
printf("Hello, World!");
}
```
###Mixins
Mixins allow you to specify new tokens that add in code.
```c
#mixin TOKEN printf("This is in a token")
main() {
TOKEN
}
```
You can access local and global variables by name, because the compiler just inlines the code.
```c
#mixin W printf("%d",w);
main() {
W //throws error
int w = 7;
W //prints 7
}
```