https://github.com/jbrosdevelopment/norma
Norma is a small custom programming language made as an example for my blog.
https://github.com/jbrosdevelopment/norma
custom language norma programming programming-language
Last synced: 2 months ago
JSON representation
Norma is a small custom programming language made as an example for my blog.
- Host: GitHub
- URL: https://github.com/jbrosdevelopment/norma
- Owner: JBrosDevelopment
- Created: 2024-04-09T00:35:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-26T03:56:52.000Z (11 months ago)
- Last Synced: 2025-04-23T08:16:31.089Z (8 months ago)
- Topics: custom, language, norma, programming, programming-language
- Language: C#
- Homepage: https://jbrosdev.hashnode.dev/guide-to-building-your-own-programming-language-with-c
- Size: 30.4 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Norma Programming Language
> \*\***Find Article about making it [HashNode](https://jbrosdev.hashnode.dev/guide-to-building-your-own-programming-language-with-c)**\*\*
Norma is a programming language built in C# made to be extremely simple. It's syntax is similar to Python and JavaScript, but has my own custom spin on it.
Here is the [Nuget Package](https://www.nuget.org/packages/Norma/) if you want to add it to your C# project
> `dotnet add package Norma`
Norma is a very simple language. To define a variable, use:
```js
var x = 10
```
To access the variable put it in between `$`
```js
var y = $x$
```
To create a pointer to that variable, use the `point` keyword.
```js
var z = point: $x$
```
To call a function, don't use parenthesis.
```js
print "Hello World"
```
Strings have automatic interpolation with variables using the `$` syntax.
```js
print "X is equal to $x$ and y is equal to $y$"
```
To define a function, use `def`
```js
def add: left, right {
return ($left$ + $right$)
}
add 5, 6
```
Any equations must be inside `( )`.
```js
var x = ($y$ * $z$)
```
To manipulate a variable, use `+` instead of `+=` where `+` can be any operator
```js
var x = 10
x + 5
x - 4
x * 3
x / 2
x = 1
print $x$
```
Comments are very simple
```js
// Line Comment
/*
Block Comment
*/
```
Arrays are also allowed in this language
```js
var y = [0, 1, 2]
```
They are typeless and can hold anything including pointers
```js
y = [0, "yes", ["no", $z$], point: $x$]
```
Structs are the next main feature
```js
struct Vector { X, Y, Z }
var vec = Vector: 100, 5.23, 99
```
They can be accessed and modified easily,
```js
vec.X = 150
vec.Y = $vec.X$
```
The values are also typeless and can be anything
```js
vec.X = "Hello World"
vec.Y = point: $z$
vec.Z = [1, 2, 3]
```
Statements are straightforward as well
```py
if x > 55 {
print "X is big"
}
elif x < 0 {
print "X is negative"
}
else {
print "x is small"
}
```
There are loops as well
```js
while true {
print "yes"
}
for i in 150 {
print $i$
}
```
For loops can also use arrays
```js
for value in $array$ {
print $value$
}
```
There are many built in functions as well ([Test file](FunctionTesting.norm)):
- `print "text"`
- `input`
- `clear`
- `exit`
- `substring "text", $start$, $len$`
- `indexOf "text", "e"`
- `toLower "Text"`
- `toUpper "text"`
- `trim " text "`
- `revere "string or array"`
- `length ["string", "or", "array"]`
- `append [0, 1], 5`
- `remove $index$`
- `insert $array$, $index$, $value$`
- `slice [99, 98, 97, 96, 95], $start$, $len$ `
- `concat $array$, [0, 1, 2, 3]`
- `sort [9, 5, 7, 2, 0]`
- `runCode $code$`
- `readFile "path/to/file.txt"`
- `writeFile "path/to/file.txt", "text"`
- `createFile "path/to/file.txt"`
- `deleteFile "path/to/file.txt"`