Nucleo is a statically-typed programming language designed for systems programming and software development. It features a simple syntax, powerful abstractions, and a rich set of libraries and tools.
Experimental programming language name: Nucleo
Extension: .nc
Compiler name: NucleoC
Variables in Nucleo are declared using the var keywords followed by the variable name and an optional initial value:
var x = 5;
var y;
Constants in Nucleo are declared using the const keyword followed by the constant name and an initial value:
const PI = 3.14;
const MY_NAME = "John";
Nucleo supports the following arithmetic operators: +, -, *, /, %.
x + y
x - y
x * y
x / y
x % y
Nucleo supports the following increment and decrement operators: ++, --.
x++
x--
++x
--x
Nucleo supports the following relational operators: <, <=, >, >=, ==, !=.
x < y
x <= y
x > y
x >= y
x == y
x != y
Nucleo supports the following logical operators: &&, ||, !.
x && y
x || y
!x
Nucleo supports write and write statements using the keywords print and input:
print("Example text")
input()
Nucleo supports if-then-else statements using the if keyword:
if (x < y) {
// do something
} else {
// do something else
}
Nucleo supports while and for loops (including "break" and "continue" loop control statements):
while (x < y) {
// do something
break;
}
for (let i = 0; i < n; i++) {
// do something
continue;
}
Functions in Nucleo are declared using the fn keyword followed by the function name, a list of parameters enclosed in parentheses, and an optional return type:
fn add(x, y) -> int {
return x + y;
}
Arrays in Nucleo are declared using square brackets []:
var arr: int[10];
Modules can be imported and exported using the import and export keywords:
import { add } from "./math.nc";
export const PI = 3.14;
Comments in Nucleo can be either single-line comments starting with // or multi-line comments starting with /* and ending with */:
// This is a single line comment
/* This is
a
multi-line
comment */
Here is a table showing the token for each symbol in the language:
| Symbol | Token Name |
|---|---|
| var | VAR |
| + | PLUS |
| - | MINUS |
| * | MULT |
| / | DIV |
| % | MOD |
| = | ASSIGN |
| += | PLUS_ASSIGN |
| -= | MINUS_ASSIGN |
| *= | MULT_ASSIGN |
| /= | DIV_ASSIGN |
| %= | MOD_ASSIGN |
| ++ | INCREMENT |
| -- | DECREMENT |
| == | EQ |
| != | NEQ |
| < | LT |
| > | GT |
| <= | LTE |
| >= | GTE |
| && | AND |
| || | OR |
| ! | NOT |
| ( | LPAREN |
| ) | RPAREN |
| { | LBRACE |
| } | RBRACE |
| [ | LBRACK |
| ] | RBRACK |
| : | COLON |
| input | INPUT |
| while | WHILE |
| for | FOR |
| break | BREAK |
| continue | CONT |
| if | IF |
| else | ELSE |
| import | IMPORT |
| export | EXPORT |
| fn | FUNC |
| return | RETURN |