2 * This is a really stupid C tokenizer. It doesn't do any include
3 * files or anything complex at all. That's the preprocessor.
5 * Copyright (C) 2003 Transmeta Corp.
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
42 int input_stream_nr
= 0;
43 struct stream
*input_streams
;
44 static int input_streams_allocated
;
45 unsigned int tabstop
= 8;
47 #define BUFSIZE (8192)
52 int newline
, whitespace
;
53 struct token
**tokenlist
;
55 unsigned char *buffer
;
58 const char *stream_name(int stream
)
60 if (stream
< 0 || stream
> input_stream_nr
)
61 return "<bad stream>";
62 return input_streams
[stream
].name
;
65 static struct position
stream_pos(stream_t
*stream
)
69 pos
.stream
= stream
->nr
;
70 pos
.newline
= stream
->newline
;
71 pos
.whitespace
= stream
->whitespace
;
72 pos
.pos
= stream
->pos
;
73 pos
.line
= stream
->line
;
78 const char *show_special(int val
)
80 static char buffer
[4];
84 if (val
>= SPECIAL_BASE
)
85 strcpy(buffer
, (char *) combinations
[val
- SPECIAL_BASE
]);
89 const char *show_ident(const struct ident
*ident
)
91 static char buffer
[256];
94 sprintf(buffer
, "%.*s", ident
->len
, ident
->name
);
98 static char *charstr(char *ptr
, unsigned char c
, unsigned char escape
, unsigned char next
)
101 if (c
== escape
|| c
== '\\')
116 return ptr
+ sprintf(ptr
, "%o", c
);
118 return ptr
+ sprintf(ptr
, "%03o", c
);
121 const char *show_string(const struct string
*string
)
123 static char buffer
[4 * MAX_STRING
+ 3];
128 return "<bad_string>";
131 for (i
= 0; i
< string
->length
-1; i
++) {
132 const char *p
= string
->data
+ i
;
133 ptr
= charstr(ptr
, p
[0], '"', p
[1]);
140 static const char *show_char(const char *s
, size_t len
, char prefix
, char delim
)
142 static char buffer
[MAX_STRING
+ 4];
154 static const char *quote_char(const char *s
, size_t len
, char prefix
, char delim
)
156 static char buffer
[2*MAX_STRING
+ 6];
164 for (i
= 0; i
< len
; i
++) {
165 if (s
[i
] == '"' || s
[i
] == '\\')
176 const char *show_token(const struct token
*token
)
178 static char buffer
[256];
182 switch (token_type(token
)) {
184 return "syntax error";
187 return "end-of-input";
190 return show_ident(token
->ident
);
193 return token
->number
;
196 return show_special(token
->special
);
199 return show_char(token
->string
->data
,
200 token
->string
->length
- 1, 0, '\'');
201 case TOKEN_CHAR_EMBEDDED_0
... TOKEN_CHAR_EMBEDDED_3
:
202 return show_char(token
->embedded
,
203 token_type(token
) - TOKEN_CHAR
, 0, '\'');
204 case TOKEN_WIDE_CHAR
:
205 return show_char(token
->string
->data
,
206 token
->string
->length
- 1, 'L', '\'');
207 case TOKEN_WIDE_CHAR_EMBEDDED_0
... TOKEN_WIDE_CHAR_EMBEDDED_3
:
208 return show_char(token
->embedded
,
209 token_type(token
) - TOKEN_WIDE_CHAR
, 'L', '\'');
211 return show_char(token
->string
->data
,
212 token
->string
->length
- 1, 0, '"');
213 case TOKEN_WIDE_STRING
:
214 return show_char(token
->string
->data
,
215 token
->string
->length
- 1, 'L', '"');
217 case TOKEN_STREAMBEGIN
:
218 sprintf(buffer
, "<beginning of '%s'>", stream_name(token
->pos
.stream
));
221 case TOKEN_STREAMEND
:
222 sprintf(buffer
, "<end of '%s'>", stream_name(token
->pos
.stream
));
226 sprintf(buffer
, "<untaint>");
229 case TOKEN_ARG_COUNT
:
230 sprintf(buffer
, "<argcnt>");
234 sprintf(buffer
, "unhandled token type '%d' ", token_type(token
));
239 const char *quote_token(const struct token
*token
)
241 static char buffer
[256];
243 switch (token_type(token
)) {
245 return "syntax error";
248 return show_ident(token
->ident
);
251 return token
->number
;
254 return show_special(token
->special
);
257 return quote_char(token
->string
->data
,
258 token
->string
->length
- 1, 0, '\'');
259 case TOKEN_CHAR_EMBEDDED_0
... TOKEN_CHAR_EMBEDDED_3
:
260 return quote_char(token
->embedded
,
261 token_type(token
) - TOKEN_CHAR
, 0, '\'');
262 case TOKEN_WIDE_CHAR
:
263 return quote_char(token
->string
->data
,
264 token
->string
->length
- 1, 'L', '\'');
265 case TOKEN_WIDE_CHAR_EMBEDDED_0
... TOKEN_WIDE_CHAR_EMBEDDED_3
:
266 return quote_char(token
->embedded
,
267 token_type(token
) - TOKEN_WIDE_CHAR
, 'L', '\'');
269 return quote_char(token
->string
->data
,
270 token
->string
->length
- 1, 0, '"');
271 case TOKEN_WIDE_STRING
:
272 return quote_char(token
->string
->data
,
273 token
->string
->length
- 1, 'L', '"');
275 sprintf(buffer
, "unhandled token type '%d' ", token_type(token
));
280 #define HASHED_INPUT_BITS (6)
281 #define HASHED_INPUT (1 << HASHED_INPUT_BITS)
282 #define HASH_PRIME 0x9e370001UL
284 static int input_stream_hashes
[HASHED_INPUT
] = { [0 ... HASHED_INPUT
-1] = -1 };
286 int *hash_stream(const char *name
)
291 while ((c
= *name
++) != 0)
292 hash
= (hash
+ (c
<< 4) + (c
>> 4)) * 11;
295 hash
>>= 32 - HASHED_INPUT_BITS
;
296 return input_stream_hashes
+ hash
;
299 int init_stream(const char *name
, int fd
, const char **next_path
)
301 int stream
= input_stream_nr
, *hash
;
302 struct stream
*current
;
304 if (stream
>= input_streams_allocated
) {
305 int newalloc
= stream
* 4 / 3 + 10;
306 input_streams
= realloc(input_streams
, newalloc
* sizeof(struct stream
));
308 die("Unable to allocate more streams space");
309 input_streams_allocated
= newalloc
;
311 current
= input_streams
+ stream
;
312 memset(current
, 0, sizeof(*current
));
313 current
->name
= name
;
315 current
->next_path
= next_path
;
316 current
->path
= NULL
;
317 current
->constant
= CONSTANT_FILE_MAYBE
;
318 input_stream_nr
= stream
+1;
319 hash
= hash_stream(name
);
320 current
->next_stream
= *hash
;
325 static struct token
* alloc_token(stream_t
*stream
)
327 struct token
*token
= __alloc_token(0);
328 token
->pos
= stream_pos(stream
);
333 * Argh... That was surprisingly messy - handling '\r' complicates the
336 static int nextchar_slow(stream_t
*stream
)
338 int offset
= stream
->offset
;
339 int size
= stream
->size
;
341 int spliced
= 0, had_cr
, had_backslash
;
344 had_cr
= had_backslash
= 0;
347 if (offset
>= size
) {
350 size
= read(stream
->fd
, stream
->buffer
, BUFSIZE
);
354 stream
->offset
= offset
= 0;
357 c
= stream
->buffer
[offset
++];
367 if (!had_backslash
) {
370 stream
->pos
+= tabstop
- stream
->pos
% tabstop
;
395 stream
->offset
= offset
;
411 warning(stream_pos(stream
), "no newline at end of file");
413 warning(stream_pos(stream
), "backslash-newline at end of file");
418 * We want that as light as possible while covering all normal cases.
419 * Slow path (including the logics with line-splicing and EOF sanity
420 * checks) is in nextchar_slow().
422 static inline int nextchar(stream_t
*stream
)
424 int offset
= stream
->offset
;
426 if (offset
< stream
->size
) {
427 int c
= stream
->buffer
[offset
++];
428 static const char special
[256] = {
429 ['\t'] = 1, ['\r'] = 1, ['\n'] = 1, ['\\'] = 1
432 stream
->offset
= offset
;
437 return nextchar_slow(stream
);
440 struct token eof_token_entry
;
442 static struct token
*mark_eof(stream_t
*stream
)
446 end
= alloc_token(stream
);
447 token_type(end
) = TOKEN_STREAMEND
;
448 end
->pos
.newline
= 1;
450 eof_token_entry
.next
= &eof_token_entry
;
451 eof_token_entry
.pos
.newline
= 1;
453 end
->next
= &eof_token_entry
;
454 *stream
->tokenlist
= end
;
455 stream
->tokenlist
= NULL
;
459 static void add_token(stream_t
*stream
)
461 struct token
*token
= stream
->token
;
463 stream
->token
= NULL
;
465 *stream
->tokenlist
= token
;
466 stream
->tokenlist
= &token
->next
;
469 static void drop_token(stream_t
*stream
)
471 stream
->newline
|= stream
->token
->pos
.newline
;
472 stream
->whitespace
|= stream
->token
->pos
.whitespace
;
473 stream
->token
= NULL
;
486 static const long cclass
[257] = {
487 ['0' + 1 ... '7' + 1] = Digit
| Hex
, /* \<octal> */
488 ['8' + 1 ... '9' + 1] = Digit
| Hex
,
489 ['A' + 1 ... 'D' + 1] = Letter
| Hex
,
490 ['E' + 1] = Letter
| Hex
| Exp
, /* E<exp> */
491 ['F' + 1] = Letter
| Hex
,
492 ['G' + 1 ... 'O' + 1] = Letter
,
493 ['P' + 1] = Letter
| Exp
, /* P<exp> */
494 ['Q' + 1 ... 'Z' + 1] = Letter
,
495 ['a' + 1 ... 'b' + 1] = Letter
| Hex
, /* \a, \b */
496 ['c' + 1 ... 'd' + 1] = Letter
| Hex
,
497 ['e' + 1] = Letter
| Hex
| Exp
,/* \e, e<exp> */
498 ['f' + 1] = Letter
| Hex
, /* \f */
499 ['g' + 1 ... 'm' + 1] = Letter
,
500 ['n' + 1] = Letter
, /* \n */
502 ['p' + 1] = Letter
| Exp
, /* p<exp> */
504 ['r' + 1] = Letter
, /* \r */
506 ['t' + 1] = Letter
, /* \t */
508 ['v' + 1] = Letter
, /* \v */
510 ['x' + 1] = Letter
, /* \x<hex> */
511 ['y' + 1 ... 'z' + 1] = Letter
,
513 ['.' + 1] = Dot
| ValidSecond
,
514 ['=' + 1] = ValidSecond
,
515 ['+' + 1] = ValidSecond
,
516 ['-' + 1] = ValidSecond
,
517 ['>' + 1] = ValidSecond
,
518 ['<' + 1] = ValidSecond
,
519 ['&' + 1] = ValidSecond
,
520 ['|' + 1] = ValidSecond
,
521 ['#' + 1] = ValidSecond
,
531 * pp-number identifier-nodigit
538 static int get_one_number(int c
, int next
, stream_t
*stream
)
541 static char buffer
[4095];
542 char *p
= buffer
, *buf
, *buffer_end
= buffer
+ sizeof (buffer
);
547 long class = cclass
[next
+ 1];
548 if (!(class & (Dot
| Digit
| Letter
)))
552 next
= nextchar(stream
);
554 if (next
== '-' || next
== '+') {
557 next
= nextchar(stream
);
562 if (p
== buffer_end
) {
563 sparse_error(stream_pos(stream
), "number token exceeds %td characters",
564 buffer_end
- buffer
);
565 // Pretend we saw just "1".
572 buf
= __alloc_bytes(len
);
573 memcpy(buf
, buffer
, len
);
575 token
= stream
->token
;
576 token_type(token
) = TOKEN_NUMBER
;
583 static int eat_string(int next
, stream_t
*stream
, enum token_type type
)
585 static char buffer
[MAX_STRING
];
586 struct string
*string
;
587 struct token
*token
= stream
->token
;
591 char delim
= type
< TOKEN_STRING
? '\'' : '"';
593 for (escape
= 0; escape
|| next
!= delim
; next
= nextchar(stream
)) {
594 if (len
< MAX_STRING
)
598 warning(stream_pos(stream
),
599 "Newline in string or character constant");
600 if (delim
== '\'') /* assume it's lost ' */
604 warning(stream_pos(stream
),
605 "End of file in middle of string");
609 if (want_hex
&& !(cclass
[next
+ 1] & Hex
))
610 warning(stream_pos(stream
),
611 "\\x used with no following hex digits");
613 escape
= next
== '\\';
616 want_hex
= next
== 'x';
620 warning(stream_pos(stream
),
621 "\\x used with no following hex digits");
622 if (len
> MAX_STRING
) {
623 warning(stream_pos(stream
), "string too long (%d bytes, %d bytes max)", len
, MAX_STRING
);
626 if (delim
== '\'' && len
<= 4) {
628 sparse_error(stream_pos(stream
),
629 "empty character constant");
630 return nextchar(stream
);
632 token_type(token
) = type
+ len
;
633 memset(buffer
+ len
, '\0', 4 - len
);
634 memcpy(token
->embedded
, buffer
, 4);
636 token_type(token
) = type
;
637 string
= __alloc_string(len
+1);
638 memcpy(string
->data
, buffer
, len
);
639 string
->data
[len
] = '\0';
640 string
->length
= len
+1;
641 token
->string
= string
;
645 token
= stream
->token
;
647 return nextchar(stream
);
650 static int drop_stream_eoln(stream_t
*stream
)
654 switch (nextchar(stream
)) {
658 return nextchar(stream
);
663 static int drop_stream_comment(stream_t
*stream
)
668 newline
= stream
->newline
;
670 next
= nextchar(stream
);
674 warning(stream_pos(stream
), "End of file in the middle of a comment");
677 next
= nextchar(stream
);
678 if (curr
== '*' && next
== '/')
681 stream
->newline
= newline
;
682 return nextchar(stream
);
685 unsigned char combinations
[][4] = COMBINATION_STRINGS
;
687 #define NR_COMBINATIONS (SPECIAL_ARG_SEPARATOR - SPECIAL_BASE)
689 /* hash function for two-character punctuators - all give unique values */
690 #define special_hash(c0, c1) (((c0*8+c1*2)+((c0*8+c1*2)>>5))&31)
693 * note that we won't get false positives - special_hash(0,0) is 0 and
694 * entry 0 is filled (by +=), so all the missing ones are OK.
696 static unsigned char hash_results
[32][2] = {
697 #define RES(c0, c1) [special_hash(c0, c1)] = {c0, c1}
698 RES('+', '='), /* 00 */
699 RES('/', '='), /* 01 */
700 RES('^', '='), /* 05 */
701 RES('&', '&'), /* 07 */
702 RES('#', '#'), /* 08 */
703 RES('<', '<'), /* 0a */
704 RES('<', '='), /* 0c */
705 RES('!', '='), /* 0e */
706 RES('%', '='), /* 0f */
707 RES('-', '-'), /* 10 */
708 RES('-', '='), /* 11 */
709 RES('-', '>'), /* 13 */
710 RES('=', '='), /* 15 */
711 RES('&', '='), /* 17 */
712 RES('*', '='), /* 18 */
713 RES('.', '.'), /* 1a */
714 RES('+', '+'), /* 1b */
715 RES('|', '='), /* 1c */
716 RES('>', '='), /* 1d */
717 RES('|', '|'), /* 1e */
718 RES('>', '>') /* 1f */
721 static int code
[32] = {
722 #define CODE(c0, c1, value) [special_hash(c0, c1)] = value
723 CODE('+', '=', SPECIAL_ADD_ASSIGN
), /* 00 */
724 CODE('/', '=', SPECIAL_DIV_ASSIGN
), /* 01 */
725 CODE('^', '=', SPECIAL_XOR_ASSIGN
), /* 05 */
726 CODE('&', '&', SPECIAL_LOGICAL_AND
), /* 07 */
727 CODE('#', '#', SPECIAL_HASHHASH
), /* 08 */
728 CODE('<', '<', SPECIAL_LEFTSHIFT
), /* 0a */
729 CODE('<', '=', SPECIAL_LTE
), /* 0c */
730 CODE('!', '=', SPECIAL_NOTEQUAL
), /* 0e */
731 CODE('%', '=', SPECIAL_MOD_ASSIGN
), /* 0f */
732 CODE('-', '-', SPECIAL_DECREMENT
), /* 10 */
733 CODE('-', '=', SPECIAL_SUB_ASSIGN
), /* 11 */
734 CODE('-', '>', SPECIAL_DEREFERENCE
), /* 13 */
735 CODE('=', '=', SPECIAL_EQUAL
), /* 15 */
736 CODE('&', '=', SPECIAL_AND_ASSIGN
), /* 17 */
737 CODE('*', '=', SPECIAL_MUL_ASSIGN
), /* 18 */
738 CODE('.', '.', SPECIAL_DOTDOT
), /* 1a */
739 CODE('+', '+', SPECIAL_INCREMENT
), /* 1b */
740 CODE('|', '=', SPECIAL_OR_ASSIGN
), /* 1c */
741 CODE('>', '=', SPECIAL_GTE
), /* 1d */
742 CODE('|', '|', SPECIAL_LOGICAL_OR
), /* 1e */
743 CODE('>', '>', SPECIAL_RIGHTSHIFT
) /* 1f */
747 static int get_one_special(int c
, stream_t
*stream
)
752 next
= nextchar(stream
);
755 * Check for numbers, strings, character constants, and comments
759 if (next
>= '0' && next
<= '9')
760 return get_one_number(c
, next
, stream
);
763 return eat_string(next
, stream
, TOKEN_STRING
);
765 return eat_string(next
, stream
, TOKEN_CHAR
);
768 return drop_stream_eoln(stream
);
770 return drop_stream_comment(stream
);
774 * Check for combinations
777 if (cclass
[next
+ 1] & ValidSecond
) {
778 i
= special_hash(c
, next
);
779 if (hash_results
[i
][0] == c
&& hash_results
[i
][1] == next
) {
781 next
= nextchar(stream
);
782 if (value
>= SPECIAL_LEFTSHIFT
&&
783 next
== "==."[value
- SPECIAL_LEFTSHIFT
]) {
785 next
= nextchar(stream
);
791 token
= stream
->token
;
792 token_type(token
) = TOKEN_SPECIAL
;
793 token
->special
= value
;
798 #define IDENT_HASH_BITS (13)
799 #define IDENT_HASH_SIZE (1<<IDENT_HASH_BITS)
800 #define IDENT_HASH_MASK (IDENT_HASH_SIZE-1)
802 #define ident_hash_init(c) (c)
803 #define ident_hash_add(oldhash,c) ((oldhash)*11 + (c))
804 #define ident_hash_end(hash) ((((hash) >> IDENT_HASH_BITS) + (hash)) & IDENT_HASH_MASK)
806 static struct ident
*hash_table
[IDENT_HASH_SIZE
];
807 static int ident_hit
, ident_miss
, idents
;
809 void show_identifier_stats(void)
812 int distribution
[100];
814 fprintf(stderr
, "identifiers: %d hits, %d misses\n",
815 ident_hit
, ident_miss
);
817 for (i
= 0; i
< 100; i
++)
820 for (i
= 0; i
< IDENT_HASH_SIZE
; i
++) {
821 struct ident
* ident
= hash_table
[i
];
830 distribution
[count
]++;
833 for (i
= 0; i
< 100; i
++) {
835 fprintf(stderr
, "%2d: %d buckets\n", i
, distribution
[i
]);
839 static struct ident
*alloc_ident(const char *name
, int len
)
841 struct ident
*ident
= __alloc_ident(len
);
842 ident
->symbols
= NULL
;
845 memcpy(ident
->name
, name
, len
);
849 static struct ident
* insert_hash(struct ident
*ident
, unsigned long hash
)
851 ident
->next
= hash_table
[hash
];
852 hash_table
[hash
] = ident
;
857 static struct ident
*create_hashed_ident(const char *name
, int len
, unsigned long hash
)
862 p
= &hash_table
[hash
];
863 while ((ident
= *p
) != NULL
) {
864 if (ident
->len
== (unsigned char) len
) {
865 if (strncmp(name
, ident
->name
, len
) != 0)
875 ident
= alloc_ident(name
, len
);
883 static unsigned long hash_name(const char *name
, int len
)
886 const unsigned char *p
= (const unsigned char *)name
;
888 hash
= ident_hash_init(*p
++);
890 unsigned int i
= *p
++;
891 hash
= ident_hash_add(hash
, i
);
893 return ident_hash_end(hash
);
896 struct ident
*hash_ident(struct ident
*ident
)
898 return insert_hash(ident
, hash_name(ident
->name
, ident
->len
));
901 struct ident
*built_in_ident(const char *name
)
903 int len
= strlen(name
);
904 return create_hashed_ident(name
, len
, hash_name(name
, len
));
907 struct token
*built_in_token(int stream
, const char *name
)
911 token
= __alloc_token(0);
912 token
->pos
.stream
= stream
;
913 token_type(token
) = TOKEN_IDENT
;
914 token
->ident
= built_in_ident(name
);
918 static int get_one_identifier(int c
, stream_t
*stream
)
927 hash
= ident_hash_init(c
);
930 next
= nextchar(stream
);
931 if (!(cclass
[next
+ 1] & (Letter
| Digit
)))
933 if (len
>= sizeof(buf
))
935 hash
= ident_hash_add(hash
, next
);
939 if (cclass
[next
+ 1] & Quote
) {
940 if (len
== 1 && buf
[0] == 'L') {
942 return eat_string(nextchar(stream
), stream
,
945 return eat_string(nextchar(stream
), stream
,
949 hash
= ident_hash_end(hash
);
950 ident
= create_hashed_ident(buf
, len
, hash
);
953 token
= stream
->token
;
954 token_type(token
) = TOKEN_IDENT
;
955 token
->ident
= ident
;
960 static int get_one_token(int c
, stream_t
*stream
)
962 long class = cclass
[c
+ 1];
964 return get_one_number(c
, nextchar(stream
), stream
);
966 return get_one_identifier(c
, stream
);
967 return get_one_special(c
, stream
);
970 static struct token
*setup_stream(stream_t
*stream
, int idx
, int fd
,
971 unsigned char *buf
, unsigned int buf_size
)
978 stream
->whitespace
= 0;
981 stream
->token
= NULL
;
984 stream
->size
= buf_size
;
985 stream
->buffer
= buf
;
987 begin
= alloc_token(stream
);
988 token_type(begin
) = TOKEN_STREAMBEGIN
;
989 stream
->tokenlist
= &begin
->next
;
993 static struct token
*tokenize_stream(stream_t
*stream
)
995 int c
= nextchar(stream
);
998 struct token
*token
= alloc_token(stream
);
999 stream
->token
= token
;
1000 stream
->newline
= 0;
1001 stream
->whitespace
= 0;
1002 c
= get_one_token(c
, stream
);
1005 stream
->whitespace
= 1;
1006 c
= nextchar(stream
);
1008 return mark_eof(stream
);
1011 struct token
* tokenize_buffer(void *buffer
, unsigned long size
, struct token
**endtoken
)
1014 struct token
*begin
;
1016 begin
= setup_stream(&stream
, 0, -1, buffer
, size
);
1017 *endtoken
= tokenize_stream(&stream
);
1021 struct token
* tokenize(const char *name
, int fd
, struct token
*endtoken
, const char **next_path
)
1023 struct token
*begin
, *end
;
1025 unsigned char buffer
[BUFSIZE
];
1028 idx
= init_stream(name
, fd
, next_path
);
1030 // info(endtoken->pos, "File %s is const", name);
1034 begin
= setup_stream(&stream
, idx
, fd
, buffer
, 0);
1035 end
= tokenize_stream(&stream
);
1037 end
->next
= endtoken
;