This page describes version 1.6 of the SMEGenerator.
Currently, the best reference manual for the LSME specification language is in our paper. An initial language reference manual is available here. Hopefully, this will become better soon.
SMEGenerator may be used to generate either a set of deterministic finite state machines for scanning, or a single non-deterministic finite state machine. The older, non-deterministic machine, is kept for compatability tests. A flag is used to select the kind of finite state machine desired. By default, the deterministic finite state machines are generated.
The pattern and actions used to extract a source model are dependent, in part, on the language and style of coding used in the system's source code. To illustrate the basic features of the SMEGenerator, we use the following example of extracting include information from C source and header files (i.e., .c and .h files). The scanner generated from these patterns may be used to scan both the source and header files.
(The scanning of include information could be easily accomplished using a simpler lexical tool like grep. It is used as an example here because of its simplicity. For examples that demonstrate more of the unique capabilities of the lexical source model extrator, see a paper describing the tool.)
The desired source model is a stream of output consisting of:
filenameincludesfilename
The specification file consists of (lines beginning with # are comment lines):
# The patterns are attached to a hierarchical description of
# the software structure.
#
# We start by scanning a file. The <file> introduces a
# variable named file.
file <file>
# Then once we are scanning a file, we want to look for include
# statements. The %% bracket a pattern.
file.import
%
\#include ( \< | " ) <filename> @
# We pass in the name of the file being scanned as the \n
# first argument to the scanning program \n
file := getArgument(1) \n
write ( file, " includes ", filename ) \n
@ ( \> | " )
%
Next, we generate the scanning program:
SMEGenerator -s specFile > imports.icn
Finally, we use the icon translater (icont) to scan a .C file and output the source model.
icont imports.icn -x < aCFile
Comments to
murphy@cs.ubc.ca