R12.1-2025Jul03
Local Scope in Paragraph Pattern

You can add a Local Scope to define the text scope for a variable line. The Local Scope copy applies to any var line that follows it. One or more local scopes can be defined within one pattern. This function is useful for parsing configurations that have a multi-level relationship using a single pattern.

Define a Local Scope

You can add a local scope from the drop-down menu of a variable line.

To create a local scope, follow the steps below:

  1. Click Insert Local Scope from the dropdown menu of a var line, then the Local Scope will be added above this var line. 

  2. Define the start line of the local scope. You can continue to define the following advanced settings:

    • Whether the start line is included in the scope.
    • What to do if the start line is not parsed: When ‘Optional’ is checked, the start line of the default scope for this var line will be used if the start line is not successfully parsed.
  1. Define the end line of local scope. You can continue to define similar definitions to the start line:

    Information Note: A local scope can be deleted from its dropdown menu.


Select Local Scope for a Var Line

You can specify a scope for a var line from its dropdown menu, and the selected scope will be marked by the  icon.

The scope options are introduced below:

  • #Id Line Scope: The scope that is specified by the ID line above this var line.
  • Local Scope: List the scopes defined before this var line.
  • Default Scope: The parsed text scope of the current pattern. If no scope is specified, the default scope will be used.
Information Note: For the collector pattern, the default scope may be the whole command text.

Insert Variable Line

Insert Variable line: You can insert a new variable line from the drop-down menu of an existing variable line. The newly inserted line can access the local scope defined above it. 

Example of Using Local Scope

The following use case illustrates how local scope works.

  1. Parse variable $route_map by ID line.
  2. Parse $prefix_list by var line, then define local scope 1 for the var line to parse it correctly. Use the variable template <%$route_map%> to define the start line of the local scope.
  3. Parse $prefix_config by var line, then define a local scope 2 for the var line to parse it correctly. Use the variable template <%$ prefix_list %> to define the start line of the local scope.

The final parser output will be as below: