TeX in C
Explore TeX with modern c compiler.
PART 22: Input stacks and states

结构体

struct  InStateRecord
 [#300]: InStateRecord(1344) . 更多...
 

宏定义

#define TOKEN_LIST   0
 [p125#307] 更多...
 
#define STATE   cur_input.statefield
 [#302] current scanner state. 更多...
 
#define IINDEX   cur_input.indexfield
 reference for buffer information 更多...
 
#define START   cur_input.startfield
 starting position in buffer 更多...
 
#define LIMIT   cur_input.limitfield
 end of current line in buffer 更多...
 
#define NAME   cur_input.namefield
 name of the current file. 更多...
 
#define MID_LINE   1
 [#303] state code when scanning a line of characters. 更多...
 
#define SKIP_BLANKS   (MAX_CHAR_CODE + 2)
 [#303] state code when ignoring blanks. 更多...
 
#define NEW_LINE   (MAX_CHAR_CODE + MAX_CHAR_CODE + 3)
 [#303] state code at start of line. 更多...
 
#define terminal_input   (NAME == 0)
 [#304] are we reading from the terminal? 更多...
 
#define curfile   (inputfile[IINDEX - 1])
 [#304] the current alphafile variable. 更多...
 
#define token_type   IINDEX
 [p125#307] type of current token list. 更多...
 
#define param_start   LIMIT
 [p125#307] base of macro parameters in paramstack. 更多...
 

枚举

enum  ScannerStatus {
  SKIPPING = 1 , DEFINING , MATCHING , ALIGNING ,
  ABSORBING
}
 [p124#305]: scanner status 更多...
 
enum  TokenType {
  PARAMETER , U_TEMPLATE , V_TEMPLATE , BACKED_UP ,
  INSERTED , MACRO , OUTPUT_TEXT , EVERY_PAR_TEXT ,
  EVERY_MATH_TEXT , EVERY_DISPLAY_TEXT , EVERY_HBOX_TEXT , EVERY_VBOX_TEXT ,
  EVERY_JOB_TEXT , EVERY_CR_TEXT , MARK_TEXT , WRITE_TEXT
}
 [p125#307] 更多...
 

函数

void runaway (void)
 [#306] uses scanner status to print a warning message when a subfile has ended, and at certain other crucial times. 更多...
 
void showcontext (void)
 [#311] prints where the scanner is. 更多...
 
void begin_pseudo_print (char *l)
 [#316] 更多...
 
void set_trick_count ()
 [#316] 更多...
 

变量

InStateRecord inputstack [STACK_SIZE+1]
 [#301]: 更多...
 
UChar inputptr
 [#301]: first unused location of input stack. 更多...
 
static UChar maxinstack
 [#301]: largest value of input ptr when pushing. 更多...
 
InStateRecord cur_input
 xref[]: 35, 36, 87, 301, 302, 311, 321, 322, 534, 1131, error, open_log_file 更多...
 
static UChar inopen
 [#304] the number of lines in the buffer, less one 更多...
 
char openparens
 the number of open text files xref[2, only tex.c]: start_input, final_cleanup 更多...
 
Integer line
 current line number in the current source file. 更多...
 
FILE * inputfile [MAX_IN_OPEN]
 xref[]: start_input 更多...
 
static Integer linestack [MAX_IN_OPEN]
 
char scanner_status
 [#305] can a subfile end now? 更多...
 
Pointer warning_index
 [#305] identifier relevant to non-normal scanner status 更多...
 
Pointer defref
 [#305] reference count of token list being defined 更多...
 
Pointer paramstack [PARAM_SIZE+1]
 [#308] token list pointers for parameters. / xref[only tex.c]: macrocall 更多...
 
int paramptr
 [#308] first unused entry in param stack. / xref[only tex.c]: macrocall 更多...
 
Integer maxparamstack
 [#308] largest value of param ptr, will be ≤ param size + 9 . / xref[only tex.c]: macrocall 更多...
 
Integer align_state
 [#309] group level with respect to current alignment. 更多...
 
UChar baseptr
 [#310] shallowest level shown by show context. 更多...
 

详细描述

宏定义说明

◆ curfile

#define curfile   (inputfile[IINDEX - 1])

[#304] the current alphafile variable.

◆ IINDEX

#define IINDEX   cur_input.indexfield

reference for buffer information

◆ LIMIT

#define LIMIT   cur_input.limitfield

end of current line in buffer

◆ MID_LINE

#define MID_LINE   1

[#303] state code when scanning a line of characters.

◆ NAME

#define NAME   cur_input.namefield

name of the current file.

◆ NEW_LINE

#define NEW_LINE   (MAX_CHAR_CODE + MAX_CHAR_CODE + 3)

[#303] state code at start of line.

◆ param_start

#define param_start   LIMIT

[p125#307] base of macro parameters in paramstack.

◆ SKIP_BLANKS

#define SKIP_BLANKS   (MAX_CHAR_CODE + 2)

[#303] state code when ignoring blanks.

◆ START

#define START   cur_input.startfield

starting position in buffer

◆ STATE

#define STATE   cur_input.statefield

[#302] current scanner state.

  1. MID_LINE is the normal state.
  2. SKIP_BLANKS is like MID_LINE, but blanks are ignored.
  3. NEW_LINE is the state at the beginning of a line.

xref

  • 赋值[16]: 323, 325, 328, 331, 343, 347[3], 349, 352, 353, 354[3], 483, 537,
  • 相等判断[8]: ==: 325, 337, 390, 1335, !=: 311, 312[2], 330, 341,
  • 文本引用[6]: 87, 300, 303, 307, 344, 346,

◆ terminal_input

#define terminal_input   (NAME == 0)

[#304] are we reading from the terminal?

◆ TOKEN_LIST

#define TOKEN_LIST   0

[p125#307]

◆ token_type

#define token_type   IINDEX

[p125#307] type of current token list.

枚举类型说明

◆ ScannerStatus

[p124#305]: scanner status

枚举值
SKIPPING 

when passing conditional text

DEFINING 

when reading a macro definition

MATCHING 

when reading macro arguments

ALIGNING 

when reading an alignment preamble

ABSORBING 

when reading a balanced text

◆ TokenType

enum TokenType

[p125#307]

枚举值
PARAMETER 

parameter

U_TEMPLATE 

<u_j> template

V_TEMPLATE 

<v_j> template

BACKED_UP 

text to be reread

INSERTED 

inserted texts

MACRO 

defined control sequences

OUTPUT_TEXT 

output routines

EVERY_PAR_TEXT 

\everypar

EVERY_MATH_TEXT 

\everymath

EVERY_DISPLAY_TEXT 

\everydisplay

EVERY_HBOX_TEXT 

\everyhbox

EVERY_VBOX_TEXT 

\everyvbox

EVERY_JOB_TEXT 

\everyjob

EVERY_CR_TEXT 

\everycr

MARK_TEXT 

\topmark, etc.

WRITE_TEXT 

\write

函数说明

◆ begin_pseudo_print()

void begin_pseudo_print ( char *  l)

[#316]

◆ runaway()

void runaway ( void  )

[#306] uses scanner status to print a warning message when a subfile has ended, and at certain other crucial times.

◆ set_trick_count()

void set_trick_count ( )

[#316]

◆ showcontext()

void showcontext ( void  )

[#311] prints where the scanner is.

变量说明

◆ align_state

Integer align_state

[#309] group level with respect to current alignment.

◆ baseptr

UChar baseptr

[#310] shallowest level shown by show context.

xref[only tex.c]: error

◆ cur_input

InStateRecord cur_input

xref[]: 35, 36, 87, 301, 302, 311, 321, 322, 534, 1131, error, open_log_file

◆ defref

Pointer defref

[#305] reference count of token list being defined

◆ inopen

UChar inopen
static

[#304] the number of lines in the buffer, less one

◆ inputfile

FILE* inputfile[MAX_IN_OPEN]

xref[]: start_input

◆ inputptr

UChar inputptr

[#301]: first unused location of input stack.

xref[3, only tex.c]: open_log_file, final_cleanup, S1337_Get_the_first_line_of_input_and_prepare_to_start

◆ inputstack

InStateRecord inputstack[STACK_SIZE+1]

[#301]:

xref[2]: only tex.c error, open_log_file

◆ line

Integer line

current line number in the current source file.

◆ linestack

Integer linestack[MAX_IN_OPEN]
static

◆ maxinstack

UChar maxinstack
static

[#301]: largest value of input ptr when pushing.

◆ maxparamstack

Integer maxparamstack

[#308] largest value of param ptr, will be ≤ param size + 9 . / xref[only tex.c]: macrocall

◆ openparens

char openparens

the number of open text files xref[2, only tex.c]: start_input, final_cleanup

◆ paramptr

int paramptr

[#308] first unused entry in param stack. / xref[only tex.c]: macrocall

◆ paramstack

Pointer paramstack[PARAM_SIZE+1]

[#308] token list pointers for parameters. / xref[only tex.c]: macrocall

◆ scanner_status

char scanner_status

[#305] can a subfile end now?

◆ warning_index

Pointer warning_index

[#305] identifier relevant to non-normal scanner status