riml 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/riml +3 -2
- data/lib/compiler.rb +17 -5
- data/lib/constants.rb +4 -0
- data/lib/grammar.y +157 -148
- data/lib/include_cache.rb +46 -0
- data/lib/lexer.rb +41 -28
- data/lib/nodes.rb +46 -9
- data/lib/parser.rb +149 -140
- data/lib/riml.rb +24 -15
- data/version.rb +2 -2
- metadata +54 -3
- data/Gemfile.lock +0 -15
data/lib/riml.rb
CHANGED
@@ -7,7 +7,7 @@ require 'lexer'
|
|
7
7
|
require 'parser'
|
8
8
|
require 'compiler'
|
9
9
|
require 'warning_buffer'
|
10
|
-
require '
|
10
|
+
require 'include_cache'
|
11
11
|
|
12
12
|
module Riml
|
13
13
|
|
@@ -76,6 +76,7 @@ module Riml
|
|
76
76
|
# expects `filenames` (String) arguments, to be readable files.
|
77
77
|
# Optional options (Hash) as last argument.
|
78
78
|
def self.compile_files(*filenames)
|
79
|
+
filenames = filenames.dup
|
79
80
|
parser, compiler = Parser.new, Compiler.new
|
80
81
|
|
81
82
|
if filenames.last.is_a?(Hash)
|
@@ -84,22 +85,24 @@ module Riml
|
|
84
85
|
compiler.options = DEFAULT_COMPILE_FILES_OPTIONS.dup
|
85
86
|
end
|
86
87
|
|
88
|
+
filenames.uniq!
|
89
|
+
# compile files using one thread per file, max 4 threads at once
|
87
90
|
if filenames.size > 1
|
88
91
|
threads = []
|
89
|
-
filenames.
|
90
|
-
|
91
|
-
|
92
|
-
else
|
92
|
+
while filenames.any?
|
93
|
+
to_compile = filenames.shift(4)
|
94
|
+
to_compile.each do |fname|
|
93
95
|
_parser, _compiler = Parser.new, Compiler.new
|
94
96
|
_compiler.options = compiler.options
|
97
|
+
threads << Thread.new do
|
98
|
+
f = File.open(fname)
|
99
|
+
# `do_compile` will close file handle
|
100
|
+
do_compile(f, _parser, _compiler)
|
101
|
+
end
|
95
102
|
end
|
96
|
-
threads
|
97
|
-
|
98
|
-
# `do_compile` will close file handle
|
99
|
-
do_compile(f, _parser, _compiler)
|
100
|
-
end
|
103
|
+
threads.each(&:join)
|
104
|
+
threads.clear
|
101
105
|
end
|
102
|
-
threads.each {|t| t.join}
|
103
106
|
elsif filenames.size == 1
|
104
107
|
fname = filenames.first
|
105
108
|
f = File.open(fname)
|
@@ -108,9 +111,7 @@ module Riml
|
|
108
111
|
else
|
109
112
|
raise ArgumentError, "need filenames to compile"
|
110
113
|
end
|
111
|
-
|
112
|
-
BacktraceFilter.new(pe).filter!
|
113
|
-
raise
|
114
|
+
true
|
114
115
|
ensure
|
115
116
|
flush_warnings
|
116
117
|
end
|
@@ -150,6 +151,12 @@ module Riml
|
|
150
151
|
warning_buffer << warning
|
151
152
|
end
|
152
153
|
|
154
|
+
def self.include_cache
|
155
|
+
@include_cache
|
156
|
+
end
|
157
|
+
# initialize non-lazily because ||= isn't thread-safe
|
158
|
+
@include_cache = IncludeCache.new
|
159
|
+
|
153
160
|
class << self
|
154
161
|
attr_accessor :warnings
|
155
162
|
end
|
@@ -166,8 +173,10 @@ module Riml
|
|
166
173
|
end
|
167
174
|
|
168
175
|
def self.warning_buffer
|
169
|
-
@warning_buffer
|
176
|
+
@warning_buffer
|
170
177
|
end
|
178
|
+
# initialize non-lazily because ||= isn't thread-safe
|
179
|
+
@warning_buffer = WarningBuffer.new
|
171
180
|
|
172
181
|
def self.set_path(name, path)
|
173
182
|
return instance_variable_set("@#{name}", nil) if path.nil?
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: racc
|
@@ -27,6 +27,38 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 10.1.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 10.1.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.3'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
30
62
|
- !ruby/object:Gem::Dependency
|
31
63
|
name: minitest
|
32
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,6 +75,22 @@ dependencies:
|
|
43
75
|
- - ~>
|
44
76
|
- !ruby/object:Gem::Version
|
45
77
|
version: 2.5.1
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: mocha
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.14.0
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.14.0
|
46
94
|
description: ! " Riml is a subset of VimL with some added features, and it compiles
|
47
95
|
to plain\n Vimscript. Some of the added features include classes, string interpolation,\n
|
48
96
|
\ heredocs, default case-sensitive string comparison and default arguments in\n
|
@@ -75,9 +123,9 @@ files:
|
|
75
123
|
- lib/nodes.rb
|
76
124
|
- lib/errors.rb
|
77
125
|
- lib/ast_rewriter.rb
|
126
|
+
- lib/include_cache.rb
|
78
127
|
- Rakefile
|
79
128
|
- CONTRIBUTING
|
80
|
-
- Gemfile.lock
|
81
129
|
- bin/riml
|
82
130
|
homepage: https://github.com/luke-gru/riml
|
83
131
|
licenses:
|
@@ -98,6 +146,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
146
|
- - ! '>='
|
99
147
|
- !ruby/object:Gem::Version
|
100
148
|
version: '0'
|
149
|
+
segments:
|
150
|
+
- 0
|
151
|
+
hash: 1222691864216833334
|
101
152
|
requirements: []
|
102
153
|
rubyforge_project:
|
103
154
|
rubygems_version: 1.8.25
|