gob-lang 1.5.6 → 1.5.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0663e72787082814a6b03e5a5c011d8692a7255794ce1d79b8f8143a54346a45
4
- data.tar.gz: b3d6a7ec818f5d376f3964a6409bf865277ebdff49ca40e836da1d95538f35f8
3
+ metadata.gz: 4cd6d81f3fb29faa854c61fbdf3c65dc4d831cc19326d8a5f9895ea1f71afe00
4
+ data.tar.gz: 403697e65db0a24072a5ba8af57ce079a4592bd7f00f6c1226101a7f5915264c
5
5
  SHA512:
6
- metadata.gz: 0c48413b4cd7a647dedfc88e9175b68ec6171556e1300666a768fd7194a20f6ace0d2ebb6ae4f0582ab7aabb811861c790e3ca94adf7e86e831966bd387b5693
7
- data.tar.gz: 87261d9c0baa4f9e7948b8748a4550d747cc52f06c9afa78147d99cbdc4bc57e0b9c18de1a0156d8a91990e0497826bd4b7d0fa77ad261f12ef679bf806d57ae
6
+ metadata.gz: b15913d1fcee07cae9741a70b46fb5922e33c77fd5d76565ce65f9d5623ff5a83f7de356e73372725dba3f0f62159d39be616e7694186510519ff799a1fd099d
7
+ data.tar.gz: 4968ae2587e03f2cbcd1e80adb87a2b970197bdab0d346efab3d285779c52ab72cff3e7c436c05744215991536c3e9a8fde0b21b7ddf4a9967abca4c4fd661a2
data/lib/gob/cli/base.rb CHANGED
@@ -38,21 +38,7 @@ module Gob
38
38
  matches
39
39
  end
40
40
 
41
- def validate_source!(source, path)
42
- offenses = Gob::Validation::Rules.validate(source, path: path)
43
- return if offenses.empty?
44
-
45
- Gob::CLI::Errors.render_offenses(offenses, path: path)
46
- exit 1
47
- end
48
-
49
41
  def transpile_source(source, path)
50
- Gob::Reporter.step("fmt #{path}")
51
- source = Gob::Validation::Rules.autocorrect(source, path: path)
52
-
53
- Gob::Reporter.step("vet #{path}")
54
- validate_source!(source, path)
55
-
56
42
  Gob::Reporter.step("transpile #{path}")
57
43
  go_source = Gob.transpile_to_go(source, path: path, check: false)
58
44
 
@@ -10,6 +10,17 @@ module Gob
10
10
  module Transpilation
11
11
  class Runner
12
12
  module DefinitionNodes
13
+ # A bracketed group, nesting recursively. A comma inside a group
14
+ # belongs to the type, so it is never an item separator.
15
+ GROUP = /(?<group>
16
+ \( (?: [^()\[\]{}] | \g<group> )* \)
17
+ | \[ (?: [^()\[\]{}] | \g<group> )* \]
18
+ | \{ (?: [^()\[\]{}] | \g<group> )* \}
19
+ )/x
20
+
21
+ # One item of a signature list: anything up to a top-level comma.
22
+ ITEM = /(?<item> (?: [^,()\[\]{}] | #{GROUP} )+ )/x
23
+
13
24
  def parse_signature_comment(text)
14
25
  body = text.to_s.strip.sub(/\A#\s*/, "")
15
26
  parts = body.split(/\s*->\s*/, 2)
@@ -17,16 +28,15 @@ module Gob
17
28
  right = parts[1].to_s.strip
18
29
 
19
30
  split_items = ->(v) {
20
- v = v.strip
21
- case v
22
- in /\A\((?<inner>.*)\)\z/m then v = $~[:inner].strip
23
- else nil
24
- end
25
-
26
- case v
27
- in /\A\s*\z/ then []
28
- else
29
- v.scan(/func\([^()]*\)(?:\s+[^,]+)?|\[[^\[\]]*\][^,]*|[^,]+/).map(&:strip).reject(&:empty?)
31
+ case v.strip
32
+ in /\A\s*\z/
33
+ []
34
+ in /\A\((?<inner>.*)\)\z/m
35
+ split_items.call($~[:inner])
36
+ in /\A#{ITEM}\s*,\s*(?<rest>.*)\z/m
37
+ [$~[:item].strip, *split_items.call($~[:rest])]
38
+ in /\A#{ITEM}\z/
39
+ [$~[:item].strip]
30
40
  end
31
41
  }
32
42
 
data/lib/gob/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gob
4
- VERSION = "1.5.6"
4
+ VERSION = "1.5.8"
5
5
  end
data/lib/gob.rb CHANGED
@@ -29,14 +29,14 @@ module Gob
29
29
  ____
30
30
 
31
31
  # Parse `source` and transpile it into a SyntaxTree::Go tree.
32
- def self.transpile(source, path: nil, check: true)
32
+ def self.transpile(source, path: nil, check: false)
33
33
  Validation::Rules.check!(source, path: path) if check
34
34
  Transpilation::Context.global_for(path) if path
35
35
  Transpilation::Runner.new.call(RubyParser.parse(source))
36
36
  end
37
37
 
38
38
  # Transpile `source` and emit it as Go source text.
39
- def self.transpile_to_go(source, path: nil, check: true)
39
+ def self.transpile_to_go(source, path: nil, check: false)
40
40
  Go::Printer.print(transpile(source, path: path, check: check))
41
41
  end
42
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gob-lang
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.6
4
+ version: 1.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Kidd