starlark_compiler 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +1 -1
- data/lib/starlark_compiler/ast.rb +9 -0
- data/lib/starlark_compiler/version.rb +1 -1
- data/lib/starlark_compiler/writer.rb +13 -1
- 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: 5b74a86696f726f3151ccdd78309c4b1ebea7bf398cb9208798a52e673be4051
|
4
|
+
data.tar.gz: 365d6a79086a1dd56e173ab2f849f6ce35369a39c377fe135251efcd495a2433
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8c9cfde13ec42a01be510b584b63a8316b0cdeefbd9c6c507d6c25aa60915db40d03102ef4bde0d4dbb2d6333195adb943114d14d3707991781858d73ca1512
|
7
|
+
data.tar.gz: a2f8569be65150c0f0ee30ccc20a0ec8d6b4f1dd03b5879e9349d07ac25e6c424d3207d8c816befa387018325bfd9f4b45207aa548e31d65ba7ff2331a7b2a8a
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -67,6 +67,8 @@ module StarlarkCompiler
|
|
67
67
|
True.new
|
68
68
|
when FalseClass
|
69
69
|
False.new
|
70
|
+
when Numeric
|
71
|
+
Number.new(obj)
|
70
72
|
else
|
71
73
|
raise Error, "#{obj.inspect} not convertible to Node"
|
72
74
|
end
|
@@ -82,6 +84,13 @@ module StarlarkCompiler
|
|
82
84
|
class False < Node
|
83
85
|
end
|
84
86
|
|
87
|
+
class Number < Node
|
88
|
+
attr_reader :number
|
89
|
+
def initialize(number)
|
90
|
+
@number = number
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
85
94
|
class String < Node
|
86
95
|
attr_reader :str
|
87
96
|
def initialize(str)
|
@@ -48,6 +48,10 @@ module StarlarkCompiler
|
|
48
48
|
io << str.str.inspect
|
49
49
|
end
|
50
50
|
|
51
|
+
def write_number(number)
|
52
|
+
io << number.number.to_s
|
53
|
+
end
|
54
|
+
|
51
55
|
def delegate(template, obj)
|
52
56
|
snake_case = lambda do |str|
|
53
57
|
return str.downcase if str =~ /^[A-Z_]+$/
|
@@ -63,7 +67,7 @@ module StarlarkCompiler
|
|
63
67
|
|
64
68
|
cls = cls.superclass
|
65
69
|
end
|
66
|
-
raise
|
70
|
+
raise "No #{template} for #{obj.class}"
|
67
71
|
end
|
68
72
|
|
69
73
|
def write_function_call(call)
|
@@ -159,6 +163,14 @@ module StarlarkCompiler
|
|
159
163
|
str.str.size <= 50
|
160
164
|
end
|
161
165
|
|
166
|
+
def single_line_number?(_)
|
167
|
+
true
|
168
|
+
end
|
169
|
+
|
170
|
+
def single_line_binary_operator?(operator)
|
171
|
+
single_line?(operator.lhs) && single_line?(operator.rhs)
|
172
|
+
end
|
173
|
+
|
162
174
|
def single_line_function_call?(call)
|
163
175
|
if call.args.empty?
|
164
176
|
call.kwargs.size <= 1 &&
|
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.2.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: 2020-01-
|
11
|
+
date: 2020-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|