Skip to content

JBrosDevelopment/Norma

Repository files navigation

Norma Programming Language

**Find Article about making it HashNode**

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 if you want to add it to your C# project

dotnet add package Norma

icon

Norma is a very simple language. To define a variable, use:

var x = 10

To access the variable put it in between $

var y = $x$

To create a pointer to that variable, use the point keyword.

var z = point: $x$

To call a function, don't use parenthesis.

print "Hello World"

Strings have automatic interpolation with variables using the $ syntax.

print "X is equal to $x$ and y is equal to $y$"

To define a function, use def

def add: left, right {
    return ($left$ + $right$)
}

add 5, 6

Any equations must be inside ( ).

var x = ($y$ * $z$)

To manipulate a variable, use + instead of += where + can be any operator

var x = 10
x + 5
x - 4
x * 3
x / 2
x = 1

print $x$

Comments are very simple

// Line Comment
/*
    Block Comment
*/

Arrays are also allowed in this language

var y = [0, 1, 2]

They are typeless and can hold anything including pointers

y = [0, "yes", ["no", $z$], point: $x$]

Structs are the next main feature

struct Vector { X, Y, Z }

var vec = Vector: 100, 5.23, 99

They can be accessed and modified easily,

vec.X = 150
vec.Y = $vec.X$

The values are also typeless and can be anything

vec.X = "Hello World"
vec.Y = point: $z$
vec.Z = [1, 2, 3]

Statements are straightforward as well

if x > 55 { 
    print "X is big"
}
elif x < 0 {
    print "X is negative"
}
else { 
    print "x is small"
}

There are loops as well

while true {
    print "yes"
}
for i in 150 {
    print $i$
}

For loops can also use arrays

for value in $array$ {
    print $value$
}

There are many built in functions as well (Test file):

  • 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"