dtr_to_rust 0.0.4 → 0.0.5
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/lib/instruction_handler.rb +21 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e847ba23b85fbcb73f654a7204b136c7d22159da92f1c19834242382f0422e9
|
4
|
+
data.tar.gz: 02c903ad18bc3ee83024db1df4d838e36dcf58f8fef3e3cb50b1b912037f7da0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15801ee722bdc1d23650c2c37535e7a836250ec313a97cadc7b2830679dbd093901ab46f2ad4e1fa995710294d8a985c173db0d9667b11129ec2fac1bb3c8c3a
|
7
|
+
data.tar.gz: 5f113fe380f4e21f260dd7bfdf6600e0354e0b24f8896cda19f22dcd38d9b173d8dc53eb55962a97ae89b21dc39a36f479c817ccf404164c6be111c7d4b88fae
|
data/lib/instruction_handler.rb
CHANGED
@@ -9,10 +9,14 @@ module DTRToRust
|
|
9
9
|
|
10
10
|
def generate_rust
|
11
11
|
case @instruction[:instruction]
|
12
|
-
when 'AddSymbols'
|
13
|
-
handle_add_symbols
|
14
12
|
when 'Return'
|
15
13
|
handle_return
|
14
|
+
when 'log_string'
|
15
|
+
handle_log_string
|
16
|
+
when 'add_and_assign'
|
17
|
+
handle_add_and_assign
|
18
|
+
when 'evaluate'
|
19
|
+
"foo bar"
|
16
20
|
else
|
17
21
|
raise "Unknown instruction type: #{@instruction[:instruction]}"
|
18
22
|
end
|
@@ -22,14 +26,24 @@ module DTRToRust
|
|
22
26
|
|
23
27
|
attr_reader :instruction
|
24
28
|
|
25
|
-
def
|
26
|
-
"
|
27
|
-
|
28
|
-
|
29
|
+
def spacing(scope)
|
30
|
+
" " * scope
|
31
|
+
end
|
32
|
+
|
33
|
+
def form_rust_string(instruction_string, scope)
|
34
|
+
"#{spacing(scope)}#{instruction_string}"
|
29
35
|
end
|
30
36
|
|
31
37
|
def handle_return
|
32
|
-
|
38
|
+
form_rust_string(instruction[:inputs][0], instruction[:scope])
|
39
|
+
end
|
40
|
+
|
41
|
+
def handle_log_string
|
42
|
+
form_rust_string("log!(#{instruction[:inputs].join(',')})", instruction[:scope])
|
43
|
+
end
|
44
|
+
|
45
|
+
def handle_add_and_assign
|
46
|
+
form_rust_string("#{instruction[:inputs][0]} += #{instruction[:inputs][1]}", instruction[:scope])
|
33
47
|
end
|
34
48
|
end
|
35
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtr_to_rust
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Durst
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Rust to DTR translator (Digicus Textual Representation).
|
14
14
|
email:
|