gloss 0.1.2 → 0.1.7

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: 598f28c63b98dc26491f81b56112a067e53700f36136e9da1f2a4fbda60e14fc
4
- data.tar.gz: 0f39f4a5cd5202bdc280c81b0fac581d06bc9303e58df7ed39ffb993cdfe577f
3
+ metadata.gz: 0f65447f0ea2606334c6c17956f4c8ec7c8be413918fa4d2d423f973407a451b
4
+ data.tar.gz: bf09ca8cfc5f0b6d4f7f6c77d8e1cb93da94d1359452218fc514160cf54c571a
5
5
  SHA512:
6
- metadata.gz: 1d3687951054a991b8c13eae82be7d7ccdb1fd5c2a730ced1b7472a3aa1b59a4fca5471ecc0e2dca00b3abf337a3ebb79bc9e06c3677fc55d30c52f682b332b0
7
- data.tar.gz: 0b14828108ea3fa140a560a04313ff6c0321f1e968e168532ae9ab092e41291affe9f4feac1f4309d5be63fd6b0b0cb63e48bce1ea6b5652bb947b051913d07e
6
+ metadata.gz: 2d788c4b489e5e16e66e304d64f9c0830922d9ef861de818ac170e3c54d64b99e0d45cf6752beca1a392e88f15dc1d3627f02f66f79eb2437659807d1b5551d2
7
+ data.tar.gz: 9b285072b81d675ac0ca5485a732e7c46e83aca2b6bf09d288b58b7a6b9503e976711f0a2cb51d3d04edbf2c573d8625a0c8f9f35e4d158b11145a2d5919c3bd
@@ -0,0 +1,41 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+ env:
9
+ ImageOS: ubuntu18
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ container:
14
+ image: johansenja/gloss:latest
15
+ steps:
16
+ - name: Checkout
17
+ uses: actions/checkout@v2
18
+ - uses: actions/cache@v2
19
+ id: gems-cache
20
+ with:
21
+ path: vendor/bundle
22
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
23
+ restore-keys: |
24
+ ${{ runner.os }}-gems-
25
+ - name: install Bundler
26
+ run: gem install bundler:2.2.3
27
+ - name: install gems
28
+ run: bundle install --jobs 4 --retry 3
29
+ - name: Compile extension
30
+ run: make
31
+ working-directory: ext/gloss
32
+ - name: Run tests
33
+ run: rake
34
+ - name: Install dependencies
35
+ run: shards install
36
+ working-directory: ext/gloss
37
+ - name: Run tests
38
+ run: crystal spec
39
+ working-directory: ext/gloss
40
+ - name: Build self with current state
41
+ run: exe/gloss build
data/.gloss.yml CHANGED
@@ -2,3 +2,4 @@
2
2
  frozen_string_literals: true
3
3
  src_dir: src
4
4
  entrypoint: src/exe/gloss
5
+ type_checking_strictness: lenient
data/Gemfile.lock CHANGED
@@ -1,22 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gloss (0.1.2)
4
+ gloss (0.1.7)
5
5
  fast_blank
6
6
  listen
7
- rbs
8
- steep
7
+ rbs (= 1.0.4)
8
+ steep (= 0.41.0)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activesupport (6.1.1)
13
+ activesupport (6.1.3.1)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
15
  i18n (>= 1.6, < 2)
16
16
  minitest (>= 5.1)
17
17
  tzinfo (~> 2.0)
18
18
  zeitwerk (~> 2.3)
19
- ast (2.4.1)
19
+ ast (2.4.2)
20
20
  ast_utils (0.4.0)
21
21
  parser (>= 2.7.0)
22
22
  byebug (11.1.3)
@@ -24,15 +24,15 @@ GEM
24
24
  concurrent-ruby (1.1.8)
25
25
  diff-lcs (1.4.4)
26
26
  fast_blank (1.0.0)
27
- ffi (1.14.2)
28
- i18n (1.8.8)
27
+ ffi (1.15.0)
28
+ i18n (1.8.10)
29
29
  concurrent-ruby (~> 1.0)
