Skip to content

Experimental, statically-typed, compiled programming language which compiles to Web Assembly bytecode

License

Notifications You must be signed in to change notification settings

iddev5/vexa-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vexa-lang

This is an attempt to create a statically-typed, compiled programming language which compiles to Web Assembly bytecode. The project is implemented in Zig 0.3.0. The compiler generates valid .wasm objects in most of the cases and can be verified using wasm tools.

History

The project originally started as a Lua implementation which compiles to WASM. However, as Lua is a dynamically typed language and its table-oriented object system needs significant runtime support, the idea was shortly scraped. Thus, I modified the code to be its own language, somewhat inspired by Python and Odin.

Stages of Compiler

  • Tokenizer: It uses a standard state-machine based tokenizer
  • Parser: Arranges tokens into an AST
  • analysis: Converts AST into IR and performs type checking
  • WasmGen: Responsible for actually generating the WASM bytecode

Types in language

Currently the following types are implemented in the language:

  • void: void
  • bool: i32
  • float: f64
  • func: i32, stored in an IR node

Features

  • Numeric and boolean literals
  • Binary expressions
  • Unary expressions
  • If-elseif-else statements
  • While loops
  • Diagnostics and error messages
  • Function
  • Function parameters
  • Function return values
  • Multi-return values (using WASM extensions)
  • Multi-return values using globals
  • Sequence types (arrays, lists)
  • For-loops for sequence types
  • Hash types (dictionary, set)
  • User defined types (structs) - Work in progress
  • Enum and union types

References

About

Experimental, statically-typed, compiled programming language which compiles to Web Assembly bytecode

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages