Only this pageAll pages
Powered by GitBook
1 of 4

1.1.0

Loading...

Loading...

Loading...

Loading...

Contributing

Thank you for your interest in contributing to Varphi! We believe that open collaboration is key to making Varphi the best it can be. Whether you're fixing a bug, improving documentation, suggesting features, or sharing your insights, every contribution is valued and appreciated.

How You Can Help

There are many ways to contribute:

  • Code Contributions: Help improve Varphi by fixing bugs, optimizing performance, or adding new features.

  • Documentation: Clear and comprehensive documentation makes Varphi more accessible to everyone.

  • Bug Reports & Feature Requests: Found an issue or have an idea? Let us know!

  • Community Engagement: Join discussions, answer questions, and help others get started.

Getting Started

We are grateful for your time and effort in making Varphi better. Every contribution, big or small, helps shape the future of the project. Thank you for being a part of this journey!

Check out our for guidelines and best practices.

Explore our to find something to work on.

Contributing Guide
open issues

Testing and Linting

Testing Your Code

All tests for the Varphi project are located under the testsdirectory. When testing Python code, please use Pytest as the testing framework (for examples of Pytest tests, please check the existing tests). When implementing a new feature for Varphi, please be sure to test it thoroughly before opening a pull request on GitHub. When you're finished testing your own feature, make sure your new code does not break any existing tests by running all existing tests, as shown below.

Running All Unit and End-to-End Tests

The easiest way to run all tests is to run

$ make test

This will rebuild Varphi and run all tests.

Linting

$ make lint

This will rebuild Varphi and run linting on the varphidirectory.

Automatic Testing and Linting

We also have a GitHub workflow to automatically test and lint the code base in the event that a pull request is made to the main branch. You should double check that your code passes these checks when you open a pull request.

For pull requests to be considered, the codebase is checked against a linter. We use to do this. The easiest way to run linting on the codebase is to run

Pylint

Codebase Structure

Varphi's High-Level Process

Here is a timeline of events that happen when a user invokes the Varphi Interpreter (vpi) on a Varphi file:

1

Argument Handling

2

Compiler API Call

The Varphi Interpreter makes an API call to the Varphi-to-Python compiler, sending the file name of the user's Varphi source code file.

3

Lexing

The user's Varphi source code file is opened for reading, and it's contents are passed through a lexer. The lexer tokenizes the code and catches specific syntax errors at this stage (specifically, a syntax error is thrown by the lexer only if a line element does not fit the criteria to be a state name, tally, blank, or head direction).

4

Parsing

The tokens from the lexer are passed into a parser, which combines them to form internal representations of the Varphi lines in the user's source code. If there are any malformed lines in the user's source code, syntax errors will be thrown by the parser.

5

Translator

The translator goes through the internal representations of the Varphi lines and, for each line, produces equivalent Python code. This Python code, using the Varphi Runtime Library written in Python, will match the behavior of the user's Varphi source code.

6

Evaluating the Compiled Code

Structure of the Codebase

The Varphi codebase consists of two parts:

  1. The Varphi-to-Python Compiler

  2. The Varphi Interpreter

The Varphi-to-Python Compiler

The Varphi-to-Python Compiler is a (non-published) Python package and is located under the varphi directory in the source code directory.

The three components of the Varphi-to-Python Compiler are:

  1. The lexer and parser

  2. The translators (Compilers)

  3. The Varphi Runtime Library

The Lexer and Parser

The lexer and parser are generated from a grammar file (Varphi.g4) and are not included in the source code. When Varphi is built, they are located under varphi/parsing/VarphiLexer.py and varphi/parsing/VarphiParser.py, respectively.

The Translators (Compilers)

Varphi includes a translator, or compiler, for every possible target (command-line program, debug adapter, etc.). These are located under varphi/compilation/varphi_translator.py.

The Varphi Runtime Library

The Varphi Runtime Library is a set of utilities used by the Python code which Varphi programs are compiled to. This library is located under varphi/runtime.

The Varphi Interpreter executable, through , parses the arguments supplied to the executable. It extract's the user's Varphi source code file path, and determines what the compilation target will be (either a command-line program, command-line program with debugging, or debug adapter).

Once every line has been stepped through by the translator, a string containing the compiled Python code is sent to the interpreter. A call to is made on the compiled Python code, which opens a session that the user can pass the input tape to and receive output from.

Python's argparse
Python's exec

Building Varphi

This guide assumes the following command-line programs are located on your PATH:

  • Make

  • Git

Cloning the Repository

$ git clone https://github.com/varphi-lang/varphi.git

A new directory named varphi should now be created with the source code under it. Change into this directory:

$ cd varphi

For the rest of this guide, it is assumed that your terminal is changed into the Varphi root directory.

Building Varphi

Varphi uses Make for building the project. The easiest way to build everything in the Varphi project is by running

$ make executable

This will generate the lexer and parser, install the Varphi-to-Python Compiler as a package (called varphi) in a Python virtual environment, and generate the Varphi Interpreter (vpi) binary for your operating system under bin/vpi(or bin\vpi.exe if you have a Windows machine).

You can also build individual components of the Varphi project, as shown below.

Building the Lexer and Parser

To build the lexer and parser, run

$ make parsing

You should see the varphi/parsing directory become populated with the following three Python files:

  1. VarphiLexer.py

  2. VarphiParser.py

  3. VarphiListener.py

Installing the Varphi-to-Python Compiler as a Python Package

To install the Varphi-to-Python compiler as a Python package in a Python virtual environment, run

$ make install

NOTE: This will build the lexer and parser as a side effect, as the lexer and parser are needed as a prerequisite.

(at least version 3.13)

Varphi is a completely open-source language. It is hosted on a . You can get the source on your local machine by cloning the repository. You can do so by running the following command in a new terminal:

Python
Java 23
cURL
public GitHub repository