Method: Minjs::Lex::Parser#row_col

Defined in:
lib/minjs/lex/parser.rb

#row_col(pos) ⇒ Object

position to [row, col]



1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
# File 'lib/minjs/lex/parser.rb', line 1078

def row_col(pos)
  _pos = 0
  row = 0
  col = 1
  @codes.each do |code|
    break if _pos >= pos
    if line_terminator?(code)
      row += 1
      col = 0
    else
      col += 1
    end
    _pos += 1
  end
  return [row+1, col+1]
end