Back to index

tetex-bin  3.0
Defines | Functions | Variables
routines.c File Reference
#include <kpathsea/config.h>
#include <kpathsea/types.h>
#include <kpathsea/c-proto.h>
#include <kpathsea/c-std.h>
#include "routines.h"
#include "otp.h"

Go to the source code of this file.

Defines

#define out_ptr   (states[cur_state].length)
#define out_array   (states[cur_state].instrs)

Functions

list cons P2C (int, x, list, L)
list list1 P1C (int, x)
list list2 P2C (int, x, int, y)
list append P2C (list, K, list, L)
list append1 P2C (list, L, int, x)
llist lcons P2C (left, x, llist, L)
llist llist1 P1C (left, x)
llist llist2 P2C (left, x, left, y)
llist lappend P2C (llist, K, llist, L)
llist lappend1 P2C (llist, L, left, x)
left WildCard P1H (void)
left StringLeft P1C (char *, x)
left ChoiceLeft P1C (llist, L)
left PlusLeft P2C (left, l, int, n)
left CompleteLeft P3C (left, l, int, n, int, m)
list gen_left P1C (left, arg)
void store_alias P2C (string, str, left, l)
left lookup_alias P1C (string, str)
void fill_in P1C (list, L)
void out_right P2C (int, instr, int, val)
void store_table P2C (string, str, int, len)

Variables

list left_false_holes
int left_state
int right_offset
int input_bytes
int output_bytes
int no_states = 0
int cur_state = 0
int room_for_states = 0
state_type states [100]
int no_tables = 0
int cur_table = 0
int room_for_tables = 0
table_type tables [100]
int no_aliases = 0
alias_pair aliases [1000]

Define Documentation

#define out_array   (states[cur_state].instrs)

Definition at line 32 of file routines.c.

#define out_ptr   (states[cur_state].length)

Definition at line 31 of file routines.c.


Function Documentation

void add_to_table P1C ( int  ,
x   
)

Definition at line 65 of file routines.c.

{
list temp;
temp = (list) malloc(sizeof(cell));
temp->val = x;
temp->ptr = nil;
return temp;
}
llist llist1 P1C ( left  ,
x   
)

Definition at line 111 of file routines.c.

{
llist temp;
temp = (llist) malloc(sizeof(lcell));
temp->val = x;
temp->ptr = nil;
return temp;
}
left StringLeft P1C ( char *  ,
x   
)

Definition at line 156 of file routines.c.

{
left temp;
temp = (left) malloc(sizeof(lft_cell));
temp->kind=STRINGLEFT;
temp->valstr=x;
return temp;
}
void out_left P1C ( llist  ,
L   
)

Definition at line 187 of file routines.c.

{
left temp;
temp = (left) malloc(sizeof(lft_cell));
temp->kind=CHOICELEFT;
temp->more_lefts=L;
return temp;
}
list gen_left P1C ( left  ,
arg   
)

Definition at line 248 of file routines.c.

