Project

chelsy

0.0
No commit activity in last 3 years
No release in over 3 years
C code generator library written in Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 5.0
~> 0.10.4
~> 10.0
~> 0.9.5
 Project Readme

Chelsy

API References Build Status Gem

C code generator library written in Ruby

Chelsy is C code generator library written in Ruby. You can construct AST objects and then transform it to C code.

This library heavily under development. Anything may change at any time. The public API should not be considered stable.

Table of Contents

  • Installation
  • Usage
  • License

Installation

Add this line to your application's Gemfile:

gem 'chelsy'

And then execute:

$ bundle

Or install it yourself as:

$ gem install chelsy

Usage

require 'chelsy'

include Chelsy

doc = Document.new

doc.fragments << Directive::Include.new("stdio.h", system: true)

doc << Function.new(:main, Type::Int.new, [:void]) do |b|
  b << Operator::Call.new(:printf, ["Hello, Chelsy!\n"])
  b << Return.new(0)
end

puts Translator.new.translate(doc)

This script generates famous "Hello, World!" C program.

#include <stdio.h>

int main(void) {
    printf("Hello, Chelsy!\n");
    return 0;
}

See sample directory to find more samples.

License

The gem is available as open source under the terms of the MIT License.