noxora
v0.1.1
Published
A very simple scripting language that is easy for beginners to read and write.
Maintainers
Readme
Noxora
A very simple scripting language.
Noxora is designed to be extremely easy for beginners to read and write.
No {}, no semicolons, no let or function. Just plain commands that start with nxr.
Noxora v0.1.0 (experimental). This first version intentionally has a small feature set. Only what is listed on this page is implemented.
Installation
npm install -g noxoraOr run it without installing:
npx noxora main.nxrNoxora needs Node.js 18 or newer.
First Program
Create a file called hello.nxr and put this inside:
nxr.say("Hello World")Run it:
noxora hello.nxrOutput:
Hello WorldVariables
Use nxr.set to store a value:
nxr.set name = "Nox"
nxr.set age = 17
nxr.say(name)
nxr.say(age)Output:
Nox
17nxr.say can print several values at once:
nxr.say("Hello", name)Output:
Hello NoxSupported value types:
nxr.set age = 17 # integer
nxr.set price = 25000.5 # decimal
nxr.set name = "Nox" # string
nxr.set active = true # boolean
nxr.set nothing = null # null
nxr.set numbers = [1, 2, 3] # arrayMath
Operators: + - * / %
nxr.set a = 10
nxr.set b = 5
nxr.set result = a + b
nxr.say(result)Output:
15Conditions
Comparisons: > < >= <= == !=
Boolean operators: and, or
nxr.set age = 17
nxr.if age >= 17
nxr.say("Boleh")
nxr.else
nxr.say("Belum")
nxr.endOutput:
Bolehnxr.end closes the current block. nxr.else is optional.
Blocks can be nested, and indentation is optional but makes code easier to read:
nxr.if age >= 17
nxr.if age >= 18
nxr.say("18+")
nxr.end
nxr.endLoops
nxr.loop angka = 1 to 10
nxr.say(angka)
nxr.endOutput:
1
2
3
4
5
6
7
8
9
10The limit can be a variable:
nxr.set max = 3
nxr.loop i = 1 to max
nxr.say("Number:", i)
nxr.endLoops can be nested.
Comments
Everything after # on a line is ignored:
# This is a comment
nxr.say("Hello")Errors
Noxora shows friendly errors, with the file name, line number and the problem line:
Noxora Error
Unknown command:
nxr.unknown("test")
File: main.nxr
Line: 1Supported Features
| Feature | Syntax |
| --- | --- |
| Print | nxr.say() |
| Variable | nxr.set |
| Condition | nxr.if |
| Else | nxr.else |
| Block end | nxr.end |
| Loop | nxr.loop |
| Comment | # |
Command Line
noxora <file.nxr> Run a Noxora file
noxora --version Show version
noxora --help Show helpExamples
See the examples/ folder: hello.nxr, variables.nxr,
if.nxr, loop.nxr and index.nxr.
How it works
Noxora is a small interpreter written in JavaScript (ES Modules). It never uses eval().
.nxr source -> Lexer -> Parser -> AST -> Interpreter -> Runtime -> Outputsrc/lexer.js: turns text into tokenssrc/parser.js: turns tokens into an ASTsrc/interpreter.js: runs the ASTsrc/runtime.js: variables and outputsrc/index.js: public API (run,runFile)
Development
npm testLicense
MIT
