def parse(data)
data = data.unpack("c*") if data.is_a?(String)
eof, stack = 0, []
words = []
contexts = [Configuration.new]
class << self
attr_accessor :_nginx_actions
private :_nginx_actions, :_nginx_actions=
end
self._nginx_actions = [
0, 1, 0, 1, 1, 1, 2, 1,
3, 1, 4, 1, 5, 1, 6, 1,
7, 1, 8, 1, 9, 1, 10, 1,
11, 1, 12, 1, 13, 1, 14, 1,
15
]
class << self
attr_accessor :_nginx_key_offsets
private :_nginx_key_offsets, :_nginx_key_offsets=
end
self._nginx_key_offsets = [
0, 1, 5, 6, 11, 12, 13, 18,
21, 22, 23, 30, 35, 39, 42, 48
]
class << self
attr_accessor :_nginx_trans_keys
private :_nginx_trans_keys, :_nginx_trans_keys=
end
self._nginx_trans_keys = [
10, 32, 40, 9, 13, 41, 32, 41,
123, 9, 13, 125, 10, 32, 35, 105,
9, 13, 32, 9, 13, 10, 102, 32,
35, 59, 123, 125, 9, 13, 32, 59,
123, 9, 13, 32, 125, 9, 13, 32,
9, 13, 10, 32, 59, 123, 9, 13,
32, 59, 123, 9, 13, 0
]
class << self
attr_accessor :_nginx_single_lengths
private :_nginx_single_lengths, :_nginx_single_lengths=
end
self._nginx_single_lengths = [
1, 2, 1, 3, 1, 1, 3, 1,
1, 1, 5, 3, 2, 1, 4, 3
]
class << self
attr_accessor :_nginx_range_lengths
private :_nginx_range_lengths, :_nginx_range_lengths=
end
self._nginx_range_lengths = [
0, 1, 0, 1, 0, 0, 1, 1,
0, 0, 1, 1, 1, 1, 1, 1
]
class << self
attr_accessor :_nginx_index_offsets
private :_nginx_index_offsets, :_nginx_index_offsets=
end
self._nginx_index_offsets = [
0, 2, 6, 8, 13, 15, 17, 22,
25, 27, 29, 36, 41, 45, 48, 54
]
class << self
attr_accessor :_nginx_indicies
private :_nginx_indicies, :_nginx_indicies=
end
self._nginx_indicies = [
2, 1, 3, 4, 3, 0, 5, 4,
5, 5, 6, 5, 4, 7, 6, 10,
9, 12, 13, 14, 12, 11, 12, 12,
15, 2, 1, 3, 16, 18, 19, 20,
21, 22, 18, 17, 23, 23, 23, 23,
17, 18, 25, 18, 24, 25, 25, 26,
10, 9, 9, 9, 9, 19, 25, 23,
23, 25, 17, 0
]
class << self
attr_accessor :_nginx_trans_targs_wi
private :_nginx_trans_targs_wi, :_nginx_trans_targs_wi=
end
self._nginx_trans_targs_wi = [
6, 0, 6, 1, 2, 3, 4, 6,
10, 5, 10, 6, 7, 8, 9, 6,
6, 11, 12, 14, 10, 10, 15, 10,
10, 13, 10
]
class << self
attr_accessor :_nginx_trans_actions_wi
private :_nginx_trans_actions_wi, :_nginx_trans_actions_wi=
end
self._nginx_trans_actions_wi = [
31, 0, 25, 0, 0, 0, 0, 21,
19, 0, 11, 23, 0, 5, 5, 29,
27, 0, 0, 5, 7, 9, 0, 13,
17, 0, 15
]
class << self
attr_accessor :_nginx_to_state_actions
private :_nginx_to_state_actions, :_nginx_to_state_actions=
end
self._nginx_to_state_actions = [
0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0, 0, 0
]
class << self
attr_accessor :_nginx_from_state_actions
private :_nginx_from_state_actions, :_nginx_from_state_actions=
end
self._nginx_from_state_actions = [
0, 0, 0, 0, 0, 0, 3, 0,
0, 0, 3, 0, 0, 0, 0, 0
]
class << self
attr_accessor :_nginx_eof_trans
private :_nginx_eof_trans, :_nginx_eof_trans=
end
self._nginx_eof_trans = [
1, 1, 1, 1, 1, 9, 0, 16,
17, 17, 0, 24, 25, 27, 24, 24
]
class << self
attr_accessor :nginx_start
end
self.nginx_start = 6;
class << self
attr_accessor :nginx_first_final
end
self.nginx_first_final = 6;
class << self
attr_accessor :nginx_error
end
self.nginx_error = -1;
class << self
attr_accessor :nginx_en_statement
end
self.nginx_en_statement = 10;
class << self
attr_accessor :nginx_en_main
end
self.nginx_en_main = 6;
begin
p ||= 0
pe ||= data.length
cs = nginx_start
top = 0
ts = nil
te = nil
act = 0
end
begin
_klen, _trans, _keys, _acts, _nacts = nil
_goto_level = 0
_resume = 10
_eof_trans = 15
_again = 20
_test_eof = 30
_out = 40
while true
_trigger_goto = false
if _goto_level <= 0
if p == pe
_goto_level = _test_eof
next
end
end
if _goto_level <= _resume
_acts = _nginx_from_state_actions[cs]
_nacts = _nginx_actions[_acts]
_acts += 1
while _nacts > 0
_nacts -= 1
_acts += 1
case _nginx_actions[_acts - 1]
when 1 then
begin
ts = p
end
end
end
if _trigger_goto
next
end
_keys = _nginx_key_offsets[cs]
_trans = _nginx_index_offsets[cs]
_klen = _nginx_single_lengths[cs]
_break_match = false
begin
if _klen > 0
_lower = _keys
_upper = _keys + _klen - 1
loop do
break if _upper < _lower
_mid = _lower + ( (_upper - _lower) >> 1 )
if data[p] < _nginx_trans_keys[_mid]
_upper = _mid - 1
elsif data[p] > _nginx_trans_keys[_mid]
_lower = _mid + 1
else
_trans += (_mid - _keys)
_break_match = true
break
end
end
break if _break_match
_keys += _klen
_trans += _klen
end
_klen = _nginx_range_lengths[cs]
if _klen > 0
_lower = _keys
_upper = _keys + (_klen << 1) - 2
loop do
break if _upper < _lower
_mid = _lower + (((_upper-_lower) >> 1) & ~1)
if data[p] < _nginx_trans_keys[_mid]
_upper = _mid - 2
elsif data[p] > _nginx_trans_keys[_mid+1]
_lower = _mid + 2
else
_trans += ((_mid - _keys) >> 1)
_break_match = true
break
end
end
break if _break_match
_trans += _klen
end
end while false
_trans = _nginx_indicies[_trans]
end
if _goto_level <= _eof_trans
cs = _nginx_trans_targs_wi[_trans]
if _nginx_trans_actions_wi[_trans] != 0
_acts = _nginx_trans_actions_wi[_trans]
_nacts = _nginx_actions[_acts]
_acts += 1
while _nacts > 0
_nacts -= 1
_acts += 1
case _nginx_actions[_acts - 1]
when 2 then
begin
te = p+1
end
when 3 then
begin
te = p+1
begin
name = words.shift
values = words.dup
contexts.last[name] = value_of(values)
words.clear
begin
top -= 1
cs = stack[top]
_trigger_goto = true
_goto_level = _again
break
end
end
end
when 4 then
begin
te = p+1
begin
name = words.shift
values = words.dup
contexts << contexts.last.section(name, value_of(values))
words.clear
begin
stack[top] = cs
top+= 1
cs = 10
_trigger_goto = true
_goto_level = _again
break
end
end
end
when 5 then
begin
te = p+1
end
when 6 then
begin
te = p
p = p - 1; begin words << data[ts...te].pack('c*') end
end
when 7 then
begin
te = p
p = p - 1; begin
contexts.pop
begin
top -= 1
cs = stack[top]
_trigger_goto = true
_goto_level = _again
break
end
end
end
when 8 then
begin
te = p
p = p - 1; end
when 9 then
begin
begin p = ((te))-1; end
begin words << data[ts...te].pack('c*') end
end
when 10 then
begin
te = p+1
end
when 11 then
begin
te = p+1
begin words.clear; p = p - 1; begin
stack[top] = cs
top+= 1
cs = 10
_trigger_goto = true
_goto_level = _again
break
end
end
end
when 12 then
begin
te = p+1
end
when 13 then
begin
te = p
p = p - 1; begin words.clear; p = p - 1; begin
stack[top] = cs
top+= 1
cs = 10
_trigger_goto = true
_goto_level = _again
break
end
end
end
when 14 then
begin
te = p
p = p - 1; end
when 15 then
begin
begin p = ((te))-1; end
begin words.clear; p = p - 1; begin
stack[top] = cs
top+= 1
cs = 10
_trigger_goto = true
_goto_level = _again
break
end
end
end
end
end
end
if _trigger_goto
next
end
end
if _goto_level <= _again
_acts = _nginx_to_state_actions[cs]
_nacts = _nginx_actions[_acts]
_acts += 1
while _nacts > 0
_nacts -= 1
_acts += 1
case _nginx_actions[_acts - 1]
when 0 then
begin
ts = nil; end
end
end
if _trigger_goto
next
end
p += 1
if p != pe
_goto_level = _resume
next
end
end
if _goto_level <= _test_eof
if p == eof
if _nginx_eof_trans[cs] > 0
_trans = _nginx_eof_trans[cs] - 1;
_goto_level = _eof_trans
next;
end
end
end
if _goto_level <= _out
break
end
end
end
contexts.first
end