Skip to content

Commit

Permalink
Use Opal::Builder to simpify opal-parser.js
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 17, 2013
1 parent 92bb9b2 commit 27c9eed
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
4 changes: 4 additions & 0 deletions lib/opal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def self.parse(source, options = {})
Parser.new.parse(source, options)
end

def self.gem_dir
File.expand_path('..', __FILE__.untaint)
end

def self.core_dir
File.expand_path('../../corelib', __FILE__.untaint)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/opal/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def self.build(name)
Builder.new.build name
end

def initialize
@paths = Opal.paths.clone
def initialize(paths = nil)
@paths = paths || Opal.paths.clone
@handled = {}
end

Expand Down
8 changes: 1 addition & 7 deletions stdlib/opal-parser.js.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
<% require_asset 'racc' %>
<% require_asset 'strscan' %>

// We need (some) of the libs from our real ruby parser (not in sprockets load path)
<% %w(opal/version opal/grammar opal/lexer opal/parser opal/target_scope opal/sexp opal/lexer_scope opal/grammar_helpers opal/fragment opal).each do |f| %>
<%= Opal::RequireParser.parse File.read(File.join Opal.core_dir, '..', 'lib', "#{f}.rb") %>
<% end %>
<%= Opal::Builder.new([Opal.gem_dir, Opal.std_dir]).build('opal') %>

Opal.parse = function(str) {
return Opal.Opal.Parser.$new().$parse(str);
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions stdlib/racc/parser.rb.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require 'racc/parser'

# FIXME: Builder cannot currently handle require('racc/parser.rb') with extname

0 comments on commit 27c9eed

Please sign in to comment.