1 # vim: tabstop=4 shiftwidth=4 softtabstop=4
2 # -*- coding: utf-8 -*-
8 from ftg.utils.common import CommonUtils
9 from ftg.flow_table import FlowTable
10 from ftg.flow_priority import FlowPriority
11 from ftg.flow_entry import FlowEntry
12 from ftg.parser.base import BaseParser
15 class TSVParser(BaseParser):
18 self.util.debug_out(self.dump_file)
19 for dump_line in open(self.dump_file, 'r'):
20 dump_line = dump_line.rstrip()
22 if self.util.d_push(re.match(r'(\d+)-(\d+)\t(.*)\t(.*)', dump_line)) is not None:
23 match = self.util.d_pop()
24 table_no = match.group(1)
25 priority_no = match.group(2)
26 match_exp = match.group(3)
27 instruction = match.group(4)
28 instructions = self._parse_actions_with_bracket(
29 instruction, instructions)
31 "[1] " + table_no + "-" + priority_no + " m:" + match_exp + " a:" + instruction)
33 table_no, priority_no, match_exp, instructions)
34 elif self.util.d_push(re.match(r'(\d+)\t(.*)\t(.*)', dump_line)) is not None:
35 match = self.util.d_pop()
36 table_no = match.group(1)
38 match_exp = match.group(2)
39 instruction = match.group(3)
40 instructions = self._parse_actions_with_bracket(
41 instruction, instructions)
43 "[3] " + table_no + "-" + priority_no + " m:" + match_exp + " a:" + instruction)
45 table_no, priority_no, match_exp, instructions)
46 elif dump_line.strip() == "":
48 elif self.util.d_push(re.match(r'Table-Priority\tMatch\tInstruction', dump_line)) is not None:
51 if not self.util.d_push(re.match(r'.*NXST_FLOW reply.*', dump_line)):
52 self.util.error_out("PARSE ERROR: " + dump_line)