dtr_core 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2457b55c657b17f1c0f69183486c2dbb78ee0c7e68ed1572db089b10e285474b
4
- data.tar.gz: e5aafcd885e48bfff0773db4ac961a48970b3f98648b3220abd29e3d34cc614c
3
+ metadata.gz: b6eb9933172ea48536b0efceffe9e9e222a54e37f214b8041dc5edd40c01f2d6
4
+ data.tar.gz: 731d58a093c47bfd2b63f4ea884d4422d703b2c2ba47baacbda105bfb02e2264
5
5
  SHA512:
6
- metadata.gz: 1f7cd472023cbfe46625ba9afa0fc8d0146ccbd0b39af87bc4157ba7d58f37760f7b07c50f76e3d2be057d2cc4650312a8ef166d3e12d0a09e9e1f90395abb09
7
- data.tar.gz: bd868a7ad8c5526624b925f5f168d828b2bafc66cc62c7d226c4f7cd59c3ff2af04e008fb7d33ecc048f8c167d8c65307b7e4d2318c4cc1df90739a2cf37b223
6
+ metadata.gz: '04824f70c5646161afb24637f614f1ba2431414cc5f98b8847b15f74299ba563957586ba40a88d36847d1cfce649462199a42508a0d276397dbe3f38d1ee7e59'
7
+ data.tar.gz: 106a92f8de4ca9385d44f510dbb942b05d073bd2584d7dabbfe7d3003d348a121c21765da246e2c450a25df92cfb5151d1b541cf5b28029d96acd6ff1875c423
@@ -3,28 +3,29 @@
3
3
  module DTRCore
4
4
  # Represents a contract in a DTR file.
5
5
  class Contract
6
- attr_reader :helpers, :interface, :name, :state, :user_defined_types
6
+ attr_reader :helpers, :interface, :name, :state, :user_defined_types, :non_translatables
7
7
 
8
- def initialize(name, state, interface, user_defined_types, helpers)
8
+ def initialize(name, state, interface, user_defined_types, helpers, non_translatables)
9
9
  @name = name
10
10
  @state = state
11
11
  @interface = interface
12
12
  @user_defined_types = user_defined_types
13
13
  @helpers = helpers
14
+ @non_translatables = non_translatables
14
15
  end
15
16
 
16
17
  def self.from_dtr(filepath)
17
18
  parser = DTRCore::Parser.new(filepath)
18
19
 
19
20
  new(parser.name_section, parser.state_section, parser.interface_section, parser.user_defined_types_section,
20
- parser.helpers_section)
21
+ parser.helpers_section, parser.non_translatable_section)
21
22
  end
22
23
 
23
24
  def self.from_dtr_raw(content)
24
25
  parser = DTRCore::Parser.new('', content:)
25
26
 
26
27
  new(parser.name_section, parser.state_section, parser.interface_section, parser.user_defined_types_section,
27
- parser.helpers_section)
28
+ parser.helpers_section, parser.non_translatable_section)
28
29
  end
29
30
 
30
31
  def ==(other)
@@ -42,6 +43,7 @@ module DTRCore
42
43
  return_string += interface_to_s
43
44
  return_string += user_defined_types_to_s
44
45
  return_string += helpers_to_s
46
+ return_string += non_translatables_to_s
45
47
 
46
48
  return_string
47
49
  end
@@ -75,5 +77,11 @@ module DTRCore
75
77
 
76
78
  "[Helpers]:\n#{@helpers&.map(&:to_s)&.join("\n")}\n:[Helpers]\n"
77
79
  end
80
+
81
+ def non_translatables_to_s
82
+ return '' if @non_translatables.nil?
83
+
84
+ "[NonTranslatable]:\n#{@non_translatables}\n:[NonTranslatable]"
85
+ end
78
86
  end
79
87
  end
@@ -97,7 +97,7 @@ module DTRCore
97
97
  instruction = DTRCore::Instruction.new(
98
98
  instruction[/instruction:\s*(?<all>[^\s,]+)/, 1],
99
99
  parse_function_instruction_input(instruction),
100
- instruction[/\s*assign:\s*(?<all>[^\s\,]+)/, 1],
100
+ instruction[/\s*assign:\s*\[?(?<all>[^\s\,\]]+)\]?/, 1],
101
101
  instruction[/\s*scope:\s*(?<all>[^\s\,]+)/, 1].to_i || 0
102
102
  )
103
103
 
@@ -77,7 +77,7 @@ module DTRCore
77
77
  end
78
78
 
79
79
  def helpers_section
80
- return @function_definitions if @function_definitions
80
+ return @helpers_section if @helpers_section
81
81
 
82
82
  helpers_section = capture_section(/\[Helpers\]:(?<all>.*)\s*:\[Helpers\]/m)
83
83
 
@@ -91,5 +91,15 @@ module DTRCore
91
91
 
92
92
  @helpers_section ||= function_definitions
93
93
  end
94
+
95
+ def non_translatable_section
96
+ return @non_translatable_section if @non_translatable_section
97
+
98
+ non_translatable_section = capture_section(/\[NonTranslatable\]:(?<all>.*)\s*:\[NonTranslatable\]/m)
99
+
100
+ return nil if non_translatable_section.nil?
101
+
102
+ @non_translatable_section = non_translatable_section
103
+ end
94
104
  end
95
105
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtr_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
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-24 00:00:00.000000000 Z
11
+ date: 2024-07-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Core smart contract intermediate language (Digicus Textual Representation)
14
14
  parser.