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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/instruction_handler.rb +21 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1806c512b3954d5b391267085acf5d29e286993840a6fd3f58191be6f9f5062d
4
- data.tar.gz: 0d19d719058f64916475ca8689b6103876f694d962e15b87ab96246472382d99
3
+ metadata.gz: 5e847ba23b85fbcb73f654a7204b136c7d22159da92f1c19834242382f0422e9
4
+ data.tar.gz: 02c903ad18bc3ee83024db1df4d838e36dcf58f8fef3e3cb50b1b912037f7da0
5
5
  SHA512:
6
- metadata.gz: 842cd6102fa86b8f66662ba8b799e8e195336fe4895653576c55a7fb14e21bed941eff1b467f16650db32ba9a2a27100b0b3920333770f4c9f8110c155e85800
7
- data.tar.gz: 7f41c7dcfce3f3077d2ada86d5b9b02a1cc0bf8a113803747d0d3a246d5e5d67354387db9cc272753657e155190cf616ac54ba7639337d4a1318d0881f545f54
6
+ metadata.gz: 15801ee722bdc1d23650c2c37535e7a836250ec313a97cadc7b2830679dbd093901ab46f2ad4e1fa995710294d8a985c173db0d9667b11129ec2fac1bb3c8c3a
7
+ data.tar.gz: 5f113fe380f4e21f260dd7bfdf6600e0354e0b24f8896cda19f22dcd38d9b173d8dc53eb55962a97ae89b21dc39a36f479c817ccf404164c6be111c7d4b88fae
@@ -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 handle_add_symbols
26
- " let #{instruction[:assign]} " \
27
- '= vec![&env, ' \
28
- "symbol_short!(#{instruction[:inputs][0]}), #{instruction[:inputs][1]}];"
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
- " #{instruction[:inputs][0]}"
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
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-01 00:00:00.000000000 Z
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: