Dismiss
InnovationQ will be updated on Sunday, Oct. 22, from 10am ET - noon. You may experience brief service interruptions during that time.
Browse Prior Art Database

Software Compiler for Analyzing and Measuring Programs

IP.com Disclosure Number: IPCOM000105735D
Original Publication Date: 1993-Sep-01
Included in the Prior Art Database: 2005-Mar-20
Document File: 6 page(s) / 216K

Publishing Venue

IBM

Related People

Orcutt, CA: AUTHOR

Abstract

The Software Compiler for Analyzing and Measuring Programs (SCAMP) is a code analysis tool that collects various statistics and metrics from a given source code file. The statistics and metrics that are collected as well as the syntax of the source file are all controllable by the user.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 25% of the total text.

Software Compiler for Analyzing and Measuring Programs

      The Software Compiler for Analyzing and Measuring Programs
(SCAMP) is a code analysis tool that collects various statistics and
metrics from a given source code file.  The statistics and metrics
that are collected as well as the syntax of the source file are all
controllable by the user.

      SCAMP accepts two files on input: a programming language source
file and a file containing the grammar which describes the
programming language.  The grammar file is then parsed and read into
internal data structures using the grammar compiler.  Of course, the
grammar file, itself, would have to be syntactically correct, and
full syntax checking on the grammar file is performed.  Depending
upon the type of grammar provided, either the Left-Read Right-Parse
LR(1) or Left-Read Left-Parse LL(1) parser generator is invoked.  The
parser generator uses the data contained in the internal data
structures and creates all of the necessary information required to
parse the input source file.  The parser generator phase is similar
to function provided by Yet Another Compiler Compiler (YACC) and is
covered in many textbooks.

      Once the parser has been generated, it is invoked to parse the
input source file.  As tokens are scanned and parsed, any flags that
have been declared with them are applied.  If the flag is global, the
single count for the entire source file is incremented; if it is
local, the single count for the current local scope is incremented.
If the flag is simple, the token is not saved; if it is ident, the
token is saved.

      If the parser enters an accept state and the last token of the
input source file has been read, then the source file is declared as
being syntactically correct, and a report is generated.  If a syntax
error occurs while parsing the input source file, SCAMP aborts
analysis.  No error recovery is attempted.

      To generate a report, one of several available report
generators is invoked.  Each of the requested metrics will be
contained in the report, in its own section.  Depending upon the
level of detail requested by the user, each section may contain only
the grand total metric value for the entire source file, sub-total
metrics for each local scope of the source file, or sub-sub-total
metrics for each unique token for each local scope of the source file
(with or without line and column number positions of each of the
tokens).  The figure depicts this process.

      The following are the more important special features offered
by SCAMP.  These features are indicated in a grammar file through the
use of pragmas or special flags.

PRE-EMPTIVE NESTED GRAMMARS AND OVERRIDE
   Almost all programming languages will call for one or more
   instances of a pre-emptive nested grammar.  The most common
   application for this feature is for comments.  As the comment
   starting token is read, the normal grammar is pre-emp...