scad 0.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/README.md +51 -0
- data/examples/helloworld.rb +1 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9a4d303d7cbb1553c6129a03878779bb52750ef173815c0a654833333f672428
|
4
|
+
data.tar.gz: db0aef3b25df526a7fdf4d40bad625527acf498606f51bbad5dea7460d1dac90
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 977491e4c039c39eb726dae9857a8a09fa3343d8b025bc40ed99afc1179ed156895a6327347db8591097f2a13bce5fb2286fd242c563e8a5aa3f6aed5ffbfcb4
|
7
|
+
data.tar.gz: '08c343c5da0bb7dd02cff639012a15260b5a609f0262271ed8d2fa011d1cea30ce284aaff6159b2ae3996e3abaf931734374e02728780addefe4e22e4150e82b'
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
```ruby
|
2
|
+
_=$$/$$;$>.<<'' <<(-~_*(-~_*(-~ _*( -~_*(-~_*(-~_*(-+~
|
3
|
+
_*_ [_] +_) )+_ ))) +_) +_) <<(
|
4
|
+
-~_ *(- ~_* (-~ _*( -+~
|
5
|
+
_*(-~_*(-~_*(-~ _*_ [_] +_) ))) )++
|
6
|
+
_)+ +_) <<(-~_*(-~_*(-~_*(-~_ *(- ~_*
|
7
|
+
(-~ _*( -~_ *_[ _]+ _)) ))) )++
|
8
|
+
_)<<(-~_*(-~_*( -~_*(-~_*(-~_*( -~_ *(- ~_*_[_]+_))))+_)))
|
9
|
+
```
|
10
|
+
[Run this code online](https://tio.run/##fZJBDgIhDEX3nKILkrEQ9QCiF5lMmngEExdu5ur4kcwMUPAvGmhL@I/yej8/MRKR3K29Wnuzj0sI00SbQjidV3FboFrIlduyMwW/GnHSnJllQfTCTZ790cnMTY/uhzODa6gn3E0Dwdi@3oEajoQC77mg8TVTSVYqu840Nas3@ryw75J2J5FDlxU1M5qVfjEnc6ouXrn56124MjT6A3uyOyF0CF4NyNAvxvgF)
|
11
|
+
|
12
|
+
# SCAD - Symbolic Compiler and Decompiler
|
13
|
+
|
14
|
+
SCAD is a Ruby to Ruby compiler (so technically it is a transpiler) which outputs code containing only symbols (in particular, it does not use letters and digits in the source). It also includes decompiler (detranspiler?) to reverse code to the original form.
|
15
|
+
|
16
|
+
[Here is hello world](examples/helloworld.rb) compiled by SCAD.
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
```shell
|
21
|
+
$ scad -h
|
22
|
+
Usage: scad [options]
|
23
|
+
-i, --inplace Replace file in place
|
24
|
+
-c, --compile Compile file
|
25
|
+
-d, --decompile Decompile file
|
26
|
+
-a, --automatic Automatically detect and compile or decompile
|
27
|
+
```
|
28
|
+
|
29
|
+
## Why does it exist?
|
30
|
+
|
31
|
+
I was inspired by [RubyConf 2017: Esoteric, Obfuscated, Artistic Programming in Ruby by Yusuke Endoh](https://youtu.be/6K7EmeptEHo?t=572) presentation, where author has shown a technique to write a code by using only symbols. He presented a very neat trick to call eval method by using just symbols and string literals (which can be converted to symbols too):
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
->(&_){
|
35
|
+
_['', 'eval', '<CODE>']
|
36
|
+
}[&:"#{'send'}"]
|
37
|
+
```
|
38
|
+
|
39
|
+
I spent couple of minutes to understand how this code works.
|
40
|
+
After that, I thought that it is a fun idea to write a tool which will automatically convert any Ruby code to this syntax.
|
41
|
+
|
42
|
+
## Does it work with any code?
|
43
|
+
|
44
|
+
The original code has some unexpected features, which would break any serious Ruby code:
|
45
|
+
|
46
|
+
* it changes `self` to the empty string
|
47
|
+
* it poisons code with local variables
|
48
|
+
* `__FILE__` keyword (yes, [it is the keyword](https://github.com/ruby/ruby/blob/12883f8fa6222324880e2b0f161f8c6d6cf365c7/defs/keywords#L13)) returns `"(eval)"`
|
49
|
+
* `__dir__` method returns `n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)+_)))+_)))}[]}"]
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scad
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Radosław Bułat
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-08 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: radek.bulat@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- README.md
|
20
|
+
- examples/helloworld.rb
|
21
|
+
homepage: https://rubygems.org/gems/scad
|
22
|
+
licenses:
|
23
|
+
- MIT
|
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
|
+
rubygems_version: 3.3.7
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: SCAD - Symbolic compiler and decompiler
|
44
|
+
test_files: []
|