Mapping Regular Expressions to Text File Searches

The COBOL Analyzer parser extracts entity and relationship instances from text files using search patterns you define in Architecture Modeler. In schematic form, the parser uses these patterns to:
  • Match relationship instances in the code.
  • Form the names of entity instances.
  • Form the names of relationship instances.

Architecture Modeler's regular expression generator simplifies the task of defining these patterns. Follow the steps below to map regular expressions to text file searches.

  1. Click Files in Architecture Modeler. Architecture Modeler displays the defined source file types in the Name area in the central pane of the window, and the text of the corresponding sample in the right-hand pane. If more than one source file type is listed, click the name of the type to display the sample.
  2. Generate the pattern the parser uses to match relationship instances:
    1. Select the code of interest in the sample source file.
    2. Choose Pick in the right-click menu.
    The Add Expression window opens.
  3. Add an expression ID, e.g. "function" for the selected function call. All expression IDs appear in the middle-bottom left-hand side of the screen in a tree form.
  4. Select the expression ID and choose Edit in the right-click menu. The Edit Regular Expression Mapping window opens. Expressions are represented in a hierarchical manner. Each expression contains its regular expression pattern and all direct children expressions.
  5. Select the expression pattern and choose Edit in the right-click menu. The Edit Regular Expression window opens. The generated regular expression is displayed in the upper part of the left-hand pane in tree form. The expression does not require further editing.
    Note: Do not manually edit the generated regular expression unless you have modified it inadvertently.
  6. In the left-hand pane of the Edit Regular Expression window, define the regular expression the parser uses to form the names of entity instances:
    1. Expand the tree for the generated regular expression.
    2. Use a subexpression of the generated regular expression to match the names of entity instances. Follow the instructions in Editing Subexpressions to edit the subexpression.
    3. Click Apply Changes after each modification.
  7. In the right-hand pane of the Edit Regular Expression Mapping window, map the regular expression for the names of entity instances. You do not need to map a regular expression for the source file name:
    1. In the Entity group box, select the entity type you want to match in the Type drop-down.
    2. Drag-and-drop the subexpression for the names of entity instances from the expression tree to the cell beside the Name attribute. The subexpression is mapped to a variable with a name reflecting the order of grouped expressions in the expression tree, counting from the regular expression for the matched relationship. For example if (\w+) is the only other grouped expression besides the expression for the matched relationship, the mapped variable is named %[ExpressionID].2%.
    3. Assuming you are defining a relationship between a source file and an extracted object, enter the system variable %[ExpressionID].sourcefilename in the cell beside the Source attribute. If you are defining another type of relationship, reference-resolving information may be contained in a different attribute.
    4. You can use functions to help you resolve entities' relationship ends. These functions are:substr, append, length, concat, replace, getpath, getfilename, unifypath. For more details on the usage of these functions, read Application Modeler Internal Language Functions Description.
  8. Click Save in the Entity group box. The entity mapping is added to the list of mappings in the Mapping List group box. Repeat this procedure for each entity mapping you want to define.
  9. In the right-hand pane of the Edit Regular Expression Mapping window, map the regular expression for the names of relationship instances:
    1. In the Relation group box, select the relationship type you want to map in the Type drop-down.
    2. Drag-and-drop the subexpression for the left entity name from the expression tree to the cell beside the Left Entity Name attribute. If you are defining a relationship between a source file and an extracted object, enter the system variable %[expressionid].sourcefilename% in the cell beside the Left Entity Name attribute.
    3. Drag-and-drop the subexpression for the right entity name from the expression tree to the cell beside the Right Entity Name attribute.
  10. Click Save in the Relation group box. The relationship mapping is added to the list of mappings in the Mapping List group box.
    Note: To edit a mapping definition, select it in the Mapping List group box and click Edit. Follow the procedure you used to define the mapping. To delete a mapping definition, select it in the Mapping List group box and click Remove.
  11. When you finish editing your entries in the Edit Regular Expression Mapping window, click Save. Architecture Modeler displays the edited expression ID in the central pane of the window.
    Note:
    • Select the expression ID and choose Edit in the right-click menu to modify the pattern.
    • Select it and choose Delete in the right-click menu to delete the pattern.