Vikari is an original, gradually typed, object-oriented programming language. Generally, it favors operators over keywords. This project is an interpreter that currently supports a subset of the Vikari language. Its initial focus is to support development of simple terminal programs.
The demo contains an exhaustive set of Vikari source files demonstrating each implemented feature. A website also is coming soon to extensively document all of Vikari's language design and to demonstrate usage each of its features.
Vikari is an open-source project licensed under the Apache License 2.0. Make cool stuff! And if you do, please send me a link: [email protected].
Vikari aims to be a general-purpose language. But its initial scope limits it to be suitable for simple scripts. The project's structure is based on design principles outlined in part II of Crafting Interpreters. Thus is it structured in terms of a lexer, parser, and tree-walk interpreter. This limits Vikari in terms of execution speed. But optimization is not an initial design goal.
The parser utilizes recursive descent to parse the language's grammar production rules. Vikari's grammar is modeled in an EBNF-like format for implemented language features here.
The following language features are fully implemented: numeric types, arithmetic expressions, grouping, print statements, statement separators, variable declarations, assignments, comments, line continuations, boolean types, null types, logical operators, and equality operators. Other features of the interpreter also include syntax error and compilation warning reporting, different phases of execution, REPL mode, and more. See the Usage section for details.
The total list of all planned language features is too multitudinous to exhaustively list here. But to name a few: control flow structures (conditional statements, loops, error handling), collection types (arrays, lists, maps, sets), characters and strings, functions, type declarations, inheritance, parameterized types, multiple base types (interfaces, enums, records, libraries), and modules. As well as more operators, and a standard library.
Build the project with Maven.
mvn install
Run the project by executing the jar and passing it the path to a Vikari file.
java -jar target/Vikari-<version_number>.jar <path_to_vikari_file>
You can also use the vikari.sh script. It will automatically execute your code with the most recent version of Vikari in the target directory.
chmod +x vikari.sh
./vikari.sh <path_to_vikari_file>
I recommend aliasing one of these two commands as vikari
. From my .zshrc
:
alias vikari="java -jar `ls -r ${VIKARI_PROJECT_DIR}/target/Vikari*.jar | head -n1`"
-r
starts Vikari in REPL mode. Use it to sequentially execute Vikari statements and view the result of each statement. Configure the REPL with commands prefixed by !
. !help
prints a list of all commands.
vikari -r
vikari> val << 42
val:Integer = 42
vikari> val * 2
84
vikari> [val '= null] ^ [val = 42]
true
vikari> !exit
Vikari has many options. See -h
or --help
for basic usage, or USAGE.md for more details.
Vikari builds and runs on macOS, Linux, and Windows. It has been tested on macOS 12.6, ZorinOS 16, and Windows 10.
The project Vide was developed specifically as the official Vikari IDE. Its features are somewhat minimum. But it features full syntax highlighting support for all language features.
Vikari is an invented word meaning error. To err is human. Errors are inevitable. What matters most is not that we never make them, but that we learn how to recover from and correct our past mistakes. This process of undoing error is called Atonement. This is a central philosophy behind both the design and implementation of Vikari.
The language is modeled in terms of Atonement Crystals, and Atonement Fields. As components of the language, Atonement Crystals are simply objects, and Atonement Fields are a hash map of string to object. Each crystal is defined by a field. Everything in Vikari is a crystal.
Vikari source files end with the suffix .DNR
for type definitions or .dnr
for script files. In terms of the language, DNR is an initialism meaning default namespace region. Regions are sections of code in Vikari which denote scope. Thus does each DNR file denote a unique default namespace for the code it contains.
The names for these language constructs have their roots in the author's metaphysical model for understanding reality.
Existence is consciousness. The running program of existence is called Atonement. The units of meaning in consciousness which constitute the structure of this program and the output of its execution are called Atonement Crystals. Each crystal's structure is defined by its Atonement Field. These fields are defined entirely in terms of other crystals.
It is called Atonement because consciousness must atone with itself for the original error of believing it has somehow separated from itself, and the resulting immense fear that was then projected outward. This projection organized itself into the Atonement Crystals to facilitate the undoing of itself. The purpose of Atonement is thus to end the separation by undoing the fear that upholds the projection.
DNR is the name for the thought of separation that must be undone. It is the original error. As an initialism, it means Dahlrei Na Rapnir, which are invented words meaning awareness of terror. DNR is the language in which Atonement is written. Thus is the original error now directly wielded by consciousness through consciousness to undo the error in consciousness.
If DNR is meant to be the programming language for all of existence, then Vikari is meant to be a dialect of DNR which implements only a small subset of the total scope of what DNR fully entails. This is also a part of the reasoning behind the Vikari source file suffix.