r-fxxk 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -3
- data/VERSION +1 -1
- data/lib/r-fxxk.rb +7 -4
- data/r-fxxk.gemspec +3 -3
- data/spec/r-fxxk_spec.rb +7 -7
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
= r-fxxk
|
2
2
|
|
3
|
-
|
3
|
+
A Brainfuck implementation, and generator for your own Brainfuck-like interpreter.
|
4
4
|
|
5
5
|
== Example of Ook! (http://ja.wikipedia.org/wiki/Ook!)
|
6
|
-
class Ook <
|
6
|
+
class Ook < Brainfuck
|
7
7
|
nxt 'Ook. Ook?'
|
8
8
|
prv 'Ook? Ook.'
|
9
9
|
inc 'Ook. Ook.'
|
@@ -18,7 +18,7 @@ and you can run:
|
|
18
18
|
Ook.new.fuck(read('hello.ook'))
|
19
19
|
|
20
20
|
you can generate with initialize options:
|
21
|
-
|
21
|
+
Brainfuck.new(nxt: 'M', prv: 'O', inc: 'N', dec: 'A', get: 'm', put: 'o', opn: 'n', cls: 'a').fuck(read('hello.mona'))
|
22
22
|
|
23
23
|
SEE ALSO spec/r-fxxk_spec.rb
|
24
24
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/r-fxxk.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class Brainfuck
|
2
2
|
def initialize(options = {})
|
3
3
|
self.class.default_mapping.each do |key, default|
|
4
4
|
operations[key] = options.has_key?(key) ? options[key] : default
|
@@ -24,7 +24,7 @@ class BrainFuck
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def compile(src)
|
27
|
-
|
27
|
+
Brainfuck.new.translate(self, src)
|
28
28
|
end
|
29
29
|
|
30
30
|
def translate(other, src)
|
@@ -42,7 +42,7 @@ class BrainFuck
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def hello_world
|
45
|
-
translate(
|
45
|
+
translate(Brainfuck, '>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-]<.>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.[-]>++++++++[<++++>-]<+.[-]++++++++++.')
|
46
46
|
end
|
47
47
|
|
48
48
|
def fuck(src)
|
@@ -97,10 +97,13 @@ class BrainFuck
|
|
97
97
|
end
|
98
98
|
|
99
99
|
class << self
|
100
|
-
|
100
|
+
Brainfuck.default_mapping.keys.each do |op|
|
101
101
|
define_method(op) do |val|
|
102
102
|
default_mapping[op] = val
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
|
+
|
108
|
+
# For backwards compatibility.
|
109
|
+
BrainFuck = Brainfuck
|
data/r-fxxk.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "r-fxxk"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["masarakki"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-11-01"
|
13
13
|
s.description = "generate your own brain-fxxk-like language"
|
14
14
|
s.email = "masaki@hisme.net"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
s.homepage = "http://github.com/masarakki/r-fxxk"
|
36
36
|
s.licenses = ["MIT"]
|
37
37
|
s.require_paths = ["lib"]
|
38
|
-
s.rubygems_version = "1.8.
|
38
|
+
s.rubygems_version = "1.8.24"
|
39
39
|
s.summary = "generate your own brain-fxxk-like language"
|
40
40
|
|
41
41
|
if s.respond_to? :specification_version then
|
data/spec/r-fxxk_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
-
class Ook <
|
3
|
+
class Ook < Brainfuck
|
4
4
|
nxt 'Ook. Ook?'
|
5
5
|
prv 'Ook? Ook.'
|
6
6
|
inc 'Ook. Ook.'
|
@@ -15,9 +15,9 @@ def src(file)
|
|
15
15
|
open(File.expand_path(File.dirname(__FILE__) + "/test_data/#{file}")).read
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
19
|
-
context 'default
|
20
|
-
subject {
|
18
|
+
describe Brainfuck do
|
19
|
+
context 'default Brainfuck' do
|
20
|
+
subject { Brainfuck.new }
|
21
21
|
its(:nxt) { should eq '>' }
|
22
22
|
its(:prv) { should eq '<' }
|
23
23
|
its(:inc) { should eq '+' }
|
@@ -32,7 +32,7 @@ describe BrainFuck do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
context 'customize in initialize' do
|
35
|
-
subject {
|
35
|
+
subject { Brainfuck.new(nxt: 'M', prv: 'O', inc: 'N', dec: 'A', get: 'm', put: 'o', opn: 'n', cls: 'a') }
|
36
36
|
its(:nxt) { should eq 'M' }
|
37
37
|
its(:prv) { should eq 'O' }
|
38
38
|
its(:inc) { should eq 'N' }
|
@@ -44,8 +44,8 @@ describe BrainFuck do
|
|
44
44
|
it "fuck(hello.mona) should be 'Hello World\\n'" do
|
45
45
|
subject.fuck(src('hello.mona')).should eq "Hello World!\n"
|
46
46
|
end
|
47
|
-
it "translate(
|
48
|
-
subject.translate(
|
47
|
+
it "translate(Brainfuck.new, hello.bf) should == hello.mona" do
|
48
|
+
subject.translate(Brainfuck, src('hello.bf')).strip.should eq src('hello.mona').strip
|
49
49
|
end
|
50
50
|
its(:hello_world) { should == src('hello.mona').strip }
|
51
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r-fxxk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -96,7 +96,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
segments:
|
98
98
|
- 0
|
99
|
-
hash:
|
99
|
+
hash: 304817909524705550
|
100
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
101
|
none: false
|
102
102
|
requirements:
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 1.8.
|
108
|
+
rubygems_version: 1.8.24
|
109
109
|
signing_key:
|
110
110
|
specification_version: 3
|
111
111
|
summary: generate your own brain-fxxk-like language
|