Skip to content

A language implemented mainly for the purpose of learning. This is meant to be a language with a syntax close to Ruby that transpiles to C code.

Notifications You must be signed in to change notification settings

asynched/c-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

c-ruby

A language implemented mainly for the purpose of learning. This is meant to be a language with a syntax close to Ruby that transpiles to C code.

Example

This c-ruby snippet

import <stdio.h>
import <stdlib.h>

fn say_hello(name: *char) -> void do
	printf("Hello, %s!\n", name)
end

fn print_person(name: *char, age: int) -> void do
	printf("Person<name=%s, age=%d>\n", name, age)
end

fn main -> int do
	name: *char = "Eder"
	age: int = 20
	say_hello(name)
	print_person(name, age)
	return 0
end

Turns into this when transpiled into C code:

#include <stdio.h>
#include <stdlib.h>
void say_hello (char* name) {
	printf("Hello, %s!\n", name);
}
void print_person (char* name, int age) {
	printf("Person<name=%s, age=%d>\n", name, age);
}
int main (void) {
	char* name = "Eder";
	int age = 20;
	say_hello(name);
	print_person(name, age);
	return 0;
}

Development

Requirements

  • NodeJS
  • GCC

Parsing a file

Check if the syntax is valid and generate an AST.

$ yarn dev:parse <file>

Building the parser

Build the parser module to use in conjunction with the codegen.

$ yarn build:parser

Transpiling

Turning c-ruby into c code.

$ yarn transpile <file>

Author

Eder Lima
Eder Lima

About

A language implemented mainly for the purpose of learning. This is meant to be a language with a syntax close to Ruby that transpiles to C code.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published