FORM 4.3
Data Structures | Macros | Typedefs | Functions | Variables
compiler.c File Reference
#include "form3.h"

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 ()
 
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 ()
 
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 235 of file compiler.c.

◆ OPTION1

#define OPTION1   2

Definition at line 236 of file compiler.c.

◆ OPTION2

#define OPTION2   3

Definition at line 237 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 248 of file compiler.c.

Function Documentation

◆ inictable()

VOID inictable ( )

Definition at line 292 of file compiler.c.

◆ findcommand()

KEYWORD * findcommand ( UBYTE * in)

Definition at line 318 of file compiler.c.

◆ ParenthesesTest()

int ParenthesesTest ( UBYTE * sin)

Definition at line 362 of file compiler.c.

◆ SkipAName()

UBYTE * SkipAName ( UBYTE * s)

Definition at line 412 of file compiler.c.

◆ IsRHS()

UBYTE * IsRHS ( UBYTE * s,
UBYTE c )

Definition at line 440 of file compiler.c.

◆ IsIdStatement()

int IsIdStatement ( UBYTE * s)

Definition at line 486 of file compiler.c.

◆ CompileAlgebra()

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

Definition at line 500 of file compiler.c.

◆ CompileStatement()

int CompileStatement ( UBYTE * in)

Definition at line 536 of file compiler.c.

◆ TestTables()

int TestTables ( )

Definition at line 650 of file compiler.c.

◆ CompileSubExpressions()

int CompileSubExpressions ( SBYTE * tokens)

Definition at line 694 of file compiler.c.

◆ CodeGenerator()

int CodeGenerator ( SBYTE * tokens)

Definition at line 829 of file compiler.c.

◆ CompleteTerm()

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

Definition at line 1874 of file compiler.c.

◆ CodeFactors()

int CodeFactors ( SBYTE * tokens)

Definition at line 1911 of file compiler.c.

◆ GenerateFactors()

WORD GenerateFactors ( WORD n,
WORD inc )

Definition at line 2208 of file compiler.c.

Variable Documentation

◆ alfatable1

int alfatable1[27]

Definition at line 233 of file compiler.c.

◆ subexpbuffers

SUBBUF* subexpbuffers = 0

Definition at line 244 of file compiler.c.

◆ topsubexpbuffers

SUBBUF* topsubexpbuffers = 0

Definition at line 245 of file compiler.c.

◆ insubexpbuffers

LONG insubexpbuffers = 0

Definition at line 246 of file compiler.c.