class Fluent::Config::BasicParser

Constants

LINE_END
LINE_END_WITHOUT_SPACING_AND_COMMENT
SPACING
SPACING_WITHOUT_COMMENT
ZERO_OR_MORE_SPACING

Public Class Methods

new(strscan) click to toggle source
# File lib/fluent/config/basic_parser.rb, line 23
def initialize(strscan)
  @ss = strscan
end

Public Instance Methods

check(pattern) click to toggle source
# File lib/fluent/config/basic_parser.rb, line 75
def check(pattern)
  @ss.check(pattern)
end
eof?() click to toggle source
# File lib/fluent/config/basic_parser.rb, line 67
def eof?
  @ss.eos?
end
error_sample() click to toggle source
# File lib/fluent/config/basic_parser.rb, line 95
def error_sample
  pos = @ss.pos

  lines = @ss.string.lines.to_a
  lines.each_with_index { |line, ln|
    if line.size >= pos
      msgs = ["line #{ln + 1},#{pos}\n"]

      if ln > 0
        last_line = lines[ln - 1]
        msgs << "%3s: %s" % [ln, last_line]
      end

      msgs << "%3s: %s" % [ln + 1, line]
      msgs << "\n     #{'-' * pos}^\n"

      if next_line = lines[ln + 1]
        msgs << "%3s: %s" % [ln + 2, next_line]
      end

      return msgs.join
    end
    pos -= line.size
    last_line = line
  }
end
getch() click to toggle source
# File lib/fluent/config/basic_parser.rb, line 63
def getch
  @ss.getch
end
line_end() click to toggle source
# File lib/fluent/config/basic_parser.rb, line 79
def line_end
  skip(LINE_END)
end
parse_error!(message) click to toggle source
# File lib/fluent/config/basic_parser.rb, line 91
def parse_error!(message)
  raise ConfigParseError, "#{message} at #{error_sample}"
end
prev_match() click to toggle source
# File lib/fluent/config/basic_parser.rb, line 71
def prev_match
  @ss[0]
end
scan(pattern) click to toggle source
# File lib/fluent/config/basic_parser.rb, line 59
def scan(pattern)
  @ss.scan(pattern)
end
skip(pattern) click to toggle source
# File lib/fluent/config/basic_parser.rb, line 55
def skip(pattern)
  @ss.skip(pattern)
end
spacing() click to toggle source
# File lib/fluent/config/basic_parser.rb, line 83
def spacing
  skip(SPACING)
end
spacing_without_comment() click to toggle source
# File lib/fluent/config/basic_parser.rb, line 87
def spacing_without_comment
  skip(SPACING_WITHOUT_COMMENT)
end