Introduction to Wave v0.1.2-pre-beta: Assignment Operators, Added Remainder and Generalized Indexing Support
LunaStev

LunaStev @lunastev

About: Developer

Location:
Goyang, Republic of Korea
Joined:
Sep 11, 2024

Introduction to Wave v0.1.2-pre-beta: Assignment Operators, Added Remainder and Generalized Indexing Support

Publish Date: Jun 21
1 0

Hello! I'm LunaStev, the developer of Wave.

We are pleased to announce Wave v0.1.2-pre-beta
This update supports indexing, supports the rest of the operators. And I added an assignment operator. And I fixed a number of bugs.


✅ Added Features

🔍 Generalized Indexing Support

  • Extended arr[index] syntax to support variable indexing in any context.

  • Now supports dynamic indexing like arr[i], ptr[j], get_array()[k] inside if, while, return, and assignments.

  • Internally handles pointer types (e.g., i8*) using GEP and performs automatic type casting (e.g., i8 vs i64) for comparisons and assignments.

➕ Added % (Remainder) Operator Support

  • Wave now supports the modulo operator % for integer types.

  • Expressions like a % b, 10 % 3, and var x: i32 = a % b are now fully parsed and compiled to LLVM IR using srem (signed remainder).

  • Parser was updated to recognize % as TokenType::Remainder, and IR generation uses build_int_signed_rem for correct runtime behavior.

  • % is fully supported inside expressions, assignments, conditionals, and return statements.

⚙️ Assignment Operators (+=, -=, *=, /=, %=)

  • Supports compound assignment operators for both integers (i32) and floating-point numbers (f32).

  • Operators implemented: +=, -=, *=, /=, %=.

  • Type-safe operation with proper distinction between integer and float IR instructions:

    • add, sub, mul, sdiv, srem for integers.
    • fadd, fsub, fmul, fdiv, frem (uses fmodf) for floats.
  • Implicit type casting during assignment (e.g., assigning an int to a float variable triggers intfloat conversion).

  • Proper LLVM IR generation for all supported operations, including float remainder via external fmodf call (linked with -lm).

🐛 Bug Fixes

🔢 Accurate Token Differentiation Between Integers and Floats

  • Number parsing logic has been overhauled to properly distinguish between integer literals (e.g., 42) and floating-point literals (e.g., 3.14, 42.0).

  • Previously, all numeric literals were parsed as Float(f64) tokens, even when no decimal point was present.
    → Now, tokens like 123 are correctly parsed as Number(i64), and 123.45 as Float(f64).

  • Introduced internal flag is_float to detect presence of . during scanning. If found, the number is parsed as a float; otherwise, as an integer.

  • Implemented type-safe error handling:

    • Fallbacks to TokenType::Number(0) or TokenType::Float(0.0) on parse failure, ensuring the lexer remains stable on malformed input.
  • This fix improves downstream type checking, IR generation, and expression evaluation, especially for typed languages like Wave where i64 and f64 must be handled distinctly.

✨ Other Changes

🧠 Library and Binary 2 Coexist

  • Add lib.rs for easy package manager creation, development, and easy access.

Showcase

The showcase is available at Wave-Test.


Thank you for using Wave! Stay tuned for future updates and enhancements.


Installation Guide

For Linux:

  1. Download and Extract:

    • Download the wave-v0.1.2-pre-beta-x86_64-linux-gnu.tar.gz file from the official source.
    • Use the wget command:
     wget https://github.com/LunaStev/Wave/releases/download/v0.1.2-pre-beta/wave-v0.1.2-pre-beta-x86_64-linux-gnu.tar.gz
    
  • Extract the archive:

     sudo tar -xvzf wave-v0.1.2-pre-beta-x86_64-linux-gnu.tar.gz -C /usr/local/bin
    
  1. Setting up LLVMs

    • Open a terminal and type:
     sudo apt-get update
     sudo apt-get install llvm-14 llvm-14-dev clang-14 libclang-14-dev lld-14 clang
     sudo ln -s /usr/lib/llvm-14/lib/libLLVM-14.so /usr/lib/libllvm-14.so
     export LLVM_SYS_140_PREFIX=/usr/lib/llvm-14
     source ~/.bashrc
    
  2. Verify Installation:

    • Open a terminal and type:
     wavec --version
    
  • If the version number displays, the installation was successful.

PR and Commits


Contributor

@lunastev | 🇰🇷


Website

Website
GitHub
Discord
Ko-fi

Comments 0 total

    Add comment