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 +4 -4
- data/.github/workflows/tests.yml +2 -2
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/starlark_compiler/ast.rb +10 -0
- data/lib/starlark_compiler/version.rb +1 -1
- data/lib/starlark_compiler/writer.rb +25 -0
- data/starlark_compiler.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b487b7ec8f95d4d08b340c2e6872d38606a3cda406c44189e04cfcc55829ae7b
|
4
|
+
data.tar.gz: ebf0df91ab7dffdab555150b9f0e6ecb44b6faea915fb55bd052bd482da4e0be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8db37b777d13cbf3b29ecd9e138d6dc80240f2338226b9b57a29d4abae31f420935b25ed151ec14d975e724103e547b29d8d8cc3ebd965dbcfc62d11e6b23d00
|
7
|
+
data.tar.gz: '0040583536df2b938c70f3c2ce39f3230be444adfa6bd9c365b9ae42808ee2db1dbc895bc66a8b2d000e9eee0d5d6879cb08a3354ee8be1b32d227b0bc106d49'
|
data/.github/workflows/tests.yml
CHANGED
@@ -12,9 +12,9 @@ jobs:
|
|
12
12
|
runs-on: ubuntu-latest
|
13
13
|
steps:
|
14
14
|
- uses: actions/checkout@v1
|
15
|
-
- uses:
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
16
|
with:
|
17
|
-
ruby-version: "2.
|
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
data/Gemfile.lock
CHANGED
@@ -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
|
|
@@ -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
|
data/starlark_compiler.gemspec
CHANGED
@@ -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 = '
|
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
|
+
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:
|
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.
|
75
|
+
rubygems_version: 3.4.1
|
76
76
|
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: A starlark gem
|