bfc 1.1.1
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 +7 -0
- data/bin/brainfck-c +34 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 725ab948bf1c6310941013ac8f5dab96bf0997a8
|
4
|
+
data.tar.gz: b4a8aa22890110611d3508f21d29cab8f6d096e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 754b647c6540aad77868fd01f10022c158350b40a54ecaaa2c5cbd2941c9ded54a5606828037742818fb60bc8e19db2691084d23ea2938941e086bd34feeb9e6
|
7
|
+
data.tar.gz: edfb3eb61f123437bd1b2c68d9db5f557cdf8b545a2d14bdb58a1755cd96f4376363b74ef1f34415f3a7b387efc56210952f355e70599f29933ce1daa23fb770
|
data/bin/brainfck-c
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
eval(`ruby -e "require('mkmf');puts(find_executable('gcc').inspect)"`.split(0xa.chr)[-1])||(puts("Please install gcc.");exit(1))
|
3
|
+
code = String.new
|
4
|
+
filename = ARGV.shift
|
5
|
+
$VERBOSE = false
|
6
|
+
$KEEP = false
|
7
|
+
ARGV.include?("-v")&&$VERBOSE=true
|
8
|
+
ARGV.include?("-k")&&$KEEP=true
|
9
|
+
if filename.nil?
|
10
|
+
puts("\e[31m\e[1mUSAGE: \e[0m ./brainfck-c <FILE> <OPTIONS>\n-v: output c code before compiling\n-k: keep the .c file")
|
11
|
+
exit(1)
|
12
|
+
else
|
13
|
+
code = File.read(filename).split("\n")
|
14
|
+
end
|
15
|
+
code_arr = []
|
16
|
+
code.split("").each do |ch|
|
17
|
+
case ch
|
18
|
+
when ">";code_arr << "++ptr;"
|
19
|
+
when "<";code_arr << "--ptr;"
|
20
|
+
when "+";code_arr << "++_c[ptr];"
|
21
|
+
when "-";code_arr << "--_c[ptr];"
|
22
|
+
when ".";code_arr << "putchar(_c[ptr]);"
|
23
|
+
when ",";code_arr << "_c[ptr]=(char)getchar();"
|
24
|
+
when "[";code_arr << "while(_c[ptr]){"
|
25
|
+
when "]";code_arr << "}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
filename==nil&&(print("Enter filename: ");filename=gets.chomp)
|
29
|
+
filename=filename.split(".");filename.pop;filename=filename.join(".")
|
30
|
+
ostr="#include <stdio.h>\nunsigned char _c[30000]={};int ptr=0;\nint main(){#{code_arr.join}return 0;}"
|
31
|
+
File.open("#{filename}.c","w"){|f|f.write(ostr)}
|
32
|
+
$VERBOSE&&puts(ostr)
|
33
|
+
system("gcc #{filename}.c -o #{filename}")
|
34
|
+
!$KEEP&&system("rm #{filename}.c")
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bfc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sesshomariu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Compiles a brainf*** file to a binary executable via gcc
|
14
|
+
email:
|
15
|
+
executables:
|
16
|
+
- brainfck-c
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/brainfck-c
|
21
|
+
homepage:
|
22
|
+
licenses:
|
23
|
+
- GPL-3.0
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.6.8
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: BFC
|
45
|
+
test_files: []
|