r-fxxk 0.2.0 → 0.3.0

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -41,6 +41,10 @@ class BrainFuck
41
41
  dst
42
42
  end
43
43
 
44
+ def hello_world
45
+ translate(BrainFuck, '>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-]<.>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.[-]>++++++++[<++++>-]<+.[-]++++++++++.')
46
+ end
47
+
44
48
  def fuck(src)
45
49
  src = compile(src)
46
50
  ptr = 0
@@ -64,9 +68,28 @@ class BrainFuck
64
68
  output << cell[ptr].chr
65
69
  when :get
66
70
  when :opn
67
- next_cur = src.index(self.class.bf_mapping[:cls], cur) + 1 if cell[ptr] == 0
71
+ if cell[ptr] == 0
72
+ open_count = 1
73
+ buf_cur = cur
74
+ while open_count > 0
75
+ open_count.times do
76
+ next_cur = src.index(self.class.bf_mapping[:cls], buf_cur)
77
+ open_count = src[buf_cur+1..next_cur].count(self.class.bf_mapping[:opn])
78
+ buf_cur = next_cur
79
+ end
80
+ end
81
+ next_cur = next_cur + 1
82
+ end
68
83
  when :cls
69
- next_cur = src.rindex(self.class.bf_mapping[:opn], cur)
84
+ close_count = 1
85
+ buf_cur = cur
86
+ while close_count > 0
87
+ close_count.times do
88
+ next_cur = src.rindex(self.class.bf_mapping[:opn], buf_cur)
89
+ close_count = src[next_cur..buf_cur-1].count(self.class.bf_mapping[:cls])
90
+ buf_cur = next_cur
91
+ end
92
+ end
70
93
  end
71
94
  cur = next_cur || src.index(reg, cur) + matches[1].length
72
95
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "r-fxxk"
8
- s.version = "0.2.0"
8
+ s.version = "0.3.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-04-17"
12
+ s.date = "2012-04-20"
13
13
  s.description = "generate your own brain-fxxk-like language"
14
14
  s.email = "masaki@hisme.net"
15
15
  s.extra_rdoc_files = [
@@ -47,6 +47,7 @@ describe BrainFuck do
47
47
  it "translate(BrainFuck.new, hello.bf) should == hello.mona" do
48
48
  subject.translate(BrainFuck, src('hello.bf')).strip.should eq src('hello.mona').strip
49
49
  end
50
+ its(:hello_world) { should == src('hello.mona').strip }
50
51
  end
51
52
 
52
53
  context 'customized class' do
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.2.0
4
+ version: 0.3.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-04-17 00:00:00.000000000 Z
12
+ date: 2012-04-20 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: -1022431185
99
+ hash: 1116091257325722486
100
100
  required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  none: false
102
102
  requirements: