Skip to content
/ nyx Public

Combines the best of Python and JavaScript while remaining fast, stable, resource efficient and reliable. Allowing users to build anything.

License

Notifications You must be signed in to change notification settings

nyxland/nyx

Repository files navigation

Nyx Programming Language

Nyx is a new programming language that combines the syntax of Python and JavaScript. It is designed to be fast, easy to read, easy to write, resource efficient, and cross-platform compatible. Nyx compiles to native executables for various operating systems.

Warning

This project is under construction and is not yet ready for production use. Please check back later for updates. We do not recommend using this project in its current state. This project is still in the early stages of development and is not yet ready for use. We are developing it publicly to allow for community feedback and contributions. Please check back later for updates.

Table of Contents

Features

  • Combines the best features of Python and JavaScript
  • Easy-to-read syntax
  • Interprets .nyx files directly without compilation

Getting Started

Prerequisites

Building Nyx

  1. Clone the repository:

    git clone https://github.com/nyxland/nyx.git
    cd nyx
  2. Install the necessary dependencies:

    bun install
  3. Build the project using the TypeScript compiler (tsc):

    bun run build

Running Nyx Code

To run Nyx code, use the cli JS file generated in the build process. The cli JS file takes a Nyx source file as input and interprets it directly.

bun run dist/cli.js path/to/your_code.nyx

This will interpret and execute the Nyx code in the specified file.

Example of Using the New CLI Interface

To run a Nyx source file, use the following command:

npx nyx example/index.nyx

This will interpret and execute the Nyx code in the example/index.nyx file.

Nyx Syntax

Nyx syntax combines elements of Python and JavaScript. Here are some examples:

Variables

let x = 10
const y = 20

Functions

def add = (a, b) => {
    return a + b;
}

Conditionals

if x > y:
    print("x is greater than y");
else:
    print("x is not greater than y");

Loops

for i in range(10) {
    print(i);
}

Classes

class Person:
    def __init__ = (self, name, age) => {
        self.name = name
        self.age = age
    }

    def greet = (self) => {
        print(f"Hello, my name is {self.name} and I am {self.age} years old")
    }

Contributing

Contributions are welcome! Please read the contributing guidelines for more information.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Project Status

The Nyx programming language now has a working parser and interpreter. The parser can handle function declarations, variable declarations, and other statements. The interpreter correctly handles function declarations and calls, including the main function. The example code in example/index.nyx runs without errors, demonstrating the functionality of the language.

Parser and Interpreter

The parser and interpreter for Nyx have been implemented to support a combination of JavaScript and Python syntax. The parser generates an Abstract Syntax Tree (AST) from the source code, and the interpreter executes the AST.

Parser

The parser is responsible for converting the source code into an AST. It supports the following features:

  • Function declarations
  • Variable declarations
  • If statements
  • For statements
  • While statements
  • Return statements
  • Import declarations
  • Expression statements

Interpreter

The interpreter executes the AST generated by the parser. It supports the following features:

  • Function calls
  • Variable assignments
  • If statements
  • For loops
  • While loops
  • Importing modules

About

Combines the best of Python and JavaScript while remaining fast, stable, resource efficient and reliable. Allowing users to build anything.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks