chelsy 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/.yardopts +1 -0
- data/README.md +38 -6
- data/chelsy.gemspec +12 -11
- data/lib/chelsy/ast.rb +922 -91
- data/lib/chelsy/syntax.rb +23 -10
- data/lib/chelsy/translator.rb +562 -43
- data/lib/chelsy/version.rb +1 -1
- data/sample/hello_chelsy.rb +1 -2
- data/sample/temperature.c +17 -0
- data/sample/temperature.rb +39 -0
- metadata +21 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56cad98ddddf30558dd50bde2947f90b785fea1b
|
4
|
+
data.tar.gz: 52271a3c6e50b65b1961316cd11ce5d9160226d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe0511b66fc3ba2ca8c0e7a04eec0ae9298bea40ffba516bc367bc5017b3ba29f2deef4bc553eb0fc91be520cec55b3f41894753f3eefed9778348c460f82aac
|
7
|
+
data.tar.gz: 6b9c4b85d08f88956c60735a9fd72d4c04d4dbe0415eb0fd1a179aa7af2a46cc9c59ed4770761fd9b1ecda766bdd0021e6e1508e8b677fcbcfe78fd2d4e74f26
|
data/.travis.yml
CHANGED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
-m markdown
|
data/README.md
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
# Chelsy
|
2
2
|
|
3
|
-
|
3
|
+
[](http://www.rubydoc.info/gems/chelsy)
|
4
|
+
[](https://travis-ci.org/ishikawa/chelsy)
|
5
|
+
[](https://rubygems.org/gems/chelsy)
|
4
6
|
|
5
|
-
|
7
|
+
> C code generator written in Ruby
|
8
|
+
|
9
|
+
**Chelsy** is C code generator library written in Ruby. You can construct AST objects and then transform it to C code.
|
10
|
+
|
11
|
+
## Table of Contents
|
12
|
+
|
13
|
+
- [Installation](#installation)
|
14
|
+
- [Usage](#usage)
|
15
|
+
- [License](#license)
|
6
16
|
|
7
17
|
## Installation
|
8
18
|
|
@@ -22,13 +32,35 @@ Or install it yourself as:
|
|
22
32
|
|
23
33
|
## Usage
|
24
34
|
|
25
|
-
|
35
|
+
```ruby
|
36
|
+
require 'chelsy'
|
37
|
+
|
38
|
+
include Chelsy
|
39
|
+
|
40
|
+
doc = Document.new
|
26
41
|
|
27
|
-
|
42
|
+
doc.fragments << Directive::Include.new("stdio.h", system: true)
|
28
43
|
|
29
|
-
|
44
|
+
doc << Function.new(:main, Type::Int.new, [:void]) do |b|
|
45
|
+
b << Operator::Call.new(:printf, [Constant::String.new("Hello, Chelsy!\n")])
|
46
|
+
b << Return.new(Constant::Int.new(0))
|
47
|
+
end
|
48
|
+
|
49
|
+
puts Translator.new.translate(doc)
|
50
|
+
```
|
51
|
+
|
52
|
+
This script generates famous "Hello, World!" C program.
|
53
|
+
|
54
|
+
```c
|
55
|
+
#include <stdio.h>
|
56
|
+
|
57
|
+
int main(void) {
|
58
|
+
printf("Hello, Chelsy!\n");
|
59
|
+
return 0;
|
60
|
+
}
|
61
|
+
```
|
30
62
|
|
31
|
-
|
63
|
+
See [sample](https://github.com/ishikawa/chelsy/tree/master/sample) directory to find more samples.
|
32
64
|
|
33
65
|
## License
|
34
66
|
|
data/chelsy.gemspec
CHANGED
@@ -4,15 +4,15 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'chelsy/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'chelsy'
|
8
8
|
spec.version = Chelsy::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Takanori Ishikawa']
|
10
|
+
spec.email = ['takanori.ishikawa@gmail.com']
|
11
11
|
|
12
|
-
spec.homepage =
|
13
|
-
spec.summary =
|
14
|
-
spec.description =
|
15
|
-
spec.license =
|
12
|
+
spec.homepage = 'https://github.com/ishikawa/chelsy'
|
13
|
+
spec.summary = 'C code generator written in Ruby'
|
14
|
+
spec.description = 'C code generator written in Ruby'
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
18
|
f.match(%r{^(test|spec|features)/})
|
@@ -20,8 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.required_ruby_version = '~> 2.0'
|
22
22
|
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
26
|
+
spec.add_development_dependency 'pry', '~> 0.10.4'
|
27
|
+
spec.add_development_dependency 'yard', '~> 0.9.5'
|
27
28
|
end
|