Giter Site home page Giter Site logo

relax-language's Introduction

A basic compiled programming language.

Tests

Note: The compiler is now bootstrapped, it used to be implemented in AutoHotkey. Yes, I regret that.

For more info, see the docs.

A quick peek at some code

/* Paths are relative to the root directory of the repo, compiler should be ran with:
		./build/compiler.exe -i path/to/this_file.rlx -o path/to/binary.exe
	to ensure the working dir is correct.
*/

#Include ./src/lib/Memory.rlx
#Include ./src/lib/String.rlx
#Include ./src/lib/Console.rlx

define i32 Main(i64 ArgC, i8** ArgV) {
	GetArgs(&ArgC, &ArgV) ; Ensures that ArgC/ArgV are set on Windows, does nothing on Linux
	
	i64 Left := AToI(ArgV[1])
	i64 Right := AToI(ArgV[3])
	
	i8 Operator := ArgV[2][0]
	
	/* The `Print` function is overloaded, with the `i64` version implemented as
		 Print(IToA(Number))
		with the `i8*`/string overload of the `Print` function working as
		 WriteFile(StdOut, String)
		when compiled for Windows, and 
		 sys_write(StdOut, String)
		when compiled for Linux
	 */

	if (Operator = '+') {
		Print(Left + Right)
	}
	else if (Operator = '-') {
		Print(Left - Right)
	}
	else if (Operator = '*') {
		Print(Left * Right)
	}
	else if (Operator = '/') {
		Print(Left / Right)
	}
	
	return 0 /* Returns from `Main()` like normal on Windows, calls `sys_exit(0)` on Linux */
}

(For more examples, check out the tests inside of tests/, or the compiler source itself in src/compiler/)

relax-language's People

Contributors

cloakersmoker avatar micha-ohne-el avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

relax-language's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.