{
int save_ptr, k;
list holes, false_holes, true_holes, backup_holes;
char *runner;
llist p;

switch(arg->kind) {
case WILDCARD:
       return nil;
case STRINGLEFT:
        runner=arg->valstr;
        holes=nil;
       while (*runner) {
              out_int(OTP_GOTO_NE, *runner);
              out_int(0, 0);
              holes=cons(out_ptr-1,holes);
              runner++;
              if (*runner) {
                     out_int(OTP_GOTO_NO_ADVANCE, 0);
                     holes = cons(out_ptr-1, holes);
              }
       }
       return holes;
case SINGLELEFT:
       out_int(OTP_GOTO_NE, arg->val1);
       out_int(0, 0);
       return list1(out_ptr-1);
case DOUBLELEFT:
       out_int(OTP_GOTO_LT, arg->val1);
       out_int(0, 0);
       save_ptr = out_ptr;
       out_int(OTP_GOTO_GT, arg->val2);
       out_int(0, 0);
       return list2(save_ptr-1, out_ptr-1);
case CHOICELEFT:
       true_holes=nil;
       false_holes=nil;
       p=arg->more_lefts;
       while (p!=nil) {
              false_holes = gen_left(p->val);
              if (p->ptr) {
                     out_int(OTP_GOTO, 0);
                     true_holes=cons(out_ptr-1, true_holes);
                     fill_in(false_holes);
              }
              p=p->ptr;
       }
       fill_in(true_holes);
       return false_holes;
case NOTCHOICELEFT:
       true_holes=nil;
       p=arg->more_lefts;
       while (p!=nil) {
              false_holes = gen_left(p->val);
              out_int(OTP_GOTO, 0);
              true_holes=cons(out_ptr-1, true_holes);
              fill_in(false_holes);
              p=p->ptr;
       }
       return true_holes;
case PLUSLEFT:
       false_holes=nil;
       true_holes=nil;
       backup_holes=nil;
       k=1;
       while (k<arg->val1) {
              holes = gen_left(arg->one_left);
              false_holes = append(false_holes, holes);
              out_int(OTP_GOTO_NO_ADVANCE, 0);
              false_holes = cons(out_ptr-1, false_holes);
              k++;
       }
       holes=gen_left(arg->one_left);
       false_holes = append(false_holes, holes);
       save_ptr = out_ptr;
       out_int(OTP_GOTO_NO_ADVANCE, 0);
       true_holes=cons(out_ptr-1, true_holes);
       backup_holes=gen_left(arg->one_left);
       out_int(OTP_GOTO, save_ptr);
       fill_in(backup_holes);
       out_int(OTP_LEFT_BACKUP, 0);
       fill_in(true_holes);
       return false_holes;
case COMPLETELEFT:
       false_holes=nil;
       true_holes=nil;
       backup_holes=nil;
       k=1;
       if (arg->val1 > arg->val2) {
              return nil;
       }
       while (k<=arg->val1) {
              holes = gen_left(arg->one_left);
              false_holes = append(false_holes, holes);
              out_int(OTP_GOTO_NO_ADVANCE, 0);
              false_holes = cons(out_ptr-1, false_holes);
              k++;
       }
       while (k<arg->val2) {
              holes = gen_left(arg->one_left);
              true_holes = append(true_holes, holes);
              out_int(OTP_GOTO_NO_ADVANCE, 0);
              backup_holes = cons(out_ptr-1, backup_holes);
              k++;
       }
       holes = gen_left(arg->one_left);
       true_holes = append(true_holes, holes);
       out_int(OTP_GOTO, out_ptr+2);
       fill_in(true_holes);
       out_int(OTP_LEFT_BACKUP, 0);
       fill_in(backup_holes);
       return false_holes;
case BEGINNINGLEFT:
       out_int(OTP_GOTO_BEG, 0);
       true_holes=list1(out_ptr-1);
       out_int(OTP_GOTO, 0);
       false_holes=list1(out_ptr-1);
       fill_in(true_holes);
       return false_holes;
case ENDLEFT:
       out_int(OTP_GOTO_END, 0);
       true_holes=list1(out_ptr-1);
       out_int(OTP_GOTO, 0);
       false_holes=list1(out_ptr-1);
       fill_in(true_holes);
       return false_holes;
default:
       fprintf(stderr, "Unrecognized left: %d\n", arg->kind);
       exit(EXIT_FAILURE);
}
}

Here is the call graph for this function:

int lookup_table P1C ( string  ,
str   
)

Definition at line 397 of file routines.c.

{
int i;
for (i=0; i<no_aliases; i++) {
    if (!strcmp(str,aliases[i].str)) {
        return aliases[i].left_val;
    }
}
fprintf(stderr, "state %s not defined\n", str);
exit(EXIT_FAILURE);
}

Here is the call graph for this function:

void fill_in P1C ( list  ,
L   
)

Definition at line 442 of file routines.c.

{
list p;
p=L;
while (p!=0) {
    out_array[p->val] = out_array[p->val] + out_ptr;
    p=p->ptr;
}
}
left WildCard P1H ( void  ) [read]

Definition at line 147 of file routines.c.

{
left temp;
temp = (left) malloc(sizeof(lft_cell));
temp->kind=WILDCARD;
return temp;
}
list cons P2C ( int  ,
x  ,
list  ,
L   
)

Definition at line 55 of file routines.c.

{
list temp;
temp = (list) malloc(sizeof(cell));
temp->val = x;
temp->ptr = L;
return temp;
}
left DoubleLeft P2C ( int  ,
x  ,
int  ,
y   
)

