Skip to content

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:

varx=10

To access the variable put it in between $

vary=$x$

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

varz=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$)}add5,6

Any equations must be inside ( ).

varx=($y$*$z$)

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

varx=10x+5x-4x*3x/2x=1print$x$

Comments are very simple

// Line Comment/* Block Comment*/

Arrays are also allowed in this language

vary=[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

structVector{X,Y,Z}varvec=Vector: 100,5.23,99

They can be accessed and modified easily,

vec.X=150vec.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

ifx>55 { print"X is big"
}
elifx<0 {
print"X is negative"
}
else { print"x is small"
}

There are loops as well

whiletrue{print"yes"}foriin150{
print $i$}

For loops can also use arrays

forvaluein$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"

About

Norma is a small custom programming language made as an example for my blog.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages