FORM  4.2
Macros | Functions
pattern.c File Reference
#include "form3.h"

Go to the source code of this file.

Macros

#define PutInBuffers(pow)
 

Functions

WORD TestMatch (PHEAD WORD *term, WORD *level)
 
VOID Substitute (PHEAD WORD *term, WORD *pattern, WORD power)
 
WORD FindAll (PHEAD WORD *term, WORD *pattern, WORD level, WORD *par)
 
int TestSelect (WORD *term, WORD *setp)
 
VOID SubsInAll (PHEAD0)
 
VOID TransferBuffer (int from, int to, int spectator)
 
int TakeIDfunction (PHEAD WORD *term)
 

Detailed Description

Top level pattern matching routines. More pattern matching is found in findpat.c, function.c, symmetr.c and smart.c. The last three files contain the matching inside functions. The file pattern.c contains also the very important routine Substitute. All regular pattern matching is just the finding of the pattern and indicating what are the wildcards etc. The routine Substitute does the actual removal of the pattern and replaces it by a subterm of the type SUBEXPRESSION.

Definition in file pattern.c.

Macro Definition Documentation

◆ PutInBuffers

#define PutInBuffers (   pow)
Value:
AddRHS(AT.ebufnum,1); \
*out++ = SUBEXPRESSION; \
*out++ = SUBEXPSIZE; \
*out++ = C->numrhs; \
*out++ = pow; \
*out++ = AT.ebufnum; \
FILLSUB(out) \
r = AT.pWorkSpace[rhs+i]; \
if ( *r > 0 ) { \
oldinr = r[*r]; r[*r] = 0; \
AddNtoC(AT.ebufnum,(*r+1-ARGHEAD),(r+ARGHEAD),14); \
r[*r] = oldinr; \
} \
else { \
ToGeneral(r,buffer,1); \
buffer[buffer[0]] = 0; \
AddNtoC(AT.ebufnum,buffer[0]+1,buffer,15); \
}
WORD * AddRHS(int num, int type)
Definition: comtool.c:214

Definition at line 2193 of file pattern.c.

Function Documentation

◆ TestMatch()

WORD TestMatch ( PHEAD WORD *  term,
WORD *  level 
)

This routine governs the pattern matching. If it decides that a substitution should be made, this can be either the insertion of a right hand side (C->rhs) or the automatic generation of terms as a result of an operation (like trace). The object to be replaced is removed from term and a subexpression pointer is inserted. If the substitution is made more than once there can be more subexpression pointers. Its number is positive as it corresponds to the level at which the C->rhs can be found in the compiler output. The subexpression pointer contains the wildcard substitution information. The power is found in *AT.TMout. For operations the subexpression pointer is negative and corresponds to an address in the array AT.TMout. In this array are then the instructions for the routine to be called and its number in the array 'Operations' The format is here: length,functionnumber,length-2 parameters

There is a certain complexity wrt repeat levels. Another complication is the poking of the wildcard values in the subexpression prototype in the compiler buffer. This was how things were done in the past with sequential FORM, but with the advent of TFORM this cannot be maintained. Now, for TFORM we make a copy of it. 7-may-2008 (JV): We cannot yet guarantee that this has been done 100% correctly. There are errors that occur in TFORM only and that may indicate problems.

Definition at line 97 of file pattern.c.