Definition at line 75 of file routines.c.

{
list temp, temp1;
temp = (list) malloc(sizeof(cell));
temp1 = (list) malloc(sizeof(cell));
temp->val = x;
temp->ptr = temp1;
temp1->val = y;
temp1->ptr = nil;
return temp;
}
list append P2C ( list  ,
,
list  ,
L   
)

Definition at line 88 of file routines.c.

{
if (K==nil) return L;
return cons(K->val, append(K->ptr, L));
}

Here is the call graph for this function:

list append1 P2C ( list  ,
L  ,
int  ,
x   
)

Definition at line 95 of file routines.c.

{
return (append(L,list1(x)));
}

Here is the call graph for this function:

llist lcons P2C ( left  ,
x  ,
llist  ,
L   
)

Definition at line 101 of file routines.c.

{
llist temp;
temp = (llist) malloc(sizeof(lcell));
temp->val = x;
temp->ptr = L;
return temp;
}
llist llist2 P2C ( left  ,
x  ,
left  ,
y   
)

Definition at line 121 of file routines.c.

{
llist temp, temp1;
temp = (llist) malloc(sizeof(lcell));
temp1 = (llist) malloc(sizeof(lcell));
temp->val = x;
temp->ptr = temp1;
temp1->val = y;
temp1->ptr = nil;
return temp;
}
llist lappend P2C ( llist  ,
,
llist  ,
L   
)

Definition at line 134 of file routines.c.

{
if (K==nil) return L;
return lcons(K->val, lappend(K->ptr, L));
}

Here is the call graph for this function:

llist lappend1 P2C ( llist  ,
L  ,
left  ,
x   
)

Definition at line 141 of file routines.c.

{
return (lappend(L,llist1(x)));
}
left PlusLeft P2C ( left  ,
,
int  ,
n   
)

Definition at line 207 of file routines.c.

{
left temp;
temp = (left) malloc(sizeof(lft_cell));
temp->kind=PLUSLEFT;
temp->one_left=l;
temp->val1=n;
return temp;
}
void store_alias P2C ( string  ,
str  ,
left  ,
 
)

Definition at line 382 of file routines.c.

{
int i;
for (i=0; i<no_aliases; i++) {
    if (!strcmp(str,aliases[i].str)) {
        fprintf(stderr, "alias %s already defined\n", str);
        exit(1);
    }
}
aliases[i].str=xstrdup(str);
aliases[i].left_val=l;
no_aliases++;
}

Here is the call graph for this function:

void out_int P2C ( int  ,
instr  ,
int  ,
val   
)

Definition at line 453 of file routines.c.

{
out_int(instr+right_offset, val);
}

Here is the call graph for this function:

void store_table P2C ( string  ,
str  ,
int  ,
len   
)

Definition at line 513 of file routines.c.

{
int i;
for (i=0; i<no_tables; i++) {
    if (!strcmp(str,tables[i].str)) {
        fprintf(stderr, "table %s already defined\n", str);
        exit(EXIT_FAILURE);
    }
}
tables[i].str=xstrdup(str);
tables[i].length=0;
cur_table=i;
no_tables++;
}

Here is the call graph for this function:

left CompleteLeft P3C ( left  ,
,
int  ,
n  ,
int  ,
 
)

Definition at line 218 of file routines.c.

{
left temp;
temp = (left) malloc(sizeof(lft_cell));
temp->kind=COMPLETELEFT;
temp->one_left=l;
temp->val1=n;
temp->val2=m;
return temp;
}

Variable Documentation

Definition at line 52 of file routines.c.

Definition at line 42 of file routines.c.

Definition at line 47 of file routines.c.

Definition at line 38 of file routines.c.

Definition at line 34 of file routines.c.

Definition at line 36 of file routines.c.

Definition at line 51 of file routines.c.

Definition at line 41 of file routines.c.

Definition at line 46 of file routines.c.

Definition at line 39 of file routines.c.

Definition at line 37 of file routines.c.

Definition at line 43 of file routines.c.

Definition at line 48 of file routines.c.

Definition at line 44 of file routines.c.

Definition at line 49 of file routines.c.