-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
translation.rb
28 lines (24 loc) · 1017 Bytes
/
translation.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true
module SyntaxTree
# This module is responsible for translating the Syntax Tree syntax tree into
# other representations.
module Translation
# This method translates the given node into the representation defined by
# the whitequark/parser gem. We don't explicitly list it as a dependency
# because it's not required for the core functionality of Syntax Tree.
def self.to_parser(node, buffer)
require "parser"
require_relative "translation/parser"
node.accept(Parser.new(buffer))
end
# This method translates the given node into the representation defined by
# the rubocop/rubocop-ast gem. We don't explicitly list it as a dependency
# because it's not required for the core functionality of Syntax Tree.
def self.to_rubocop_ast(node, buffer)
require "rubocop/ast"
require_relative "translation/parser"
require_relative "translation/rubocop_ast"
node.accept(RuboCopAST.new(buffer))
end
end
end