Special cases for Universal Analyzer language packages

Handle objects with no end pattern, understand how comments are counted, and migrate language packages written for older CAST releases
Updated

Overview

This page covers situations that commonly cause incorrect results with a Universal Analyzer language package, and the changes needed to use a language package written for an older CAST release.

Objects with no end pattern

An object type that has no end pattern, and whose sibling objects are recognized by a property pattern, can be identified incorrectly: the Universal Analyzer can include the start of the next object in the current one. To avoid this, include the property in the pattern that locates the sibling objects.

For example, in the following script, functions have no end pattern and their names are recognized with a backward property pattern:

Fct1 : function
echo "today"
Fct2 : function
echo "tomorrow"
  • With the pattern function, the object Fct1 is not identified correctly: it extends to the name of Fct2.
  • With the pattern [a-zA-Z0-9]+ : function, the object Fct1 is identified correctly.

How comments are counted

  • A line that contains only white space or comment markers is not counted as a comment line.
  • Several comments on the same line are counted separately: /* comment 1 */ ... /* comment 2 */ counts as two comments.

Migrate an older language package

Language packages written for CAST AIP 6.x and earlier may need the following changes.

Encoding

The Universal Analyzer supports Unicode source files, so the XML files of the package must also be Unicode. Check that xxxMetaModel.xml, xxxLanguagePattern.xml, xxxInformationTracking.xml and xxxCastMetrics.xml are saved in UTF-8 and start with this declaration:

<?xml version="1.0" encoding="utf-8"?>

Regular expressions

The Universal Analyzer uses the Boost regular expression engine, with Perl syntax external link. Older releases used the TCL engine. Check the regular expressions in xxxLanguagePattern.xml and xxxCastMetrics.xml:

  • Braces: escape { and } with a backslash outside character sets. For example, to match letters, then blanks, then an opening brace, write [A-Za-z]+[ ]+\{. Inside a character set the backslash is not needed: [A-Za-z$({] is correct.
  • Extended ASCII characters: the \x notation is no longer supported. Use character classes external link instead. For example, to match any letter including accented letters, write [[:alpha:]] instead of [A-Za-z\x80-\xFF].

Metamodel

If the metamodel was created with the Excel file that CAST provided, remove the following line from it:

<tree parent="EnlightenUniversalObjects" category="EnlightenTree"/>

Test the migrated package

Test the migrated package on a non-production CAST Imaging installation before you use it on your applications. Check that it validates, that the analysis runs without syntax errors and that it produces the same results as before.