Skip to content
Pranav M S edited this page May 17, 2025 · 1 revision

Flux Language Wiki

Overview

Flux is a simple, interpreted programming language implemented in Go. It features a clean syntax and supports basic programming constructs like functions, conditionals, and string operations. The language is designed to be easy to learn and use while providing essential programming features.

Table of Contents

  1. Getting Started
  2. Language Features
  3. Project Structure
  4. Development Guide
  5. VS Code Integration
  6. Examples

Getting Started

Prerequisites

  • Go 1.23.2 or higher
  • Git

Installation

  1. Clone the repository:

    git clone https://github.com/pranavms13/flux-lang.git
    cd flux-lang
  2. Build the project:

    go build -o dist/flux

Running Programs

To run a Flux program:

./dist/flux run <filename>

To compile a Flux program to a binary:

./dist/flux compile <filename>

Language Features

Basic Syntax

Flux supports the following basic features:

  • Variable declarations using let
  • Function definitions using fn
  • Conditional expressions using if-then-else
  • String concatenation using +
  • Basic arithmetic operations
  • Print statements for output
  • Lists and Dictionaries

Data Types

  • Numbers (integers)
  • Strings
  • Lists
  • Dictionaries
  • Functions

Control Flow

  • If-else statements
  • Function calls
  • Basic arithmetic expressions

Project Structure

Core Components

  • lexer/: Tokenizes source code into tokens
  • parser/: Parses tokens into an Abstract Syntax Tree (AST)
  • compiler/: Compiles AST into bytecode
  • vm/: Virtual machine that executes bytecode
  • types/: Core type definitions
  • runtime/: Runtime functionality and built-in functions
  • vsce/: VS Code Extension for Flux Language

Dependencies

  • github.com/alecthomas/participle/v2 - For parsing

Development Guide

Setting Up Development Environment

  1. Install Go 1.23.2 or higher
  2. Clone the repository
  3. Install dependencies:
    go mod download

Building from Source

go build -o dist/flux

Running Tests

go test ./...

VS Code Integration

Installation

  1. Install the dependencies:

    npm install -g yo generator-code
  2. Build the extension:

    cd vsce
    vsce package
  3. Install the VSIX file in VS Code:

    • Open VS Code
    • Press Ctrl+Shift+P
    • Select "Extensions: Install from VSIX..."
    • Choose the generated .vsix file
    • Reload VS Code if prompted

Features

  • Syntax highlighting for .flux files
  • Basic language support
  • Code snippets
  • Bracket matching
  • Comment toggling

Examples

Basic Function Example

print("Functions")
let double = fn(x) => x + x
let result = double(5)
print(result)

String Operations

print("Add Strings")
let name = "Flux"
print("Hello, " + name)

Conditional Expressions

let x = 5
let msg = if x > 0 then {
  print("x is positive")
  "yes"
} else {
  "no"
}
print(msg)

Contributing

Contributions are welcome! Please refer to CONTRIBUTING.md for guidelines on how to contribute to the project.

License

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

Contact