Module: Opal::Parser::DefaultConfig

Included in:
WithCLexer, WithRubyLexer
Defined in:
opal/lib/opal/parser/default_config.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



18
19
20
21
22
23
24
25
# File 'opal/lib/opal/parser/default_config.rb', line 18

def self.included(klass)
  klass.extend(ClassMethods)
  klass.diagnostics_consumer = ->(diagnostic) do
    if RUBY_ENGINE != 'opal'
      $stderr.puts(diagnostic.render)
    end
  end
end

Instance Method Details

#initializeObject



27
28
29
# File 'opal/lib/opal/parser/default_config.rb', line 27

def initialize(*)
  super(Opal::AST::Builder.new)
end

#parse(source_buffer) ⇒ Object



31
32
33
34
35
# File 'opal/lib/opal/parser/default_config.rb', line 31

def parse(source_buffer)
  parsed = super
  rewriten = rewrite(parsed)
  rewriten
end

#rewrite(node) ⇒ Object



37
38
39
# File 'opal/lib/opal/parser/default_config.rb', line 37

def rewrite(node)
  Opal::Rewriter.new(node).process
end