Skip to content

My first attempt at creating my own programming language.

License

Notifications You must be signed in to change notification settings

MaciekWin3/Moonwalk

Repository files navigation

🌕 MoonWalk Compiler 🌕

My first attempt at creating my own programming language.

Description 📝

Moonwalk is designed to be a simple, safe, statically typed, compiled language fully compatible with the .NET platform. It is designed to be a simple language that is easy to learn and use, while still being powerful enough to write complex programs in.

Goals 🎯

  • Simple impertaive language
  • Full compatibility with .NET
  • Safe, statically typed, compiled language
  • Modular and eas y to write and create POC
  • Inline testing

Code Examples 📝

For now the syntax is still in flux, but here is a simple example of what I am aiming for:

import Terminal.Gui;

module Main {
	pub func Main(args: string[]): void {
		Application.Init();

		let label: Label = create_label("Hello, World!");

		Application.Top.Add(label)
		Application.Run();
		Application.Shutdown();
	}

	prv func CreateLabel(text: string): Label {
		let label = new Label(text) {
			X = Pos.Center(),
			Y = Pos.Center(),
			Height = 1
		};
		return label;
	}

	prv func ImportExample(): void {
		Utils.Print("Hello, World");
	}
}

module Utils {

	pub struct Person() {

		Name: string;
		Age: int;

		init (name: string, age: int): Person {
			this.Name = name;
			if (age < 18) {
				Console.WriteLine("Younger person");
			}
			this.Age = age;
		}
	}

	pub func Print(text: string): void {
		Console.WriteLine(string);
	}
}

module Main.Tests {

	import NUnit;

	[Test]
	pub func ShoudlAddTwoNumbers(): void {
		let result = 1 + 1;
		Assert.AreEqual(2, result);
	}
}

References 📒

About

My first attempt at creating my own programming language.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages