Defining a Paragraph Parser to Parse Nested Paragraph and Nested Table

Besides 2-layer nested paragraph, multi-layer nested paragraph and nested table are also supported with parent paragraph.

You can add previously defined paragraphs as parent paragraph to paragraph parser and table parser. Then variables defined in parent paragraphs can be inherited and displayed as table columns in parser result. Since the parent paragraph can be nested paragraphs, so it is possible to create multi-layer nested paragraphs and tables.

With parent paragraph being selected, the start line and end line will be applied inside each paragraph instead of being applied to the whole sample data. Therefore, it is possible to have multiple start lines and end lines for nested paragraph and nested table.

Example: Create parser for nested paragraphs for command show policy-map interface.

1.Define parent paragraph interface.

2.Define paragraph service_policy.

3.Click Add Parent to add parent paragraph.

4.Select paragraph interface as parent paragraph from the drop-down menu.

5.Define Variable Lines for paragraph service_policy.

6.Click 2/2 Variables to open the Select Variable window. Select the variables to be inherited and displayed from the list.

When the parent paragraph is selected, the sample data will be firstly divided into paragraphs as defined in parent paragraph. In this example, the sample data is firstly divided into two paragraphs (Paragraph 1 and Paragraph 2) as shown below. Then each paragraph is further divided into two subparagraphs as defined by ID Line A.

By selecting the variables in step 6, the variables defined in parent paragraph interface are displayed in the parser result for paragraph service_policy:

For paragraph service_policy, the start line will be applied inside each paragraph from parent paragraph (Paragraph 1 and Paragraph 2). For each paragraph, the parsing scope will start from the start line till the end line or end of paragraph if end line is not defined.

Add Definition for End of Paragraph

End of paragraph can be defined to narrow the scope of each paragraph for more accurate results. This is especially useful to parse the configlets in paragraph parser. The diagram below shows the order in which parser rules are applied:

When there is no end of paragraph defined, or there are no matched lines found for end of paragraph, the matching scope for variables is the whole paragraph. Single-line rule or regular expressions can be used to define end of paragraph. It is not recommended to define variables in end of paragraph as they will not be parsed and will be treated as dummy variables.

There are two ways to define the end of paragraph. An example about how to define the end of paragraph for CLI command show interface in two ways is as follows:

Option1: Select the target line of text in sample data and click the icon to duplicate it at the End of Paragraph field.

Option2: Use regular expression to define end of paragraph.

In this example, the parsed configlet will stop before end of paragraph for a more accurate result: