turborails 0.1.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: beee31f2c93a71d5e8b5dda3520a03b9559d4339
4
+ data.tar.gz: 71de6ef1fee01fe95573937f49b2f78dc5dd9e67
5
+ SHA512:
6
+ metadata.gz: 2e597eb7bf723fbfbaf29d2d9170d0af01f518026b47e73dd721ec37c4b7c71a6f3070eab14b421cf8f7de4daee3071687898105e247d2e94f1f34de4d5107f5
7
+ data.tar.gz: 927f6e302c846e3e8d31ae9bdb4427927579f1c3161ecaa246407d99bbf40d103cb36a5009062d90db11f600a7a4ade91d8af0028f6fcf781cb85de376fd682a
@@ -0,0 +1,2 @@
1
+ target
2
+ Cargo.lock
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ -c
@@ -0,0 +1,4 @@
1
+ [package]
2
+ name = "turboruby"
3
+ version = "0.1.0"
4
+ authors = ["Yehuda Katz <wycats@gmail.com>"]
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in turboruby.gemspec
4
+ gemspec
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ turboruby (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.2.5)
10
+ rake (10.4.2)
11
+ rspec (3.3.0)
12
+ rspec-core (~> 3.3.0)
13
+ rspec-expectations (~> 3.3.0)
14
+ rspec-mocks (~> 3.3.0)
15
+ rspec-core (3.3.2)
16
+ rspec-support (~> 3.3.0)
17
+ rspec-expectations (3.3.1)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.3.0)
20
+ rspec-mocks (3.3.2)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.3.0)
23
+ rspec-support (3.3.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.10)
30
+ rake (~> 10.0)
31
+ rspec
32
+ turboruby!
33
+
34
+ BUNDLED WITH
35
+ 1.10.6
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Yehuda Katz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # Turboruby
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/turboruby`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'turboruby'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install turboruby
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/turboruby.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "turboruby"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,243 @@
1
+ require "strscan"
2
+
3
+ module TurboRuby
4
+ def self.compile(input_folder:, output_folder:)
5
+ end
6
+
7
+ module Syntax
8
+ class Class < Struct.new(:name)
9
+ attr_reader :methods
10
+
11
+ def initialize(*)
12
+ super
13
+ @methods = []
14
+ end
15
+ end
16
+
17
+ class Method < Struct.new(:name, :return_type)
18
+ attr_reader :body, :arguments
19
+
20
+ def initialize(*)
21
+ super
22
+ @body = []
23
+ @arguments = []
24
+ end
25
+
26
+ def add_argument(arg)
27
+ @arguments << arg
28
+ end
29
+ end
30
+
31
+ Argument = Struct.new(:name, :type)
32
+ end
33
+
34
+ class Parser
35
+ attr_reader :ast
36
+
37
+ def initialize
38
+ @ast = []
39
+ end
40
+
41
+ def parse(source)
42
+ @scanner = StringScanner.new(source)
43
+ @stack = []
44
+ @state = :program
45
+ @indentation_pattern = nil
46
+
47
+ until @scanner.eos?
48
+ #puts "Processing #{@state} for #{peek_token.inspect}"
49
+ send @state
50
+ end
51
+
52
+ finalize
53
+ @ast
54
+ ensure
55
+ @scanner = nil
56
+ @stack = nil
57
+ @state = nil
58
+ @indentation_pattern = nil
59
+ end
60
+
61
+ private
62
+ def program
63
+ consume_whitespace
64
+
65
+ unless @scanner.eos?
66
+ case consume_token!(/class/)
67
+ when 'class'
68
+ consume_whitespace!
69
+ @state = :class_def
70
+ end
71
+ end
72
+ end
73
+
74
+ def class_def
75
+ class_name = consume_token!(/[A-Z]\S+/)
76
+ consume_whitespace!
77
+
78
+ @stack.push Syntax::Class.new(class_name)
79
+ @state = :class_body
80
+ end
81
+
82
+ def class_body
83
+ case consume_token!(/def|end/)
84
+ when 'def'
85
+ consume_whitespace!
86
+ @state = :method_def
87
+ when 'end'
88
+ @ast << @stack.pop
89
+ @state = :program
90
+ end
91
+ end
92
+
93
+ def method_def
94
+ method_name = consume_token!
95
+
96
+ @stack.push Syntax::Method.new(method_name)
97
+
98
+ consume_whitespace(newlines: false)
99
+
100
+ if consume_token(/\(/)
101
+ consume_whitespace
102
+ @state = :method_arguments_list_begin
103
+ else
104
+ @state = :method_arguments_list_end
105
+ end
106
+ end
107
+
108
+ def method_arguments_list_begin
109
+ if consume_token(/\)/)
110
+ consume_whitespace(newlines: false)
111
+ @state = :method_arguments_list_end
112
+ else
113
+ @state = :method_argument_begin
114
+ end
115
+ end
116
+
117
+ def method_argument_begin
118
+ argument_name = consume_token!
119
+
120
+ @stack.push Syntax::Argument.new(argument_name)
121
+
122
+ consume_whitespace(newlines: false)
123
+
124
+ if consume_token(/->/)
125
+ consume_whitespace
126
+ @state = :method_argument_type
127
+ else
128
+ @state = :method_argument_end
129
+ end
130
+ end
131
+
132
+ def method_argument_type
133
+ argument_type = consume_token!
134
+
135
+ @stack.last.type = argument_type
136
+
137
+ consume_whitespace
138
+ @state = :method_argument_end
139
+ end
140
+
141
+ def method_argument_end
142
+ argument = @stack.pop
143
+ method = @stack.last
144
+
145
+ method.add_argument(argument)
146
+
147
+ case consume_token!(/,|\)/)
148
+ when ','
149
+ consume_whitespace
150
+ @state = :method_argument_begin
151
+ when ')'
152
+ consume_whitespace(newlines: false)
153
+ @state = :method_arguments_list_end
154
+ end
155
+ end
156
+
157
+ def method_arguments_list_end
158
+ if consume_token(/->/)
159
+ consume_whitespace
160
+ @state = :method_return_type
161
+ else
162
+ @state = :method_signature_end
163
+ end
164
+ end
165
+
166
+ def method_return_type
167
+ return_type = consume_token!
168
+
169
+ @stack.last.return_type = return_type
170
+
171
+ consume_whitespace(newlines: false)
172
+ @state = :method_signature_end
173
+ end
174
+
175
+ def method_signature_end
176
+ consume_token!(/\n/)
177
+ @state = :method_body_begin
178
+ end
179
+
180
+ def method_body_begin
181
+ @indentation_pattern = /^#{ Regexp.escape(peek_token!(/\s+/)) }/
182
+ @state = :method_body
183
+ end
184
+
185
+ def method_body
186
+ if consume_token(/\s*?\n/)
187
+ @state = :method_body
188
+ elsif peek_token(@indentation_pattern)
189
+ @stack.last.body << consume_token(/.*?\n/)
190
+ @state = :method_body
191
+ else
192
+ consume_whitespace(newlines: false)
193
+ @state = :method_body_end
194
+ end
195
+ end
196
+
197
+ def method_body_end
198
+ consume_token!(/end/)
199
+
200
+ method = @stack.pop
201
+ klass = @stack.last
202
+
203
+ klass.methods << method
204
+
205
+ consume_whitespace!
206
+ @state = :class_body
207
+ end
208
+
209
+ def finalize
210
+ raise "Unexpected EOF" unless @state == :program
211
+ end
212
+
213
+ def peek_token(pattern = /\S+/)
214
+ @scanner.check(pattern)
215
+ end
216
+
217
+ def peek_token!(*args)
218
+ peek_token(*args).tap do |token|
219
+ raise "Expected to find #{pattern.inspect}" if token.nil?
220
+ end
221
+ end
222
+
223
+ def consume_token(pattern = /\S+/)
224
+ @scanner.scan(pattern)
225
+ end
226
+
227
+ def consume_token!(*args)
228
+ consume_token(*args).tap do |token|
229
+ raise "Expected to find #{args.inspect} at #{peek_token.inspect} (state: #{@state})" if token.nil?
230
+ end
231
+ end
232
+
233
+ def consume_whitespace(newlines: true)
234
+ consume_token( newlines ? /\s*/ : /[\s&&[^\n]]*/ )
235
+ end
236
+
237
+ def consume_whitespace!(*args)
238
+ consume_whitespace(*args).tap do |token|
239
+ raise "Expected to find at least one whitespace character" if token.nil?
240
+ end
241
+ end
242
+ end
243
+ end
@@ -0,0 +1,3 @@
1
+ module TurboRuby
2
+ VERSION = "0.1.0.alpha.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ require "turbo_ruby/version"
2
+
3
+ module TurboRuby
4
+ # Your code goes here...
5
+ end
6
+
7
+ require "turbo_ruby/parser"
@@ -0,0 +1,3 @@
1
+ #[test]
2
+ fn it_works() {
3
+ }
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'turbo_ruby/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "turborails"
8
+ spec.version = TurboRuby::VERSION
9
+ spec.authors = ["Yehuda Katz"]
10
+ spec.email = ["wycats@gmail.com"]
11
+
12
+ spec.summary = %q{TurboRuby}
13
+ spec.description = %q{TurboRuby}
14
+ #spec.homepage = "None yet"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: turborails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.alpha.1
5
+ platform: ruby
6
+ authors:
7
+ - Yehuda Katz
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: TurboRuby
56
+ email:
57
+ - wycats@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - Cargo.toml
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/turbo_ruby/parser.rb
73
+ - lib/turbo_ruby/version.rb
74
+ - lib/turboruby.rb
75
+ - src/lib.rs
76
+ - turboruby.gemspec
77
+ homepage:
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">"
93
+ - !ruby/object:Gem::Version
94
+ version: 1.3.1
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.4.5
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: TurboRuby
101
+ test_files: []