Class: Opal::Parser

Inherits:
Parser::Ruby23
  • Object
show all
Defined in:
opal/lib/opal/parser.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser



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

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

Class Attribute Details

.diagnostics_consumerObject

Returns the value of attribute diagnostics_consumer



16
17
18
# File 'opal/lib/opal/parser.rb', line 16

def diagnostics_consumer
  @diagnostics_consumer
end

Class Method Details

.default_parserObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'opal/lib/opal/parser.rb', line 18

def default_parser
  parser = super

  parser.diagnostics.all_errors_are_fatal = true
  parser.diagnostics.ignore_warnings      = false

  if RUBY_ENGINE == 'opal'
    parser.diagnostics.consumer = ->(diag){}
  else
    parser.diagnostics.consumer = diagnostics_consumer
  end

  parser
end

Instance Method Details

#parse(source_buffer) ⇒ Object



40
41
42
43
44
# File 'opal/lib/opal/parser.rb', line 40

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

#rewrite(node) ⇒ Object



46
47
48
# File 'opal/lib/opal/parser.rb', line 46

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