Home Libraries Author Links

Matchtst: Interactive Test Program
[Match Test]

Collaboration diagram for Matchtst: Interactive Test Program:

Detailed Description

Interactive console C program demonstrating the usage and testing the implementation of pattern matching in strings by means of regular expressions.


Files

file  matchtst.c
 Implementation of an interactive console program demonstrating the usage and testing the implementation of pattern matching in strings by means of regular expressions.

Data Structures

struct  MatchTstEnv
 Match environment. More...

Typedefs

typedef struct MatchTstEnv MatchTstEnv
 Type name of the match environment MatchTstEnv.

Functions

static void defsreact (StmReCtrl reCtrl)
 Definition of regular expression StmRe objects and of qualified regular expression action functions.
static int incLineNumber (StmMtcFctCmd cmd, StmQreMtc qreMtc)
 Qualified regular expression action function for the qualified regular expression action inclnr.
static int out (StmMtcFctCmd cmd, StmQreMtc qreMtc)
 Qualified regular expression action function for the qualified regular expression action out.
static int printIdent (StmMtcFctCmd cmd, StmReMtc reMtc)
 Regular expression action function for the StmRe object ident.
static char * mkCtrl (char *str)
 In-place generation of C escape sequences.
int main (int argc, char **argv)
 Main function implementing the command matchtst.


Typedef Documentation

typedef struct MatchTstEnv MatchTstEnv

Type name of the match environment MatchTstEnv.

Definition at line 174 of file matchtst.c.


Function Documentation

static void defsreact ( StmReCtrl  reCtrl  )  [static]

Definition of regular expression StmRe objects and of qualified regular expression action functions.

Parameters:
reCtrl The StmReCtrl object.
Effects:
The function defines the following named regular expressions and named regular expression action functions for the StmReCtrl object reCtrl.
  • The regular regular expression ident having the syntax of a C identifier. On successful matching it executes the action function printIdent().
  • The regular expression nl representing an arbitary non-empty sequence of end-of-line characters. On successful matching the action function incLineNumber() is executed.
  • The regular expression blank representing an arbitrary non-empty sequence of space and/or tab characters.
  • The regular expression ws representing an arbitrary optionally empty sequence of space and tab characters, of C comments and end-of-line characters.
  • The regular expression comm repraesenting a C comment which may span more than one line.
  • The regular expression subtext defined as follows
                "&xy&:out:&ident&:out:"
    
  • The regular expression text defined as follows
                "&subtext&:out:",
    
  • The regular expression xy defined as follows
                "x|y"
    
  • The regular expression e defined as follows
                "[^.]|&e&%."
    
  • The regular expression a defined as follows
                "[^.]&a&|%."
    
  • The qualified regular expression action inclnr.
  • The qualified regular expression action out.

Definition at line 285 of file matchtst.c.

static int incLineNumber ( StmMtcFctCmd  cmd,
StmQreMtc  qreMtc 
) [static]

Qualified regular expression action function for the qualified regular expression action inclnr.

The function is assigned to the named qualified regular expression action inclnr and increments the line counter env.lnr.

Examples:
matchtst.c.

Definition at line 333 of file matchtst.c.

Referenced by defsreact().

static int out ( StmMtcFctCmd  cmd,
StmQreMtc  qreMtc 
) [static]

Qualified regular expression action function for the qualified regular expression action out.

The function is assigned to the named qualified regular expression action out and prints the text matched.

Definition at line 345 of file matchtst.c.

static int printIdent ( StmMtcFctCmd  cmd,
StmReMtc  reMtc 
) [static]

Regular expression action function for the StmRe object ident.

The function is assigned to the named regular expression "ident" and prints the name of a matching identifier.

Examples:
matchtst.c.

Definition at line 357 of file matchtst.c.

Referenced by defsreact().

static char * mkCtrl ( char *  str  )  [static]

In-place generation of C escape sequences.

The function replaces all occurrences of the character sequences "\\n", "\\t", "\\r" and "\\f" with the characters '\n', '\t', '\r' and '\f', respectively. This replacement occurs in-place.

Examples:
matchtst.c.

Definition at line 368 of file matchtst.c.

int main ( int  argc,
char **  argv 
)

Main function implementing the command matchtst.

Parameters:
[in] argc Argument count. For now no arguments are evaluated.
[in] argv Pointer to an array of argc argument strings followed by an additional NULL array element. For now no arguments are evaluated.
Effects:
In a loop the user is requested to input a string to match and a regular expression string. Input of a single "q" ends the loop and the program. In the regular expression several named regular expressions and actions (see defsreact()) may be contained.
Returns:
0, if no error occurred.

One of the non-null StmReCtrlErrnos enumerators as error number on error.

Main function implementing the command matchtst.

Main function implementing the command dsettst.

Main function implementing the command cuglify.

Parameters:
[in] argc Argument count.
[in] argv Pointer to an array of argc argument strings followed by an additional NULL array element (only used internally).
Returns:
0, if no error occurred.

1, if an error occurred.

Definition at line 87 of file namedconditiontest.c.


© Copyright Tom Michaelis 2002-2007

Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).