starlark_compiler 0.4.0 → 0.5.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: f9056c314125d14aa7ee9af25d658629397f42ab961917622c6204f196df7fe3
4
- data.tar.gz: 57bef8b8f602d04a8fdc86437fff2020cd473be044098bb8e6e9822c9045a08b
3
+ metadata.gz: b487b7ec8f95d4d08b340c2e6872d38606a3cda406c44189e04cfcc55829ae7b
4
+ data.tar.gz: ebf0df91ab7dffdab555150b9f0e6ecb44b6faea915fb55bd052bd482da4e0be
5
5
  SHA512:
6
- metadata.gz: 85ba7945d934680f16e4d9613fee54f71b763837545914105908c0acb350a6bd7e27e588766adc8563e18cd75c97e894ad03325102c1778a62d0af389d201a3b
7
- data.tar.gz: bb63ffc5a3882822e71a44b28379de380e7266d49f552c3d88d8fd7389616a910710bf083da9b37c94da2eb679ae9ca562df49fe083d281952a4b6bc2f440b06
6
+ metadata.gz: 8db37b777d13cbf3b29ecd9e138d6dc80240f2338226b9b57a29d4abae31f420935b25ed151ec14d975e724103e547b29d8d8cc3ebd965dbcfc62d11e6b23d00
7
+ data.tar.gz: '0040583536df2b938c70f3c2ce39f3230be444adfa6bd9c365b9ae42808ee2db1dbc895bc66a8b2d000e9eee0d5d6879cb08a3354ee8be1b32d227b0bc106d49'
@@ -12,9 +12,9 @@ jobs:
12
12
  runs-on: ubuntu-latest
13
13
  steps:
14
14
  - uses: actions/checkout@v1
15
- - uses: actions/setup-ruby@v1
15
+ - uses: ruby/setup-ruby@v1
16
16
  with:
17
- ruby-version: "2.x" # Version range or exact version of a Ruby version to use, using semvers version range syntax.
17
+ ruby-version: "2.6" # Version range or exact version of a Ruby version to use, using semvers version range syntax.
18
18
  - name: Install Gems
19
19
  run: bundle install
20
20
  - name: Build and Test
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.5.0
2
+
3
+ * Update gemspec for compatibility with Ruby 3.x
4
+
1
5
  0.4.0
2
6
 
3
7
  * Add variable assignment and reference ability
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- starlark_compiler (0.4.0)
4
+ starlark_compiler (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -143,6 +143,16 @@ module StarlarkCompiler
143
143
  end
144
144
  end
145
145
 
146
+ class FunctionDeclaration < Node
147
+ attr_reader :name, :args, :body, :kwargs
148
+ def initialize(name, args, body, **kwargs)
149
+ @name = name
150
+ @args = args.map(&method(:node))
151
+ @body = body.map(&method(:node))
152
+ @kwargs = kwargs.transform_values(&method(:node))
153
+ end
154
+ end
155
+
146
156
  class MethodCall < Node
147
157
  end
148
158
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StarlarkCompiler
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -97,6 +97,27 @@ module StarlarkCompiler
97
97
  io << ')'
98
98
  end
99
99
 
100
+ def write_function_declaration(declaration)
101
+ io << 'def ' << declaration.name << '('
102
+ final_index = declaration.args.size.pred
103
+ declaration.args.each_with_index do |arg, idx|
104
+ indented(single_line: false) do |indenter|
105
+ indenter.write_newline
106
+ write_node(arg)
107
+ indenter.write_comma unless final_index == idx
108
+ end
109
+ end
110
+ write_newline
111
+ io << '):'
112
+ final_index = declaration.body.size.pred
113
+ declaration.body.each do |arg|
114
+ indented(single_line: false) do |indenter|
115
+ indenter.write_newline
116
+ write_node(arg)
117
+ end
118
+ end
119
+ end
120
+
100
121
  def write_variable_reference(variable)
101
122
  io << variable.var
102
123
  end
@@ -212,5 +233,9 @@ module StarlarkCompiler
212
233
  dictionary.elements.size <= 1 &&
213
234
  dictionary.elements.each_key.all?(&method(:single_line?))
214
235
  end
236
+
237
+ def single_line_variable_reference?(_)
238
+ true
239
+ end
215
240
  end
216
241
  end
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ['lib']
27
27
 
28
- spec.required_ruby_version = '~> 2.6'
28
+ spec.required_ruby_version = '>= 2.6'
29
29
 
30
30
  spec.add_development_dependency 'bundler', '~> 2.0'
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starlark_compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Giddins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-22 00:00:00.000000000 Z
11
+ date: 2023-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -63,7 +63,7 @@ require_paths:
63
63
  - lib
64
64
  required_ruby_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.6'
69
69
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubygems_version: 3.0.1
75
+ rubygems_version: 3.4.1
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: A starlark gem