Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

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>voidsay_hello (char*name) {
printf("Hello, %s!\n", name);
}
voidprint_person (char*name, intage) {
printf("Person<name=%s, age=%d>\n", name, age);
}
intmain (void) {
char*name="Eder";
intage=20;
say_hello(name);
print_person(name, age);
return0;
}

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

10 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages