FORM v5.0.0-35-g6318119
Data Structures | Macros | Typedefs | Functions | Variables
compiler.c File Reference
#include "form3.h"
#include "comtool.h"
Include dependency graph for compiler.c:

Go to the source code of this file.

Data Structures

struct  SuBbUf
 

Macros

#define OPTION0   1
 
#define OPTION1   2
 
#define OPTION2   3
 
#define REDUCESUBEXPBUFFERS
 

Typedefs

typedef struct SuBbUf SUBBUF
 

Functions

void inictable (void)
 
KEYWORDfindcommand (UBYTE *in)
 
int ParenthesesTest (UBYTE *sin)
 
UBYTE * SkipAName (UBYTE *s)
 
UBYTE * IsRHS (UBYTE *s, UBYTE c)
 
int IsIdStatement (UBYTE *s)
 
int CompileAlgebra (UBYTE *s, int leftright, WORD *prototype)
 
int CompileStatement (UBYTE *in)
 
int TestTables (void)
 
int CompileSubExpressions (SBYTE *tokens)
 
int CodeGenerator (SBYTE *tokens)
 
int CompleteTerm (WORD *term, UWORD *numer, UWORD *denom, WORD nnum, WORD nden, int sign)
 
int CodeFactors (SBYTE *tokens)
 
WORD GenerateFactors (WORD n, WORD inc)
 

Variables

int alfatable1 [27]
 
SUBBUFsubexpbuffers = 0
 
SUBBUFtopsubexpbuffers = 0
 
LONG insubexpbuffers = 0
 

Detailed Description

The heart of the compiler. It contains the tables of statements. It finds the statements in the tables and calls the proper routines. For algebraic expressions it runs the compilation by first calling the tokenizer, splitting things into subexpressions and generating the code. There is a system for recognizing already existing subexpressions. This economizes on the length of the output.

Note: the compiler of FORM doesn't attempt to normalize the input. Hence x+1 and 1+x are different objects during compilation. Similarly (a+b-b) will not be simplified to (a).

Definition in file compiler.c.

Macro Definition Documentation

◆ OPTION0

#define OPTION0   1

Definition at line 260 of file compiler.c.

◆ OPTION1

#define OPTION1   2

Definition at line 261 of file compiler.c.

◆ OPTION2

#define OPTION2   3

Definition at line 262 of file compiler.c.

◆ REDUCESUBEXPBUFFERS

#define REDUCESUBEXPBUFFERS
Value:
{ if ( (topsubexpbuffers-subexpbuffers) > 256 ) {\
M_free(subexpbuffers,"subexpbuffers");\
subexpbuffers = (SUBBUF *)Malloc1(256*sizeof(SUBBUF),"subexpbuffers");\
topsubexpbuffers = subexpbuffers+256; } insubexpbuffers = 0; }

Definition at line 273 of file compiler.c.

Function Documentation

◆ inictable()

void inictable ( void  )

Definition at line 315 of file compiler.c.

◆ findcommand()

KEYWORD * findcommand ( UBYTE *  in)

Definition at line 341 of file compiler.c.

◆ ParenthesesTest()

int ParenthesesTest ( UBYTE *  sin)

Definition at line 385 of file compiler.c.

◆ SkipAName()

UBYTE * SkipAName ( UBYTE *  s)

Skips a name and gives a pointer to the character after the name. If there is not a proper name, it emits a compiler message and then returns a null pointer. This function supports formal names (e.g., [x+a]) and $-variables in addition to ordinary identifiers.

Note
The brackets are assumed to be matched already.
Parameters
[in]sPointer to a null-terminated input string that starts with a name.
Returns
Pointer to the character after the name, or a null pointer if the name is invalid.

Definition at line 443 of file compiler.c.

◆ IsRHS()

UBYTE * IsRHS ( UBYTE *  s,
UBYTE  c 
)

Definition at line 476 of file compiler.c.

◆ IsIdStatement()

int IsIdStatement ( UBYTE *  s)

Definition at line 522 of file compiler.c.

◆ CompileAlgebra()

int CompileAlgebra ( UBYTE *  s,
int  leftright,
WORD *  prototype 
)

Definition at line 536 of file compiler.c.

◆ CompileStatement()

int CompileStatement ( UBYTE *  in)

Definition at line 572 of file compiler.c.

◆ TestTables()

int TestTables ( void  )

Definition at line 706 of file compiler.c.

◆ CompileSubExpressions()

int CompileSubExpressions ( SBYTE *  tokens)

Definition at line 750 of file compiler.c.

◆ CodeGenerator()

int CodeGenerator ( SBYTE *  tokens)

Definition at line 885 of file compiler.c.

◆ CompleteTerm()

int CompleteTerm ( WORD *  term,
UWORD *  numer,
UWORD *  denom,
WORD  nnum,
WORD  nden,
int  sign 
)

Definition at line 1948 of file compiler.c.

◆ CodeFactors()

int CodeFactors ( SBYTE *  tokens)

Definition at line 1985 of file compiler.c.

◆ GenerateFactors()

WORD GenerateFactors ( WORD  n,
WORD  inc 
)

Definition at line 2282 of file compiler.c.

Variable Documentation

◆ alfatable1

int alfatable1[27]

Definition at line 258 of file compiler.c.

◆ subexpbuffers

SUBBUF* subexpbuffers = 0

Definition at line 269 of file compiler.c.

◆ topsubexpbuffers

SUBBUF* topsubexpbuffers = 0

Definition at line 270 of file compiler.c.

◆ insubexpbuffers

LONG insubexpbuffers = 0

Definition at line 271 of file compiler.c.