orenono 0.0.1 → 0.0.2
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/README.md +57 -4
- data/bin/orenono +41 -34
- data/lib/brain.rb +108 -108
- data/lib/orenono/version.rb +1 -1
- data/lib/orenono_core.rb +86 -66
- data/lib/orenono_dsl_model.rb +11 -0
- data/samples/pattern3/Orenonofile +10 -0
- data/samples/pattern3/hello_world.bf +56 -0
- data/samples/pattern4/Orenonofile +10 -0
- data/samples/pattern4/hello_world.bf +53 -0
- data/spec/orenono_core_spec.rb +55 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af55e5f715052163f8ce3424d5e28fd1124615ff
|
4
|
+
data.tar.gz: 97e2440757ef668f979a22bec058c464a1bc82e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c4555dcdaa4641ee59269842e149b75bd7e87a28c4869b2623f75e66270f5244449dd9a170fabf804b1be823943331601cb401b9a110f60d3e19e976e9e92c1
|
7
|
+
data.tar.gz: 587fa42b4f3071d8efbbd7117845a5bb861d9fd7d2d3eec9ea22ce3e8d4b3ec16fd58b074cc4b15096dceda4b0ff3c500ac0d45dae811bda352ca06d0a871297
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Orenono
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/orenono)
|
3
4
|
[](https://travis-ci.org/tbpgr/orenono)
|
4
5
|
[](https://coveralls.io/r/tbpgr/orenono)
|
5
6
|
|
@@ -29,19 +30,30 @@ Or install it yourself as:
|
|
29
30
|
### Show help
|
30
31
|
|
31
32
|
~~~bash
|
32
|
-
orenono h
|
33
|
+
$ orenono h
|
34
|
+
Commands:
|
35
|
+
orenono convert # Convert Brainf*ck default syntax to your Orenono...
|
36
|
+
orenono execute # Execute Brainf**k
|
37
|
+
orenono help [COMMAND] # Describe available commands or one specific command
|
38
|
+
orenono init # Generate Orenonofile template
|
39
|
+
orenono version # version
|
40
|
+
|
41
|
+
Options:
|
42
|
+
-h, [--help] # help message.
|
43
|
+
[--version] # version
|
44
|
+
|
33
45
|
~~~
|
34
46
|
|
35
47
|
### Generate Orenonofile
|
36
48
|
|
37
49
|
~~~bash
|
38
|
-
orenono init
|
50
|
+
$ orenono init
|
39
51
|
~~~
|
40
52
|
|
41
53
|
or
|
42
54
|
|
43
55
|
~~~bash
|
44
|
-
orenono i
|
56
|
+
$ orenono i
|
45
57
|
~~~
|
46
58
|
|
47
59
|
Orenonofile contents is...
|
@@ -105,6 +117,46 @@ $ orenono e sample.bf
|
|
105
117
|
Hello, world!
|
106
118
|
~~~
|
107
119
|
|
120
|
+
### Convert Brainf*ck default syntax to your Orenonofile syntax
|
121
|
+
|
122
|
+
* Orenonofile
|
123
|
+
|
124
|
+
~~~ruby
|
125
|
+
# encoding: utf-8
|
126
|
+
|
127
|
+
increment "足す"
|
128
|
+
decrement "引く"
|
129
|
+
start_loop "はじめ"
|
130
|
+
end_loop "おわり"
|
131
|
+
next_cursol "次"
|
132
|
+
previous_cursol "前"
|
133
|
+
display "出"
|
134
|
+
read "入"
|
135
|
+
~~~
|
136
|
+
|
137
|
+
* Target Brainf_ck code.
|
138
|
+
|
139
|
+
~~~brainfuck
|
140
|
+
+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.+++++++..+++.>-.
|
141
|
+
------------.<++++++++.--------.+++.------.--------.>+.
|
142
|
+
~~~
|
143
|
+
|
144
|
+
* Convert
|
145
|
+
|
146
|
+
~~~bash
|
147
|
+
$ orenono c base.bf
|
148
|
+
足す足す足す足す足す足す足す足す足すはじめ次足す足す足す足す足す足す足す足す次足す足す足す足す足す足す足す足す足す足す足す次足す足す足す足す足す前前前引くおわり次出次足す足す出足す足す足す足す足す足す足す出出足す足す足す出次引く出
|
149
|
+
引く引く引く引く引く引く引く引く引く引く引く引く出前足す足す足す足す足す足す足す足す出引く引く引く引く引く引く引く引く出足す足す足す出引く引く引く引く引く引く出引く引く引く引く引く引く引く引く出次足す出
|
150
|
+
~~~
|
151
|
+
|
152
|
+
* Use converted file
|
153
|
+
|
154
|
+
~~~bash
|
155
|
+
$ orenono c base.bf > sample.bf
|
156
|
+
$ orenono e sample.bf
|
157
|
+
Hello, world!$
|
158
|
+
~~~
|
159
|
+
|
108
160
|
## Brainfuck Derivation Language Samples
|
109
161
|
|
110
162
|
### Sample Define1
|
@@ -172,7 +224,8 @@ Hello, world!
|
|
172
224
|
~~~
|
173
225
|
|
174
226
|
## History
|
175
|
-
* version 0.0.
|
227
|
+
* version 0.0.2 : Add converter(Brainf*ck default syntax to your Orenonofile syntax).
|
228
|
+
* version 0.0.1 : First release.
|
176
229
|
|
177
230
|
## Contributing
|
178
231
|
|
data/bin/orenono
CHANGED
@@ -1,34 +1,41 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require 'orenono_core'
|
5
|
-
require 'orenono/version'
|
6
|
-
require 'thor'
|
7
|
-
|
8
|
-
module Orenono
|
9
|
-
# = Orenono CLI
|
10
|
-
class CLI < Thor
|
11
|
-
class_option :help, type: :boolean, aliases: '-h', desc: 'help message.'
|
12
|
-
class_option :version, type: :boolean, desc: 'version'
|
13
|
-
|
14
|
-
desc '
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
Orenono::Core.new.
|
24
|
-
exit(0)
|
25
|
-
end
|
26
|
-
|
27
|
-
desc '
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'orenono_core'
|
5
|
+
require 'orenono/version'
|
6
|
+
require 'thor'
|
7
|
+
|
8
|
+
module Orenono
|
9
|
+
# = Orenono CLI
|
10
|
+
class CLI < Thor
|
11
|
+
class_option :help, type: :boolean, aliases: '-h', desc: 'help message.'
|
12
|
+
class_option :version, type: :boolean, desc: 'version'
|
13
|
+
|
14
|
+
desc 'init', 'Generate Orenonofile template'
|
15
|
+
def init
|
16
|
+
Orenono::Core.new.init
|
17
|
+
exit(0)
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'execute', 'Execute Brainf**k'
|
21
|
+
def execute(file)
|
22
|
+
exit(1) unless file
|
23
|
+
Orenono::Core.new.execute(file)
|
24
|
+
exit(0)
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'convert', 'Convert Brainf*ck default syntax to your Orenonofile syntax'
|
28
|
+
def convert(file)
|
29
|
+
exit(1) unless file
|
30
|
+
puts Orenono::Core.new.bf_to_your_syntax(file)
|
31
|
+
exit(0)
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'version', 'version'
|
35
|
+
def version
|
36
|
+
p Orenono::VERSION
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Orenono::CLI.start(ARGV)
|
data/lib/brain.rb
CHANGED
@@ -1,108 +1,108 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'orenono_dsl'
|
3
|
-
require 'orenono_dsl_model'
|
4
|
-
|
5
|
-
module Orenono
|
6
|
-
# Brain
|
7
|
-
class Brain
|
8
|
-
attr_reader :config, :tokens, :src, :tape
|
9
|
-
attr_reader :memory_cursol, :loop_stack, :code_cursol
|
10
|
-
|
11
|
-
def initialize(config, src = '')
|
12
|
-
@config = config
|
13
|
-
@src = src
|
14
|
-
@tokens = @src.scan(/#{@config.token_patterns}/)
|
15
|
-
@tape = Array.new(65_535) { 0 }
|
16
|
-
@memory_cursol = 0
|
17
|
-
@code_cursol = 0
|
18
|
-
@loop_stack = []
|
19
|
-
end
|
20
|
-
|
21
|
-
# rubocop:disable CyclomaticComplexity, MethodLength
|
22
|
-
def run
|
23
|
-
loop do
|
24
|
-
token = @tokens[@code_cursol]
|
25
|
-
case token
|
26
|
-
when @config.increment
|
27
|
-
increment
|
28
|
-
@code_cursol += 1
|
29
|
-
when @config.decrement
|
30
|
-
decrement
|
31
|
-
@code_cursol += 1
|
32
|
-
when @config.start_loop
|
33
|
-
start_loop
|
34
|
-
when @config.end_loop
|
35
|
-
end_loop
|
36
|
-
when @config.next_cursol
|
37
|
-
next_cursol
|
38
|
-
@code_cursol += 1
|
39
|
-
when @config.previous_cursol
|
40
|
-
previous_cursol
|
41
|
-
@code_cursol += 1
|
42
|
-
when @config.display
|
43
|
-
display
|
44
|
-
@code_cursol += 1
|
45
|
-
when @config.read
|
46
|
-
read
|
47
|
-
@code_cursol += 1
|
48
|
-
end
|
49
|
-
break if @code_cursol >= @tokens.size
|
50
|
-
end
|
51
|
-
end
|
52
|
-
# rubocop:enable CyclomaticComplexity, MethodLength
|
53
|
-
|
54
|
-
def increment
|
55
|
-
@tape[@memory_cursol] += 1
|
56
|
-
end
|
57
|
-
|
58
|
-
def decrement
|
59
|
-
fail InvalidMemoryAccessError if @tape[@memory_cursol].zero?
|
60
|
-
@tape[@memory_cursol] -= 1
|
61
|
-
end
|
62
|
-
|
63
|
-
def start_loop
|
64
|
-
@loop_stack << @code_cursol
|
65
|
-
return goto_end_loop_next if @tape[@memory_cursol] == 0
|
66
|
-
@code_cursol += 1
|
67
|
-
end
|
68
|
-
|
69
|
-
def goto_end_loop_next
|
70
|
-
hit_cnt = 0
|
71
|
-
index = 0
|
72
|
-
@tokens[@code_cursol..-1].each_with_index do |token, i|
|
73
|
-
hit_cnt += 1 if token == @config.end_loop
|
74
|
-
next unless hit_cnt == @loop_stack.size
|
75
|
-
index = i + @code_cursol
|
76
|
-
break
|
77
|
-
end
|
78
|
-
@loop_stack.pop
|
79
|
-
@code_cursol = index + 1
|
80
|
-
end
|
81
|
-
|
82
|
-
def end_loop
|
83
|
-
fail InvalidLoopError, 'Invalid Loop.' if @loop_stack.empty?
|
84
|
-
@code_cursol = @loop_stack.pop
|
85
|
-
end
|
86
|
-
|
87
|
-
def next_cursol
|
88
|
-
@memory_cursol += 1
|
89
|
-
end
|
90
|
-
|
91
|
-
def previous_cursol
|
92
|
-
fail InvalidCursolError, 'Invalid Cursol.' if @memory_cursol.zero?
|
93
|
-
@memory_cursol -= 1
|
94
|
-
end
|
95
|
-
|
96
|
-
def display
|
97
|
-
putc @tape[@memory_cursol]
|
98
|
-
end
|
99
|
-
|
100
|
-
def read
|
101
|
-
@tape[@memory_cursol] = STDIN.readchar.ord
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
class InvalidMemoryAccessError < StandardError; end
|
106
|
-
class InvalidLoopError < StandardError; end
|
107
|
-
class InvalidCursolError < StandardError; end
|
108
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'orenono_dsl'
|
3
|
+
require 'orenono_dsl_model'
|
4
|
+
|
5
|
+
module Orenono
|
6
|
+
# Brain
|
7
|
+
class Brain
|
8
|
+
attr_reader :config, :tokens, :src, :tape
|
9
|
+
attr_reader :memory_cursol, :loop_stack, :code_cursol
|
10
|
+
|
11
|
+
def initialize(config, src = '')
|
12
|
+
@config = config
|
13
|
+
@src = src
|
14
|
+
@tokens = @src.scan(/#{@config.token_patterns}/)
|
15
|
+
@tape = Array.new(65_535) { 0 }
|
16
|
+
@memory_cursol = 0
|
17
|
+
@code_cursol = 0
|
18
|
+
@loop_stack = []
|
19
|
+
end
|
20
|
+
|
21
|
+
# rubocop:disable CyclomaticComplexity, MethodLength
|
22
|
+
def run
|
23
|
+
loop do
|
24
|
+
token = @tokens[@code_cursol]
|
25
|
+
case token
|
26
|
+
when @config.increment
|
27
|
+
increment
|
28
|
+
@code_cursol += 1
|
29
|
+
when @config.decrement
|
30
|
+
decrement
|
31
|
+
@code_cursol += 1
|
32
|
+
when @config.start_loop
|
33
|
+
start_loop
|
34
|
+
when @config.end_loop
|
35
|
+
end_loop
|
36
|
+
when @config.next_cursol
|
37
|
+
next_cursol
|
38
|
+
@code_cursol += 1
|
39
|
+
when @config.previous_cursol
|
40
|
+
previous_cursol
|
41
|
+
@code_cursol += 1
|
42
|
+
when @config.display
|
43
|
+
display
|
44
|
+
@code_cursol += 1
|
45
|
+
when @config.read
|
46
|
+
read
|
47
|
+
@code_cursol += 1
|
48
|
+
end
|
49
|
+
break if @code_cursol >= @tokens.size
|
50
|
+
end
|
51
|
+
end
|
52
|
+
# rubocop:enable CyclomaticComplexity, MethodLength
|
53
|
+
|
54
|
+
def increment
|
55
|
+
@tape[@memory_cursol] += 1
|
56
|
+
end
|
57
|
+
|
58
|
+
def decrement
|
59
|
+
fail InvalidMemoryAccessError if @tape[@memory_cursol].zero?
|
60
|
+
@tape[@memory_cursol] -= 1
|
61
|
+
end
|
62
|
+
|
63
|
+
def start_loop
|
64
|
+
@loop_stack << @code_cursol
|
65
|
+
return goto_end_loop_next if @tape[@memory_cursol] == 0
|
66
|
+
@code_cursol += 1
|
67
|
+
end
|
68
|
+
|
69
|
+
def goto_end_loop_next
|
70
|
+
hit_cnt = 0
|
71
|
+
index = 0
|
72
|
+
@tokens[@code_cursol..-1].each_with_index do |token, i|
|
73
|
+
hit_cnt += 1 if token == @config.end_loop
|
74
|
+
next unless hit_cnt == @loop_stack.size
|
75
|
+
index = i + @code_cursol
|
76
|
+
break
|
77
|
+
end
|
78
|
+
@loop_stack.pop
|
79
|
+
@code_cursol = index + 1
|
80
|
+
end
|
81
|
+
|
82
|
+
def end_loop
|
83
|
+
fail InvalidLoopError, 'Invalid Loop.' if @loop_stack.empty?
|
84
|
+
@code_cursol = @loop_stack.pop
|
85
|
+
end
|
86
|
+
|
87
|
+
def next_cursol
|
88
|
+
@memory_cursol += 1
|
89
|
+
end
|
90
|
+
|
91
|
+
def previous_cursol
|
92
|
+
fail InvalidCursolError, 'Invalid Cursol.' if @memory_cursol.zero?
|
93
|
+
@memory_cursol -= 1
|
94
|
+
end
|
95
|
+
|
96
|
+
def display
|
97
|
+
putc @tape[@memory_cursol]
|
98
|
+
end
|
99
|
+
|
100
|
+
def read
|
101
|
+
@tape[@memory_cursol] = STDIN.readchar.ord
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
class InvalidMemoryAccessError < StandardError; end
|
106
|
+
class InvalidLoopError < StandardError; end
|
107
|
+
class InvalidCursolError < StandardError; end
|
108
|
+
end
|
data/lib/orenono/version.rb
CHANGED
data/lib/orenono_core.rb
CHANGED
@@ -1,66 +1,86 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'brain'
|
3
|
-
require 'orenono_dsl'
|
4
|
-
|
5
|
-
module Orenono
|
6
|
-
# Orenono Core
|
7
|
-
class Core
|
8
|
-
ORENONO_FILE = 'Orenonofile'
|
9
|
-
ORENONO_TEMPLATE = <<-EOS
|
10
|
-
# encoding: utf-8
|
11
|
-
|
12
|
-
# increment command
|
13
|
-
# increment's default value => "+"
|
14
|
-
increment "+"
|
15
|
-
|
16
|
-
# decrement command
|
17
|
-
# decrement's default value => "-"
|
18
|
-
decrement "-"
|
19
|
-
|
20
|
-
# start_loop command
|
21
|
-
# start_loop's default value => "["
|
22
|
-
start_loop "["
|
23
|
-
|
24
|
-
# end_loop command
|
25
|
-
# end_loop's default value => "]"
|
26
|
-
end_loop "]"
|
27
|
-
|
28
|
-
# next_cursol command
|
29
|
-
# next_cursol's default value => ">"
|
30
|
-
next_cursol ">"
|
31
|
-
|
32
|
-
# previous_cursol command
|
33
|
-
# previous_cursol's default value => "<"
|
34
|
-
previous_cursol "<"
|
35
|
-
|
36
|
-
# display command
|
37
|
-
# display's default value => "."
|
38
|
-
display "."
|
39
|
-
|
40
|
-
# read command
|
41
|
-
# read's default value => ","
|
42
|
-
read ","
|
43
|
-
EOS
|
44
|
-
|
45
|
-
# Generate Orenonofile to current directory.
|
46
|
-
def init
|
47
|
-
File.open(ORENONO_FILE, 'w') { |f|f.puts ORENONO_TEMPLATE }
|
48
|
-
end
|
49
|
-
|
50
|
-
# Execute brain f**k
|
51
|
-
def execute(file)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'brain'
|
3
|
+
require 'orenono_dsl'
|
4
|
+
|
5
|
+
module Orenono
|
6
|
+
# Orenono Core
|
7
|
+
class Core
|
8
|
+
ORENONO_FILE = 'Orenonofile'
|
9
|
+
ORENONO_TEMPLATE = <<-EOS
|
10
|
+
# encoding: utf-8
|
11
|
+
|
12
|
+
# increment command
|
13
|
+
# increment's default value => "+"
|
14
|
+
increment "+"
|
15
|
+
|
16
|
+
# decrement command
|
17
|
+
# decrement's default value => "-"
|
18
|
+
decrement "-"
|
19
|
+
|
20
|
+
# start_loop command
|
21
|
+
# start_loop's default value => "["
|
22
|
+
start_loop "["
|
23
|
+
|
24
|
+
# end_loop command
|
25
|
+
# end_loop's default value => "]"
|
26
|
+
end_loop "]"
|
27
|
+
|
28
|
+
# next_cursol command
|
29
|
+
# next_cursol's default value => ">"
|
30
|
+
next_cursol ">"
|
31
|
+
|
32
|
+
# previous_cursol command
|
33
|
+
# previous_cursol's default value => "<"
|
34
|
+
previous_cursol "<"
|
35
|
+
|
36
|
+
# display command
|
37
|
+
# display's default value => "."
|
38
|
+
display "."
|
39
|
+
|
40
|
+
# read command
|
41
|
+
# read's default value => ","
|
42
|
+
read ","
|
43
|
+
EOS
|
44
|
+
|
45
|
+
# Generate Orenonofile to current directory.
|
46
|
+
def init
|
47
|
+
File.open(ORENONO_FILE, 'w') { |f|f.puts ORENONO_TEMPLATE }
|
48
|
+
end
|
49
|
+
|
50
|
+
# Execute brain f**k
|
51
|
+
def execute(file)
|
52
|
+
dsl = read_dsl
|
53
|
+
code = read_code(file)
|
54
|
+
ob = Orenono::Brain.new(dsl.orenono, code)
|
55
|
+
ob.run
|
56
|
+
end
|
57
|
+
|
58
|
+
# Convert Brainf*ck default syntax to your Orenonofile syntax
|
59
|
+
def bf_to_your_syntax(file)
|
60
|
+
dsl = read_dsl
|
61
|
+
code = read_code(file)
|
62
|
+
config = dsl.orenono
|
63
|
+
convert(config, code, config.default_syntaxes, config.syntaxes)
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def convert(config, src, from_syntaxes, to_syntaxes)
|
69
|
+
from_syntaxes.each_with_index do |syntax, i|
|
70
|
+
src = src.gsub(syntax, to_syntaxes[i])
|
71
|
+
end
|
72
|
+
src
|
73
|
+
end
|
74
|
+
|
75
|
+
def read_code(file)
|
76
|
+
File.open(file, 'r:utf-8') { |f|f.read }
|
77
|
+
end
|
78
|
+
|
79
|
+
def read_dsl
|
80
|
+
src = File.open(ORENONO_FILE) { |f|f.read } if File.exist?(ORENONO_FILE)
|
81
|
+
dsl = Orenono::Dsl.new
|
82
|
+
dsl.instance_eval src if File.exist?(ORENONO_FILE)
|
83
|
+
dsl
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lib/orenono_dsl_model.rb
CHANGED
@@ -21,6 +21,17 @@ module Orenono
|
|
21
21
|
# read command
|
22
22
|
attr_accessor :read
|
23
23
|
|
24
|
+
def syntaxes
|
25
|
+
[
|
26
|
+
@increment, @decrement, @start_loop, @end_loop,
|
27
|
+
@next_cursol, @previous_cursol, @display, @read
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_syntaxes
|
32
|
+
%w(+ - [ ] > < . ,)
|
33
|
+
end
|
34
|
+
|
24
35
|
def token_patterns
|
25
36
|
instance_variables.map do |key|
|
26
37
|
sap_key = instance_variable_get(key)
|
@@ -0,0 +1,56 @@
|
|
1
|
+
1時間残業追加1時間残業追加1時間残業追加1時間残業追加1時間残業追加
|
2
|
+
1時間残業追加1時間残業追加1時間残業追加1時間残業追加
|
3
|
+
勤務開始
|
4
|
+
次のタスク
|
5
|
+
1時間残業追加1時間残業追加1時間残業追加1時間残業追加1時間残業追加
|
6
|
+
1時間残業追加1時間残業追加1時間残業追加
|
7
|
+
|
8
|
+
次のタスク
|
9
|
+
1時間残業追加1時間残業追加1時間残業追加1時間残業追加1時間残業追加
|
10
|
+
1時間残業追加1時間残業追加1時間残業追加1時間残業追加1時間残業追加
|
11
|
+
1時間残業追加
|
12
|
+
|
13
|
+
次のタスク
|
14
|
+
1時間残業追加1時間残業追加1時間残業追加1時間残業追加1時間残業追加
|
15
|
+
前のタスク
|
16
|
+
前のタスク
|
17
|
+
前のタスク
|
18
|
+
1時間サービス残業
|
19
|
+
勤務終了
|
20
|
+
|
21
|
+
次のタスク
|
22
|
+
納品 # => H
|
23
|
+
次のタスク
|
24
|
+
1時間残業追加1時間残業追加
|
25
|
+
納品 # => e
|
26
|
+
1時間残業追加1時間残業追加1時間残業追加1時間残業追加1時間残業追加
|
27
|
+
1時間残業追加1時間残業追加
|
28
|
+
納品 # => l
|
29
|
+
納品 # => l
|
30
|
+
1時間残業追加1時間残業追加1時間残業追加
|
31
|
+
納品 # => o
|
32
|
+
次のタスク
|
33
|
+
1時間サービス残業
|
34
|
+
納品 # => ,
|
35
|
+
1時間サービス残業1時間サービス残業1時間サービス残業1時間サービス残業1時間サービス残業
|
36
|
+
1時間サービス残業1時間サービス残業1時間サービス残業1時間サービス残業1時間サービス残業
|
37
|
+
1時間サービス残業1時間サービス残業
|
38
|
+
納品 # => space
|
39
|
+
前のタスク
|
40
|
+
1時間残業追加1時間残業追加1時間残業追加1時間残業追加1時間残業追加
|
41
|
+
1時間残業追加1時間残業追加1時間残業追加
|
42
|
+
納品 # => w
|
43
|
+
1時間サービス残業1時間サービス残業1時間サービス残業1時間サービス残業1時間サービス残業
|
44
|
+
1時間サービス残業1時間サービス残業1時間サービス残業
|
45
|
+
納品 # => o
|
46
|
+
1時間残業追加1時間残業追加1時間残業追加
|
47
|
+
納品 # => r
|
48
|
+
1時間サービス残業1時間サービス残業1時間サービス残業1時間サービス残業1時間サービス残業
|
49
|
+
1時間サービス残業
|
50
|
+
納品 # => l
|
51
|
+
1時間サービス残業1時間サービス残業1時間サービス残業1時間サービス残業1時間サービス残業
|
52
|
+
1時間サービス残業1時間サービス残業1時間サービス残業
|
53
|
+
納品 # => d
|
54
|
+
次のタスク
|
55
|
+
1時間残業追加
|
56
|
+
納品 # => !
|
@@ -0,0 +1,53 @@
|
|
1
|
+
新問題公開新問題公開新問題公開新問題公開新問題公開
|
2
|
+
新問題公開新問題公開新問題公開新問題公開
|
3
|
+
ゴルフ問題開始
|
4
|
+
次の問題を解く
|
5
|
+
新問題公開新問題公開新問題公開新問題公開新問題公開
|
6
|
+
新問題公開新問題公開新問題公開
|
7
|
+
次の問題を解く
|
8
|
+
新問題公開新問題公開新問題公開新問題公開新問題公開
|
9
|
+
新問題公開新問題公開新問題公開新問題公開新問題公開
|
10
|
+
新問題公開
|
11
|
+
次の問題を解く
|
12
|
+
新問題公開新問題公開新問題公開新問題公開新問題公開
|
13
|
+
前の問題を解く
|
14
|
+
前の問題を解く
|
15
|
+
前の問題を解く
|
16
|
+
受付終了
|
17
|
+
ゴルフ問題終了
|
18
|
+
次の問題を解く
|
19
|
+
提出する
|
20
|
+
次の問題を解く
|
21
|
+
新問題公開新問題公開
|
22
|
+
提出する
|
23
|
+
新問題公開新問題公開新問題公開新問題公開新問題公開
|
24
|
+
新問題公開新問題公開
|
25
|
+
提出する
|
26
|
+
提出する
|
27
|
+
新問題公開新問題公開新問題公開
|
28
|
+
提出する
|
29
|
+
次の問題を解く
|
30
|
+
受付終了
|
31
|
+
提出する
|
32
|
+
受付終了受付終了受付終了受付終了受付終了
|
33
|
+
受付終了受付終了受付終了受付終了受付終了
|
34
|
+
受付終了受付終了
|
35
|
+
提出する
|
36
|
+
前の問題を解く
|
37
|
+
新問題公開新問題公開新問題公開新問題公開新問題公開
|
38
|
+
新問題公開新問題公開新問題公開
|
39
|
+
提出する
|
40
|
+
受付終了受付終了受付終了受付終了受付終了
|
41
|
+
受付終了受付終了受付終了
|
42
|
+
提出する
|
43
|
+
新問題公開新問題公開新問題公開
|
44
|
+
提出する
|
45
|
+
受付終了受付終了受付終了受付終了受付終了
|
46
|
+
受付終了
|
47
|
+
提出する
|
48
|
+
受付終了受付終了受付終了受付終了受付終了
|
49
|
+
受付終了受付終了受付終了
|
50
|
+
提出する
|
51
|
+
次の問題を解く
|
52
|
+
新問題公開
|
53
|
+
提出する
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
require "orenono_core"
|
4
|
+
require "orenono_dsl_model"
|
5
|
+
|
6
|
+
describe Orenono::Core do
|
7
|
+
context :convert do
|
8
|
+
cases = [
|
9
|
+
{
|
10
|
+
case_no: 1,
|
11
|
+
case_title: "valid case",
|
12
|
+
config: Orenono::DslModel.new.tap do |e|
|
13
|
+
e.increment = 'add'
|
14
|
+
e.decrement = 'diff'
|
15
|
+
e.start_loop = 'start'
|
16
|
+
e.end_loop = 'end'
|
17
|
+
e.next_cursol = 'next'
|
18
|
+
e.previous_cursol = 'previous'
|
19
|
+
e.display = 'display'
|
20
|
+
e.read = 'read'
|
21
|
+
end,
|
22
|
+
src: '++--[[]]>><<..,,',
|
23
|
+
bf_to_your: true,
|
24
|
+
expected: 'addadddiffdiffstartstartendendnextnextpreviouspreviousdisplaydisplayreadread'
|
25
|
+
},
|
26
|
+
]
|
27
|
+
|
28
|
+
cases.each do |c|
|
29
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
30
|
+
begin
|
31
|
+
case_before c
|
32
|
+
|
33
|
+
# -- given --
|
34
|
+
orenono_core = Orenono::Core.new
|
35
|
+
|
36
|
+
# -- when --
|
37
|
+
actual = orenono_core.send(:convert, c[:config], c[:src], c[:config].default_syntaxes, c[:config].syntaxes)
|
38
|
+
|
39
|
+
# -- then --
|
40
|
+
expect(actual).to eq(c[:expected])
|
41
|
+
ensure
|
42
|
+
case_after c
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def case_before(c)
|
47
|
+
# implement each case before
|
48
|
+
end
|
49
|
+
|
50
|
+
def case_after(c)
|
51
|
+
# implement each case after
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orenono
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tbpgr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,7 +81,12 @@ files:
|
|
81
81
|
- samples/pattern1/orenono.bf
|
82
82
|
- samples/pattern2/Orenonofile
|
83
83
|
- samples/pattern2/orenono.bf
|
84
|
+
- samples/pattern3/Orenonofile
|
85
|
+
- samples/pattern3/hello_world.bf
|
86
|
+
- samples/pattern4/Orenonofile
|
87
|
+
- samples/pattern4/hello_world.bf
|
84
88
|
- spec/brain_spec.rb
|
89
|
+
- spec/orenono_core_spec.rb
|
85
90
|
- spec/spec_helper.rb
|
86
91
|
homepage: https://github.com/tbpgr/orenono
|
87
92
|
licenses:
|
@@ -109,4 +114,5 @@ specification_version: 4
|
|
109
114
|
summary: New Brainf**k derivation language generator and executor.
|
110
115
|
test_files:
|
111
116
|
- spec/brain_spec.rb
|
117
|
+
- spec/orenono_core_spec.rb
|
112
118
|
- spec/spec_helper.rb
|