Class: BelleTranspiler

Inherits:
Object
  • Object
show all
Defined in:
lib/bellejs/belle_transpiler.rb

Constant Summary collapse

BELLEJS_NODE_CLASSES =
[RBelly::Nodes::ImportNode, RBelly::Nodes::ClassNode, RBelly::Nodes::ExtendsNode, RBelly::Nodes::BellejsVarStatementNode, RBelly::Nodes::BellejsFuncStatementNode]
LINE_END =
RBelly::Nodes::ExpressionStatementNode

Instance Method Summary collapse

Constructor Details

#initialize(file_contents, local_dir) ⇒ BelleTranspiler

Returns a new instance of BelleTranspiler.



8
9
10
11
12
# File 'lib/bellejs/belle_transpiler.rb', line 8

def initialize(file_contents, local_dir)
  @local_dir = local_dir
  @raw_file_contents = file_contents
  @parser = RBelly::Parser.new
end

Instance Method Details

#transpileObject



14
15
16
17
18
# File 'lib/bellejs/belle_transpiler.rb', line 14

def transpile
  ast = @parser.parse @raw_file_contents
  pure_js_tree = replace_bellejs(ast)
  pure_js_tree.to_ecma
end