lib/riemann/tools/mdstat_parser.tab.rb in riemann-tools-1.4.0 vs lib/riemann/tools/mdstat_parser.tab.rb in riemann-tools-1.5.0
- old
+ new
@@ -7,198 +7,217 @@
require 'racc/parser.rb'
require 'strscan'
+require 'riemann/tools/utils'
+
module Riemann
module Tools
class MdstatParser < Racc::Parser
-module_eval(<<'...end mdstat_parser.y/module_eval...', 'mdstat_parser.y', 42)
+module_eval(<<'...end mdstat_parser.y/module_eval...', 'mdstat_parser.y', 49)
def parse(text)
- s = StringScanner.new(text)
- @tokens = []
+ s = Utils::StringTokenizer.new(text)
until s.eos? do
case
- when s.scan(/\n/) then # ignore
- when s.scan(/\s+/) then # ignore
+ when s.scan(/\n/) then s.push_token(nil)
+ when s.scan(/\s+/) then s.push_token(nil)
- when s.scan(/\[=*>.*\]/) then @tokens << [:PROGRESS, s.matched]
- when s.scan(/%/) then @tokens << ['%', s.matched]
- when s.scan(/,/) then @tokens << [',', s.matched]
- when s.scan(/:/) then @tokens << [':', s.matched]
- when s.scan(/</) then @tokens << ['<', s.matched]
- when s.scan(/=/) then @tokens << ['=', s.matched]
- when s.scan(/>/) then @tokens << ['>', s.matched]
- when s.scan(/\(/) then @tokens << ['(', s.matched]
- when s.scan(/\)/) then @tokens << [')', s.matched]
- when s.scan(/\./) then @tokens << ['.', s.matched]
- when s.scan(/\//) then @tokens << ['/', s.matched]
- when s.scan(/\[/) then @tokens << ['[', s.matched]
- when s.scan(/]/) then @tokens << [']', s.matched]
- when s.scan(/algorithm/) then @tokens << [:ALGORITHM, s.matched]
- when s.scan(/bitmap/) then @tokens << [:BITMAP, s.matched]
- when s.scan(/blocks/) then @tokens << [:BLOCKS, s.matched]
- when s.scan(/chunk/) then @tokens << [:CHUNK, s.matched]
- when s.scan(/finish/) then @tokens << [:FINISH, s.matched]
- when s.scan(/level/) then @tokens << [:LEVEL, s.matched]
- when s.scan(/min/) then @tokens << [:MIN, s.matched]
- when s.scan(/pages/) then @tokens << [:PAGES, s.matched]
- when s.scan(/(raid([014-6]|10)|linear|multipath|faulty)\b/) then @tokens << [:PERSONALITY, s.matched]
- when s.scan(/Personalities/) then @tokens << [:PERSONALITIES, s.matched]
- when s.scan(/recovery/) then @tokens << [:RECOVERY, s.matched]
- when s.scan(/speed/) then @tokens << [:SPEED, s.matched]
- when s.scan(/super/) then @tokens << [:SUPER, s.matched]
- when s.scan(/unused devices/) then @tokens << [:UNUSED_DEVICES, s.matched]
- when s.scan(/K\/sec/) then @tokens << [:SPEED_UNIT, s.matched.to_i]
- when s.scan(/KB/) then @tokens << [:BYTE_UNIT, s.matched.to_i]
- when s.scan(/k/) then @tokens << [:UNIT, s.matched.to_i]
- when s.scan(/\d+\.\d+/) then @tokens << [:FLOAT, s.matched.to_i]
- when s.scan(/\d+/) then @tokens << [:INTEGER, s.matched.to_i]
- when s.scan(/F\b/) then @tokens << [:FAILED, s.matched.to_i]
- when s.scan(/\w+/) then @tokens << [:IDENTIFIER, s.matched]
+ when s.scan(/\[=*>.*\]/) then s.push_token(:PROGRESS)
+ when s.scan(/%/) then s.push_token('%')
+ when s.scan(/,/) then s.push_token(',')
+ when s.scan(/:/) then s.push_token(':')
+ when s.scan(/</) then s.push_token('<')
+ when s.scan(/=/) then s.push_token('=')
+ when s.scan(/>/) then s.push_token('>')
+ when s.scan(/\(/) then s.push_token('(')
+ when s.scan(/\)/) then s.push_token(')')
+ when s.scan(/\./) then s.push_token('.')
+ when s.scan(/\//) then s.push_token('/')
+ when s.scan(/\[/) then s.push_token('[')
+ when s.scan(/]/) then s.push_token(']')
+ when s.scan(/algorithm/) then s.push_token(:ALGORITHM)
+ when s.scan(/bitmap/) then s.push_token(:BITMAP)
+ when s.scan(/blocks/) then s.push_token(:BLOCKS)
+ when s.scan(/check/) then s.push_token(:CHECK)
+ when s.scan(/chunk/) then s.push_token(:CHUNK)
+ when s.scan(/finish/) then s.push_token(:FINISH)
+ when s.scan(/level/) then s.push_token(:LEVEL)
+ when s.scan(/min/) then s.push_token(:MIN)
+ when s.scan(/pages/) then s.push_token(:PAGES)
+ when s.scan(/(raid([014-6]|10)|linear|multipath|faulty)\b/) then s.push_token(:PERSONALITY)
+ when s.scan(/Personalities/) then s.push_token(:PERSONALITIES)
+ when s.scan(/recovery/) then s.push_token(:RECOVERY)
+ when s.scan(/reshape/) then s.push_token(:RESHAPE)
+ when s.scan(/resync/) then s.push_token(:RESYNC)
+ when s.scan(/speed/) then s.push_token(:SPEED)
+ when s.scan(/super/) then s.push_token(:SUPER)
+ when s.scan(/unused devices/) then s.push_token(:UNUSED_DEVICES)
+ when s.scan(/K\/sec/) then s.push_token(:SPEED_UNIT)
+ when s.scan(/KB/) then s.push_token(:BYTE_UNIT)
+ when s.scan(/k/) then s.push_token(:UNIT)
+ when s.scan(/\d+\.\d+/) then s.push_token(:FLOAT, s.matched.to_f)
+ when s.scan(/\d+/) then s.push_token(:INTEGER, s.matched.to_i)
+ when s.scan(/F\b/) then s.push_token(:FAILED)
+ when s.scan(/\w+/) then s.push_token(:IDENTIFIER)
else
- raise s.rest
+ s.unexpected_token
end
end
+ @tokens = s.tokens
+
do_parse
end
def next_token
@tokens.shift
end
+
+ def on_error(error_token_id, error_value, value_stack)
+ raise(Racc::ParseError, "parse error on value \"#{error_value[:value]}\" (#{token_to_str(error_token_id)}) on line #{error_value[:lineno]}:\n#{error_value[:line]}\n#{' ' * error_value[:pos]}^#{'~' * (error_value[:value].to_s.length - 1)}")
+ end
...end mdstat_parser.y/module_eval...
##### State transition tables begin ###
racc_action_table = [
- 10, 13, 14, 10, 29, 3, 4, 6, 7, 15,
- 16, 17, 18, 11, 19, 20, 21, 22, 23, 24,
- 10, 27, 28, 31, 32, 33, 35, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- 50, 51, 52, 53, 54, 56, 58, 59, 60, 61,
- 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
- 82, 83, 84, 85, 86, 87, 88 ]
+ 10, 13, 14, 60, 10, 29, 3, 4, 6, 7,
+ 15, 16, 17, 18, 19, 11, 61, 62, 63, 20,
+ 21, 22, 23, 24, 10, 27, 28, 31, 32, 33,
+ 35, 37, 38, 39, 40, 41, 42, 43, 44, 45,
+ 46, 47, 48, 49, 50, 51, 52, 53, 54, 56,
+ 58, 64, 65, 66, 67, 68, 69, 70, 71, 72,
+ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
+ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92 ]
racc_action_check = [
- 5, 10, 10, 25, 25, 0, 1, 3, 4, 11,
- 12, 13, 14, 5, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 27, 29, 31, 32, 34, 35, 36,
- 37, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 55, 56, 58, 59,
- 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
- 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 84, 85, 86, 87 ]
+ 5, 10, 10, 56, 25, 25, 0, 1, 3, 4,
+ 11, 12, 13, 14, 15, 5, 56, 56, 56, 16,
+ 17, 18, 19, 20, 21, 22, 23, 27, 29, 31,
+ 32, 34, 35, 36, 37, 39, 40, 41, 42, 43,
+ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+ 55, 58, 59, 64, 65, 66, 67, 68, 69, 70,
+ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
+ 81, 82, 83, 84, 85, 86, 87, 89, 90, 91 ]
racc_action_pointer = [
- -10, 6, nil, -17, 8, -10, nil, nil, nil, nil,
- -23, -15, -15, 1, 1, -19, -1, 0, -9, 8,
- -7, 10, -7, -12, nil, -7, nil, 16, nil, 20,
- nil, -4, 5, nil, 15, 19, 4, 19, nil, 20,
- 2, 6, 23, 24, 14, 11, 32, 14, 10, 31,
- 40, 17, 33, 42, nil, 29, 23, nil, 30, 38,
- 19, 24, 43, 42, 22, 41, 28, 32, 47, 48,
- 33, 56, 51, 37, 35, 35, 58, 56, 37, 64,
- 61, 65, 59, nil, 54, 43, 64, 56, nil ]
+ -10, 7, nil, -19, 9, -11, nil, nil, nil, nil,
+ -26, -17, -17, 1, 1, -22, 2, 3, -8, 11,
+ -6, 13, -6, -11, nil, -7, nil, 19, nil, 24,
+ nil, -3, 6, nil, 18, 22, 5, 22, nil, 23,
+ 3, 7, 26, 27, 15, 12, 35, 15, 11, 34,
+ 44, 18, 36, 31, nil, 47, -3, nil, 24, 18,
+ nil, nil, nil, nil, 41, 44, 25, 21, 45, 27,
+ 44, 48, 33, 32, 51, 52, 60, 34, 38, 59,
+ 36, 36, 59, 62, 68, 60, 68, 54, nil, 43,
+ 66, 56, nil ]
racc_action_default = [
- -21, -21, -6, -21, -21, -21, -4, 89, -1, -5,
- -21, -21, -2, -21, -21, -21, -21, -21, -21, -21,
- -21, -21, -11, -21, -3, -21, -9, -21, -20, -21,
- -8, -21, -13, -10, -15, -21, -21, -21, -12, -21,
- -21, -21, -21, -21, -21, -21, -21, -21, -21, -21,
- -21, -21, -21, -17, -14, -19, -21, -7, -21, -21,
- -21, -21, -21, -21, -21, -21, -21, -21, -21, -21,
- -21, -21, -21, -21, -21, -21, -21, -21, -21, -21,
- -21, -21, -21, -16, -21, -21, -21, -21, -18 ]
+ -25, -25, -6, -25, -25, -25, -4, 93, -1, -5,
+ -25, -25, -2, -25, -25, -25, -25, -25, -25, -25,
+ -25, -25, -11, -25, -3, -25, -9, -25, -24, -25,
+ -8, -25, -13, -10, -15, -25, -25, -25, -12, -25,
+ -25, -25, -25, -25, -25, -25, -25, -25, -25, -25,
+ -25, -25, -25, -19, -14, -17, -25, -7, -25, -25,
+ -20, -21, -22, -23, -25, -25, -25, -25, -25, -25,
+ -25, -25, -25, -25, -25, -25, -25, -25, -25, -25,
+ -25, -25, -25, -25, -25, -25, -25, -25, -16, -25,
+ -25, -25, -18 ]
racc_goto_table = [
9, 1, 2, 5, 8, 12, 25, 34, 36, 55,
- 57, nil, nil, nil, nil, nil, 26, nil, nil, nil,
+ 57, 59, nil, nil, nil, nil, 26, nil, nil, nil,
30 ]
racc_goto_check = [
6, 1, 2, 3, 4, 5, 7, 8, 9, 10,
- 11, nil, nil, nil, nil, nil, 6, nil, nil, nil,
+ 11, 12, nil, nil, nil, nil, 6, nil, nil, nil,
6 ]
racc_goto_pointer = [
nil, 1, 2, 1, -1, -1, -5, -15, -25, -26,
- -44, -45 ]
+ -44, -45, -45 ]
racc_goto_default = [
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
- nil, nil ]
+ nil, nil, nil ]
racc_reduce_table = [
0, 0, :racc_error,
- 3, 36, :_reduce_1,
- 3, 37, :_reduce_none,
- 4, 40, :_reduce_none,
- 0, 40, :_reduce_none,
- 2, 38, :_reduce_5,
- 0, 38, :_reduce_6,
- 19, 41, :_reduce_7,
- 2, 42, :_reduce_none,
- 1, 42, :_reduce_none,
- 7, 41, :_reduce_none,
- 4, 41, :_reduce_none,
- 2, 43, :_reduce_none,
+ 3, 39, :_reduce_1,
+ 3, 40, :_reduce_none,
+ 4, 43, :_reduce_none,
0, 43, :_reduce_none,
- 9, 44, :_reduce_none,
- 0, 44, :_reduce_none,
- 14, 45, :_reduce_none,
- 0, 45, :_reduce_none,
- 18, 46, :_reduce_none,
+ 2, 41, :_reduce_5,
+ 0, 41, :_reduce_6,
+ 19, 44, :_reduce_7,
+ 2, 45, :_reduce_none,
+ 1, 45, :_reduce_none,
+ 7, 44, :_reduce_none,
+ 4, 44, :_reduce_none,
+ 2, 46, :_reduce_none,
0, 46, :_reduce_none,
- 5, 39, :_reduce_none ]
+ 9, 47, :_reduce_none,
+ 0, 47, :_reduce_none,
+ 14, 49, :_reduce_none,
+ 0, 49, :_reduce_none,
+ 18, 48, :_reduce_none,
+ 0, 48, :_reduce_none,
+ 1, 50, :_reduce_none,
+ 1, 50, :_reduce_none,
+ 1, 50, :_reduce_none,
+ 1, 50, :_reduce_none,
+ 5, 42, :_reduce_none ]
-racc_reduce_n = 21
+racc_reduce_n = 25
-racc_shift_n = 89
+racc_shift_n = 93
racc_token_table = {
false => 0,
:error => 1,
:ALGORITHM => 2,
:BITMAP => 3,
:BLOCKS => 4,
:BYTE_UNIT => 5,
- :CHUNK => 6,
- :FAILED => 7,
- :FINISH => 8,
- :FLOAT => 9,
- :IDENTIFIER => 10,
- :INTEGER => 11,
- :LEVEL => 12,
- :MIN => 13,
- :PAGES => 14,
- :PERSONALITIES => 15,
- :PERSONALITY => 16,
- :PROGRESS => 17,
- :RECOVERY => 18,
- :SPEED => 19,
- :SPEED_UNIT => 20,
- :SUPER => 21,
- :UNIT => 22,
- :UNUSED_DEVICES => 23,
- ":" => 24,
- "[" => 25,
- "]" => 26,
- "/" => 27,
- "(" => 28,
- ")" => 29,
- "," => 30,
- "=" => 31,
- "%" => 32,
- "<" => 33,
- ">" => 34 }
+ :CHECK => 6,
+ :CHUNK => 7,
+ :FAILED => 8,
+ :FINISH => 9,
+ :FLOAT => 10,
+ :IDENTIFIER => 11,
+ :INTEGER => 12,
+ :LEVEL => 13,
+ :MIN => 14,
+ :PAGES => 15,
+ :PERSONALITIES => 16,
+ :PERSONALITY => 17,
+ :PROGRESS => 18,
+ :RECOVERY => 19,
+ :RESHAPE => 20,
+ :RESYNC => 21,
+ :SPEED => 22,
+ :SPEED_UNIT => 23,
+ :SUPER => 24,
+ :UNIT => 25,
+ :UNUSED_DEVICES => 26,
+ ":" => 27,
+ "[" => 28,
+ "]" => 29,
+ "/" => 30,
+ "(" => 31,
+ ")" => 32,
+ "," => 33,
+ "=" => 34,
+ "%" => 35,
+ "<" => 36,
+ ">" => 37 }
-racc_nt_base = 35
+racc_nt_base = 38
racc_use_result_var = true
Racc_arg = [
racc_action_table,
@@ -221,10 +240,11 @@
"error",
"ALGORITHM",
"BITMAP",
"BLOCKS",
"BYTE_UNIT",
+ "CHECK",
"CHUNK",
"FAILED",
"FINISH",
"FLOAT",
"IDENTIFIER",
@@ -234,10 +254,12 @@
"PAGES",
"PERSONALITIES",
"PERSONALITY",
"PROGRESS",
"RECOVERY",
+ "RESHAPE",
+ "RESYNC",
"SPEED",
"SPEED_UNIT",
"SUPER",
"UNIT",
"UNUSED_DEVICES",
@@ -260,12 +282,13 @@
"list_of_personalities",
"device",
"list_of_devices",
"super",
"level",
+ "progress",
"bitmap",
- "restore_progress" ]
+ "progress_action" ]
Racc_debug_parser = false
##### State transition tables end #####
@@ -298,11 +321,11 @@
end
.,.,
module_eval(<<'.,.,', 'mdstat_parser.y', 13)
def _reduce_7(val, _values, result)
- result = { val[0] => val[15] }
+ result = { val[0][:value] => val[15][:value] }
result
end
.,.,
# reduce 8 omitted
@@ -328,9 +351,17 @@
# reduce 18 omitted
# reduce 19 omitted
# reduce 20 omitted
+
+# reduce 21 omitted
+
+# reduce 22 omitted
+
+# reduce 23 omitted
+
+# reduce 24 omitted
def _reduce_none(val, _values, result)
val[0]
end