Nova Script is a simple, readable, English-like programming language designed for beginners and rapid prototyping. It emphasizes clarity and natural language syntax.
Checkout this LinkedIN post for more info:
https://www.linkedin.com/feed/update/urn:li:activity:7339534452844281857/
say "Hello, world!"
say x
- Syntax:
say <expression>
- Prints the value of the expression to the console.
let count be 42
let name be "Alice"
let value be count
- Syntax:
let <identifier> [be= <expression>]
- Declares a variable, optionally with a value and type.
define function sayName(name):
say "Hello, "
say name
call sayName("Novascript")
- Syntax:
define function <function-name> [with <param> as <type>, ...]:
- Defines a function.
let age be 18
when age<18 then
say "You can't vote"
otherwise
say "You can vote"
end
-
Syntax:
when <condition> then
otherwise
#while loop
repeat while a<10
say a
set a to a+1
end
#for
repeat for j from 1 to 5
say j
end
-
Syntax:
repeat while <condition>
repeat for <variable> from <start> to <end>:
# This is a single-line comment
/*
THis is a multiline comment.
*/
- Lines starting with
#
are ignored.
try:
let x be 10 / 0
catch error:
say "Error: " + error
-
Syntax:
try:
catch <error-var>:
+
,-
,*
,/
,==
,!=
,>
,<
,>=
,<=
define function factorial(n)
let result be 1
let i be 1
repeat while i<=n
set result to result*i
set i to i+1
end
return result
end
let answer be call factorial(5)
say answer
define function fibonacci(n)
let a be 0
let b be 1
let c be 0
repeat while c<n
say a
let temp be b
set b to a+b
set a to temp
set c to c+1
end
end
call fibonacci(10)
try
let number be 0
let result be 100/number
say result
catch error
say "an error occured:"
say error
end
Save code in a .ns
file and run:
g++ -I../include -o main main.cpp lexer.cpp Parser.cpp SymbolTable.cpp SemanticAnalyzer.cpp -std=c++17 -mconsole
After successful compilation - run:
./main