File: process.c

package info (click to toggle)
icmake 6.22-7
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,148 kB
  • ctags: 1,042
  • sloc: ansic: 9,241; makefile: 1,134; sh: 235; asm: 126
file content (77 lines) | stat: -rw-r--r-- 1,981 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
\funcref{process}{void process (\params)}
    {
        {LEXER\_} {token} {input token to process}
    }
    {}
    {popfile(), finddef()}
    {lexer()}
    {process.c}
    {
        Function {\em process()} is called from {\em main()} with as argument
        the token as read by {\em lexer()}. Depending on the token, several
        actions are performed by {\em process()}:

        \begin{itemize}

            \item Token {\em l\_eof} signals the end of the processed file.
            {\em popfile()} is called to close the file etc..

            \item Token {\em l\_ident} signals an identifer. {\em process()}
            scans the symbol table {\em defined} to check if the identifier was
            redefined; if so, the redefinition string is written to the output
            file. If not, the identifer itself is written to the output file.

            \item All other tokens signal `ordinary' input. The sematic value
            of the tokens, as stored by {\em lexer()} in the buffer {\em
            lexbuf}, is written to the output file.

        \end{itemize}
    }
*/

#include "icm-pp.h"

void process (LEXER_ token)
{
    register int
        i;

    switch (token)
    {
        case l_eof:
	    if (! output_active)
		error ("%s: end-of-file inside #if(n)def",
		       filestack [filesp].n);
	    popfile ();
	    break;
        case l_space:
	    fputc (lexbuf [0], outfile);
            break;
        case l_string:
	    if (output_active)
	    {
		fputc ('\"', outfile);
		fputs (lexbuf, outfile);
		fputc ('\"', outfile);
	    }
            break;
        case l_single:
	    if (output_active)
		fputc (lexbuf [0], outfile);
            break;
        case l_ident:
	    if (output_active)
	    {
		if ( (i = finddef (lexbuf)) != -1 )
		    fputs (defined [i].redef, outfile);
		else
		    fputs (lexbuf, outfile);
	    }
            break;
        case l_other:
	    if (output_active)
		fputs (lexbuf, outfile);
            break;
    }
}