30
- language_server-protocol (3.15.0.1)
31
- listen (3.4.1)
30
+ language_server-protocol (3.15.0.2)
31
+ listen (3.5.1)
32
32
  rb-fsevent (~> 0.10, >= 0.10.3)
33
33
  rb-inotify (~> 0.9, >= 0.9.10)
34
34
  method_source (1.0.0)
35
- minitest (5.14.3)
35
+ minitest (5.14.4)
36
36
  parallel (1.20.1)
37
37
  parser (2.7.2.0)
38
38
  ast (~> 2.4.1)
@@ -77,6 +77,7 @@ GEM
77
77
  rubocop-ast (1.4.0)
78
78
  parser (>= 2.7.1.5)
79
79
  ruby-progressbar (1.11.0)
80
+ rufo (0.12.0)
80
81
  steep (0.41.0)
81
82
  activesupport (>= 5.1)
82
83
  ast_utils (>= 0.4.0)
@@ -99,6 +100,7 @@ DEPENDENCIES
99
100
  rake-compiler
100
101
  rspec
101
102
  rubocop
103
+ rufo
102
104
 
103
105
  BUNDLED WITH
104
106
  2.2.3
data/README.md CHANGED
@@ -1,12 +1,10 @@
1
- # Gloss
1
+ # ![Gloss](./logo.svg "Gloss")
2
2
  [![Gem Version](https://badge.fury.io/rb/gloss.svg)](https://rubygems.org/gems/gloss)
3
- [![Ruby Specs](https://github.com/johansenja/gloss/workflows/Ruby%20Specs/badge.svg)](https://github.com/johansenja/gloss/actions?query=workflow%3A%22Ruby+Specs%22)
4
- [![Crystal Specs](https://github.com/johansenja/gloss/workflows/Crystal%20Specs/badge.svg)](https://github.com/johansenja/gloss/actions?query=workflow%3A%22Crystal+Specs%22)
5
- [![Total Downloads](http://ruby-gem-downloads-badge.herokuapp.com/gloss?type=total&color=green&metric=true&label=downloads%20(total)&total_label=)](https://rubygems.org/gems/gloss)
3
+ [![Tests](https://github.com/johansenja/gloss/workflows/Tests/badge.svg)](https://github.com/johansenja/gloss/actions?query=workflow%3ATests)
4
+ [![Total Downloads](http://ruby-gem-downloads-badge.herokuapp.com/gloss?type=total&color=green&label=downloads%20(total)&total_label=)](https://rubygems.org/gems/gloss)
6
5
  [![Current Version](http://ruby-gem-downloads-badge.herokuapp.com/gloss?color=green&label=downloads%20(current%20version)&metric=true)](https://rubygems.org/gems/gloss)
7
6
 
8
- [Gloss](https://en.wikipedia.org/wiki/Gloss_(annotation)) is a high-level programming language based on [Ruby](https://github.com/ruby/ruby) and [Crystal](https://github.com/crystal-lang/crystal), which compiles to ruby; its aims are on transparency,
9
- efficiency, and to enhance ruby's goal of developer happiness and productivity.
7
+ [Gloss](https://en.wikipedia.org/wiki/Gloss_(annotation)) is a language project inspired by [Crystal](https://github.com/crystal-lang/crystal), Ruby's [RBS](https://github.com/ruby/rbs), [Steep](https://github.com/soutaro/steep) and [TypeScript](https://github.com/microsoft/TypeScript). It compiles to pure Ruby.
10
8
 
11
9
  ### Current features
12
10
 
@@ -21,23 +19,6 @@ efficiency, and to enhance ruby's goal of developer happiness and productivity.
21
19
 
22
20
  This project is at a stage where the core non-crystal parts are written in Gloss and compile to ruby (essentially self-hosting), albeit with the type checking being fairly loose. However the project is still in the very early stages; with (as of yet) no Linux support nor error handling (see roadmap below). Use at your own discretion!
23
21
 
24
- ### Approx. roadmap:
25
-
26
- - Improve error handling and logging (currently almost non-existant)
27
- - Address Linux compatibility (currently more or less non-existant)
28
- - Implement different strictnesses of type checking
29
- - Metaprogramming helpers/safety:*
30
- - Abstract classes and methods
31
- - Method lookup/existence checking at compile time
32
- - Method overloading
33
-
34
- #### Related items:
35
-
36
- - Rails helpers; probably some time away*
37
- - Editor plugins/syntax highlighting/langserver; probably some time away*
38
-
39
- *__Dependent on popularity__
40
-
41
22
  ## Examples:
42
23
 
43
24
  #### Type checking:
@@ -136,7 +117,7 @@ class Language
136
117
  TS = "TypeScript"
137
118
  P = "Python"
138
119
  end
139
-
120
+
140
121
  def favourite_language(language : Lang)
141
122
  puts "my favourite language is #{language}"
142
123
  end
@@ -212,7 +193,7 @@ end
212
193
  ```crystal
213
194
  abstract class BaseClass
214
195
  attr_reader :var
215
-
196
+
216
197
  def initialize(@var); end
217
198
  end
218
199
 
@@ -226,7 +207,14 @@ BaseClass.new(123) # Error - can't instantiate abstract class
226
207
  Child.new(123).what_is_var # Ok - "var is 123"
227
208
  ```
228
209
 
229
- ## Usage:
210
+ ## Getting started:
211
+
212
+ **Note: This gem currently requires Crystal to be installed. If you don't wish to install it, or run into other installation problems, consider using the Docker image:**
213
+
214
+ ```dockerfile
215
+ FROM johansenja/gloss:latest
216
+ # ...
217
+ ```
230
218
 
231
219
  ```ruby
232
220
  # Gemfile
@@ -249,8 +237,18 @@ then
249
237
 
250
238
  then
251
239
 
240
+ `vi .gloss.yml # set entrypoint to src/hello_world.gl`
241
+
242
+ then
243
+
252
244
  `gloss build`
253
245
 
254
246
  then
255
247
 
256
248
  `ruby ./hello_world.rb`
249
+
250
+ ## Example Projects:
251
+
252
+ - This one! Gloss is mostly self-hosting, so check out the `./src` and `./.gloss.yml`, or the generated output in `./lib`
253
+ - [onefiveone](https://github.com/johansenja/onefiveone) - A Roman Numeral CLI. Read the accompanying article [here](https://johansenja.medium.com/ruby-crystal-pt-ii-a-simple-app-using-gloss-368ff849db67)
254
+ - More to come (including web apps)! Also check out `Used by` section in the sidebar
data/Rakefile CHANGED
@@ -17,8 +17,10 @@ RSpec::Core::RakeTask.new :spec do |spec|
17
17
  spec.pattern = 'spec/**/*_spec.rb'
18
18
  end
19
19
 
20
- task :build do
20
+ task :build_gem do
21
21
  sh "cd", "ext/gloss", "&&", "make", "all", "&&", "cd", "-"
22
22
  end
23
23
 
24
- task :default => [:spec]
24
+ task build: [:build_gem]
25
+
26
+ task default: [:spec]
data/ext/gloss/Makefile CHANGED
@@ -3,16 +3,8 @@ PLATFORM = $(shell uname -s)
3
3
 
4
4
  ifeq "$(PLATFORM)" "Darwin"
5
5
  TARGET = ../../lib/gls.bundle
6
-
7
- clean:
8
- rm -f $(TARGET) $(TARGET).dwarf
9
- endif
10
-
11
- ifeq "$(PLATFORM)" "Linux"
6
+ else
12
7
  TARGET = ../../lib/gls.so
13
-
14
- clean:
15
- rm -f $(TARGET)
16
8
  endif
17
9
 
18
10
  install: all
@@ -23,4 +15,8 @@ shards:
23
15
  shards
24
16
 
25
17
  build: ./src/gloss.cr
26
- $(CRYSTAL) build --link-flags "-shared -dynamic -Wl,-undefined,dynamic_lookup" $< -o $(TARGET) --release
18
+ $(CRYSTAL) build --link-flags "-shared -Wl,-undefined,dynamic_lookup" $< -o $(TARGET) --release
19
+
20
+ clean:
21
+ rm -f $(TARGET)
22
+ rm -f $(TARGET).dwarf
@@ -1,8 +1,6 @@
1
1
  lib CrRuby
2
2
  # every ruby Object is a VALUE
3
3
  type VALUE = Void*
4
- # ruby method typing
5
- type METHOD_FUNC = VALUE, VALUE -> VALUE
6
4
 
7
5
  # a ruby Class is a VALUE
8
6
  $rb_cObject : VALUE
@@ -28,8 +26,11 @@ lib CrRuby
28
26
  fun rb_define_module(name: UInt8*) : VALUE
29
27
 
30
28
  # define ruby method in C
31
- fun rb_define_method(klass: VALUE, name: UInt8*, func: METHOD_FUNC, argc: Int32)
29
+ fun rb_define_method(klass: VALUE, name: UInt8*, func: Proc(CrRuby::VALUE, CrRuby::VALUE,
30
+ CrRuby::VALUE), argc: Int32)
32
31
 
33
32
  # define singleton ruby method in C
34
- fun rb_define_singleton_method(klass: VALUE, name: UInt8*, func: METHOD_FUNC, argc: Int32)
33
+ fun rb_define_singleton_method(klass: VALUE, name: UInt8*, func: Proc(CrRuby::VALUE,
34
+ CrRuby::VALUE,
35
+ CrRuby::VALUE), argc: Int32)
35
36
  end
@@ -21,5 +21,10 @@ fun init = Init_gls
21
21
  GC.init
22
22
  LibCrystalMain.__crystal_main(0, Pointer(Pointer(UInt8)).null)
23
23
  gloss = CrRuby.rb_define_module("Gloss");
24
- CrRuby.rb_define_singleton_method(gloss, "parse_buffer", ->parse_string(CrRuby::VALUE, CrRuby::VALUE), 1);
24
+ CrRuby.rb_define_singleton_method(
25
+ gloss,
26
+ "parse_buffer",
27
+ ->parse_string(CrRuby::VALUE, CrRuby::VALUE),
28
+ 1
29
+ );
25
30
  end
data/gloss.gemspec CHANGED
@@ -17,11 +17,12 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.add_runtime_dependency "fast_blank"
19
19
  s.add_runtime_dependency "listen"
20
- s.add_runtime_dependency "rbs"
21
- s.add_runtime_dependency "steep"
20
+ s.add_runtime_dependency "rbs", "1.0.4"
21
+ s.add_runtime_dependency "steep", "0.41.0"
22
22
 
23
+ s.add_development_dependency "pry-byebug"
23
24
  s.add_development_dependency "rake-compiler"
24
25
  s.add_development_dependency "rspec"
25
- s.add_development_dependency "pry-byebug"
26
26
  s.add_development_dependency "rubocop"
27
+ s.add_development_dependency "rufo"
27
28
  end
data/lib/gloss.rb CHANGED
@@ -1,7 +1,6 @@
1
- # frozen_string_literal: true
2
-
1
+
3
2
  ##### This file was generated by Gloss; any changes made here will be overwritten.
4
- ##### See src/ to make changes
3
+ ##### See / to make changes
5
4
 
6
5
  require "rbs"
7
6
  require "json"
@@ -22,11 +21,8 @@ require "gloss/errors"
22
21
  require "gloss/logger"
23
22
  require "gloss/prog_loader"
24
23
  require "gloss/utils"
25
- is_ci = ENV.fetch("CI") { ||
26
- false}
27
- unless is_ci
28
- require "gls"
29
- end
24
+ require "gloss/runtime"
25
+ require "gls"
30
26
  EMPTY_ARRAY = Array.new
31
27
  .freeze
32
28
  EMPTY_HASH = {}.freeze
data/lib/gloss/cli.rb CHANGED
@@ -1,7 +1,6 @@
1
- # frozen_string_literal: true
2
-
1
+
3
2
  ##### This file was generated by Gloss; any changes made here will be overwritten.
4
- ##### See src/ to make changes
3
+ ##### See / to make changes
5
4
 
6
5
  require "optparse"
7
6
  module Gloss
@@ -27,7 +26,9 @@ case command
27
26
  when "version", "--version", "-v"
28
27
  puts(Gloss::VERSION)
29
28
  when "watch", "build"
30
- type_checker = ProgLoader.new
29
+ Gloss.load_config
30
+ type_checker = TypeChecker.new(Config.src_dir)
31
+ type_checker = ProgLoader.new(type_checker)
31
32
  .run
32
33
  (if command.==("watch")
33
34
  files = files.map() { |f|
data/lib/gloss/config.rb CHANGED
@@ -1,7 +1,6 @@
1
- # frozen_string_literal: true
2
-
1
+
3
2
  ##### This file was generated by Gloss; any changes made here will be overwritten.
4
- ##### See src/ to make changes
3
+ ##### See / to make changes
5
4
 
6
5
  require "ostruct"
7
6
  require "yaml"
@@ -10,14 +9,18 @@ module Gloss
10
9
  Config = OpenStruct.new(default_config: {:frozen_string_literals => true,
11
10
  :src_dir => "src",
12
11
  :entrypoint => nil,
13
- :strict_require => false}.freeze)
14
- user_config = (if File.exist?(CONFIG_PATH)
15
- YAML.safe_load(File.read(CONFIG_PATH))
16
- else
12
+ :strict_require => false,
13
+ :type_checking_strictness => "lenient",
14
+ :prettify_output_executable_path => nil}.freeze)
15
+ def self.load_config()
16
+ user_config = (if File.exist?(File.absolute_path(File.join(Dir.pwd, CONFIG_PATH)))
17
+ YAML.safe_load(File.read(CONFIG_PATH))
18
+ else
19
+ Config.default_config
20
+ end)
17
21
  Config.default_config
18
- end)
19
- Config.default_config
20
22
  .each() { |k, v|
21
- Config.send(:"#{k}=", user_config.[](k.to_s) || v)
22
- }
23
+ Config.send(:"#{k}=", user_config.[](k.to_s) || v)
24
+ }
25
+ end
23
26
  end
data/lib/gloss/errors.rb CHANGED
@@ -1,7 +1,6 @@
1
- # frozen_string_literal: true
2
-
1
+
3
2
  ##### This file was generated by Gloss; any changes made here will be overwritten.
4
- ##### See src/ to make changes
3
+ ##### See / to make changes
5
4
 
6
5
  module Gloss
7
6
  module Errors
@@ -1,7 +1,6 @@
1
- # frozen_string_literal: true
2
-
1
+
3
2
  ##### This file was generated by Gloss; any changes made here will be overwritten.
4
- ##### See src/ to make changes
3
+ ##### See / to make changes
5
4
 
6
5
  require "yaml"
7
6
  module Gloss
data/lib/gloss/logger.rb CHANGED
@@ -1,7 +1,6 @@
1
- # frozen_string_literal: true
2
-
1
+
3
2
  ##### This file was generated by Gloss; any changes made here will be overwritten.
4
- ##### See src/ to make changes
3
+ ##### See / to make changes
5
4
 
6
5
  module Gloss
7
6
  def self.logger()
@@ -24,6 +23,11 @@ nil => nil,
24
23
  else
25
24
  IO::NULL
26
25
  end))
26
+ .tap() { |l|
27
+ (if real_log_level
28
+ l.level=(real_log_level)
29
+ end)
30
+ }
27
31
  end)
28
32
  end
29
33
  end
data/lib/gloss/parser.rb CHANGED
@@ -1,7 +1,6 @@
1
- # frozen_string_literal: true
2
-
1
+
3
2
  ##### This file was generated by Gloss; any changes made here will be overwritten.
4
- ##### See src/ to make changes
3
+ ##### See / to make changes
5
4
 
6
5
  module Gloss
7
6
  class Parser