Module: Mirah::AST

Defined in:
lib/mirah/ast.rb,
lib/mirah/ast/scope.rb,
lib/mirah/jvm/compiler.rb,
lib/mirah/transform/ast_ext.rb

Defined Under Namespace

Classes: FunctionalCall, StaticScope, Super

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.verboseObject

Returns the value of attribute verbose.



23
24
25
# File 'lib/mirah/ast.rb', line 23

def verbose
  @verbose
end

Class Method Details

.parse(src, filename = 'dash_e', raise_errors = false, transformer = nil) ⇒ Object

Raises:

  • (ArgumentError)


8
9
10
11
# File 'lib/mirah/transform/ast_ext.rb', line 8

def parse(src, filename='dash_e', raise_errors=false, transformer=nil)
  raise ArgumentError unless transformer
  parse_ruby(transformer, src, filename)
end

.parse_ruby(transformer, src, filename = '-') ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mirah/transform/ast_ext.rb', line 14

def parse_ruby(transformer, src, filename='-')
  raise ArgumentError if src.nil?
  #filename = transformer.tag_filename(src, filename)
  parser = MirahParser.new
  source = StringCodeSource.new(filename, src)
  parser.diagnostics = SimpleDiagnostics.new(true)
  begin
    ast = parser.parse(source)
    if parser.diagnostics.error_count > 0
      puts "#{parser.diagnostics.error_count} errors, exiting"
      throw :exit, 1
    end
    return ast
  rescue NativeException => ex
    ex.cause.printStackTrace
    raise ex
  rescue => ex
    # if ex.cause.kind_of? Java::OrgMirahMmeta::SyntaxError
    #   ex = SyntaxError.wrap ex.cause, nil
    # end

    if ex.respond_to? :position
      position = ex.cause.position
      Mirah.print_error(ex.cause.message, position)
    end
    raise ex
  end
end