Vāṇī is a logic-based programming language built in Prolog. It focuses on clarity, expressiveness, and simplicity, supporting core features like arithmetic, conditionals, loops, and strings. Designed for education and experimentation in language design.
Team Name: Vani
Team Number: Team 38
Course: SER502 – Languages and Programming Paradigm
Project: Project: Compiler and Virtual Machine for a Programming Language
- OS: Linux / MacOS / Windows (WSL recommended)
- Language: Prolog (SWI-Prolog recommended)
- Tools: Definite Clause Grammars (DCG)
- SWI-Prolog
- DCG for grammar
- Custom-built lexer, parser, and runtime in Prolog
- GitHub for version control
This project implements a Tokenizer and Parser for a custom imperative language called Vani, written in Prolog using Definite Clause Grammars (DCGs). The language includes constructs like define, bet, finna, say, etc, and more—designed to resemble a playful blend of programming and Gen Z slang.
src/tokenizer.pl– Tokenizes GenZLang code into structured tokenssrc/parser.pl– Parses tokens into an abstract syntax tree (AST)src/evaluator.pl- Core interpreter logic for GenZLang. Evaluates parsed AST structures.data/– Sample input and test casesexecutor.sh/– Bash script for easy program execution (MacOS)executor.bat/– Bat script for easy program execution (Windows)
bash
sudo apt install swi-prolog
- Step 1:Open the terminal and run
swipl
- Step 2: Load the modules
?- [tokenizer].
?- [parser].
?- [evaluator]
- Step 3: Run a Parse Query
?- parse("define x as 5; say x;", Tree).
output :
Tree = program([
define(x, number(5)),
print(identifier(x))
]).
chmod +x executor.sh
.\executor.bat data\program1
Purpose : Acts as the entrypoint to run a GenZLang program from a file.
Invokes Prolog interpreter with finalExecute.pl as the main module.
Takes a file path as an argument (e.g., data/program3).
Passes that file into the run/0 predicate in finalExecute.pl.
Purpose: The main driver that ties together the tokenizer, parser, and evaluator to run a full GenZLang program.
Reads a .genz source file passed via command-line (from executor.sh).
Uses tokenizer.pl to convert the source string into tokens.
Uses parser.pl to parse the tokens into an abstract syntax tree (AST).
Uses evaluator.pl to execute the AST and produce output (e.g., printing strings or numbers).
bash executor.sh data/program1
.\executor.bat data\program1
Watch our full demo here: YouTube Link

