docs: Add initial language spec
Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
34
SPEC.md
Normal file
34
SPEC.md
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# The Rifle specification
|
||||||
|
|
||||||
|
## About Rifle
|
||||||
|
|
||||||
|
The rifle programming language is a language aiming to keep optimization down to
|
||||||
|
a minimum. It is to have a somewhat C-like syntax and seperate directive/keyword
|
||||||
|
namespace.
|
||||||
|
|
||||||
|
## Identifiers
|
||||||
|
|
||||||
|
Identifiers are names that exist within the program that represent a specific
|
||||||
|
symbol/object. If the name is prefixed with a dot '.' it is a reserved keyword
|
||||||
|
or directive.
|
||||||
|
|
||||||
|
## A simple main function
|
||||||
|
|
||||||
|
```
|
||||||
|
// Function is public
|
||||||
|
// | This is a function
|
||||||
|
// | / Identifier
|
||||||
|
// | | | Type designator
|
||||||
|
// | | | / Type
|
||||||
|
// | | | / /
|
||||||
|
// | | | | |
|
||||||
|
// | | | | |
|
||||||
|
.pub .f main() : u32 {
|
||||||
|
return 0; // <-- Return statement
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
A few things are going on here, first we declare the function
|
||||||
|
as public (i.e., visible externally from the current file), then
|
||||||
|
we use '.f' to denote that we are defining a function, followed by
|
||||||
|
an identifier, a set of parenthesis and a type after the ':'.
|
||||||
Reference in New Issue
Block a user