Module: JSCompiler::Parser

Defined in:
lib/jsc/parser.rb

Class Method Summary collapse

Class Method Details

.default_parser(result) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/jsc/parser.rb', line 37

def default_parser(result)
  out = ""
  
  if $debug
    puts "#DEBUG default parser \n"
  end

  op = JSCompiler.op
  unless result.nil?
    num = result.size
    out << "You've got #{result.size} #{op}\n"
    i = 0
    result.each do |message|
      i += 1
      out << "\n#{op.singularize.capitalize} n.#{i}\n"
      out << "\t#{message['type']}: " + message[op.singularize] + " at line #{message['lineno']} character #{message['charno']}\n"
      out << "\t" + message['line'] + "\n" unless message['line'].nil?
      out << "\t" + print_under_character(message['charno'])
    end
    out
  else
    "No #{op}"
  end
end

.flymake_parser(result) ⇒ Object

window_message_handlers.js:73: strict warning: trailing comma is not legal in ECMA-262 object initializers:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jsc/parser.rb', line 13

def flymake_parser(result)
  if $debug
    puts "#DEBUG flymake parser \n"
  end

  #TODO
  out = ""
  op = JSCompiler.op
  unless result.nil?
    file = JSCompiler.file
    format_type = JSCompiler.format_type

    num = result.size
    result.each do |message|
      out << "#{file}:#{message['lineno']}: #{op.singularize}: #{message['type']}: " + message[op.singularize] +"\n"
      out << "#{file}:#{message['lineno']}: #{op.singularize}: #{message['line']} \n" unless message['line'].nil?
      out << "#{file}:#{message['lineno']}: #{op.singularize}: " + print_under_character(message['charno'])
    end
  else
    out = "No #{op}"
  end
  return out
end

.parse(result) ⇒ Object

this methos calls the right parser for result



7
8
9
10
# File 'lib/jsc/parser.rb', line 7

def parse(result)
  return flymake_parser(result) if JSCompiler.format_type == "flymake"
  default_parser(result)
end


62
63
64
65
66
67
68
69
70
71
# File 'lib/jsc/parser.rb', line 62

def print_under_character(pos)
  i = 0
  auto_fill = ""
  while i < pos -1
    auto_fill << "."
    i = i+1
  end
  
  auto_fill << " ^ \n"
end