Fix up mix of man(7)/mdoc(7).
[netbsd-mini2440.git] / usr.bin / tn3270 / tools / mkmake / mkmake.y
blobdaf6c1ecf601582950c29a27f9edaebbc7e36be5
1 %{
2 /* $NetBSD$ */
3 /*-
4 * Copyright (c) 1988 The Regents of the University of California.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
32 #ifndef HOST_TOOL
33 #include <sys/cdefs.h>
34 #if defined(__RCSID) && !defined(lint)
35 #if 0
36 static char sccsid[] = "@(#)mkmake.y 4.2 (Berkeley) 4/26/91";
37 #else
38 __RCSID("$NetBSD$");
39 #endif
40 #endif /* not lint */
41 #endif
43 typedef struct string {
44 int
45 hashval,
46 length;
47 char
48 *string;
49 struct string
50 *next;
51 } string_t;
54 * The deal with these is that they exist on various lists.
56 * First off, they are on a temporary list during the time they
57 * are in the active focus of the parser.
59 * Secondly, they live on one of three queues:
60 * 1. Variables
61 * 2. Targets
62 * 3. Actions
63 * (and, we restrict any given one to live on one and only one such list)
65 * Also, they may live on the list of values for someone else's variable,
66 * or as someone's dependency.
69 typedef struct same {
70 string_t
71 *string; /* My name */
72 struct same
73 *nexttoken, /* Next pointer */
74 *lasttoken, /* Back pointer */
75 *depend_list, /* If target, dependancies */
76 *action_list, /* If target, actions */
77 *value_list, /* If variable, value list */
78 *shell_item; /* If a shell variable, current value */
79 } same_t;
84 %union {
85 string_t *string;
86 same_t *same;
87 int intval;
90 %start makefile
91 %token <string> TOKEN QUOTED_STRING
92 %token <intval> FOR IN DO DONE
93 %token <intval> MACRO_CHAR NL WHITE_SPACE
94 %token <intval> ':' '=' '$' '{' '}' ';' '-' '@' '(' ')' ' ' '\t'
95 %type <same> target target1 assignment assign1 actions action
96 %type <same> command_list list list_element
97 %type <same> for_statement maybe_at_minus tokens token
98 %type <same> maybe_white_space
99 %type <intval> white_space macro_char
102 makefile : lines;
104 lines : line
105 | lines line
108 line : NL
109 | assignment
110 | target_action
113 assignment : assign1 tokens NL
115 assign($1, $2);
117 | assign1 NL
119 assign($1, same_copy(null));
123 assign1: token maybe_white_space '=' maybe_white_space
126 target_action: target actions
128 add_targets_actions($1, $2);
130 | target
132 add_targets_actions($1, 0);
136 target : target1 tokens NL
138 $$ = add_depends($1, $2);
140 | target1 NL
142 $$ = add_depends($1, same_copy(null));
146 target1: tokens maybe_white_space ':' maybe_white_space
148 $$ = ws_merge($1);
152 actions: action
153 | actions action
155 $$ = same_cat(same_cat($1, same_copy(newline)), $2);
159 action: white_space command_list NL
161 $$ = $2;
163 | white_space for_statement do command_list semi_colon done NL
165 $$ = do_command($2, $4);
169 for_statement: maybe_at_minus FOR white_space token
170 in tokens semi_colon
172 $$ = for_statement($1, $4, ws_merge(expand_variables($6, 0)));
176 in: white_space IN white_space
177 do: white_space DO white_space
180 done: white_space DONE
183 semi_colon: ';'
186 command_list: list
187 | '(' list maybe_white_space ')'
189 $$ = same_cat($2, same_copy(cwd_line));
193 list: token
194 | list list_element
196 $$ = same_cat($1, $2);
198 | list white_space list_element
200 $$ = same_cat($1, same_cat(same_copy(blank), $3));
204 list_element: token
205 | semi_colon
207 $$ = same_copy(newline);
211 maybe_at_minus: /* empty */
213 $$ = same_copy(null);
215 | '@'
217 char buffer[2];
219 buffer[0] = $1;
220 buffer[1] = 0;
221 $$ = same_item(string_lookup(buffer));
223 | '-'
225 char buffer[2];
227 buffer[0] = $1;
228 buffer[1] = 0;
229 $$ = same_item(string_lookup(buffer));
233 tokens : token
234 | tokens maybe_white_space token
236 $$ = same_cat($1, same_cat($2, $3));
240 token: TOKEN
242 $$ = same_item($1);
244 | QUOTED_STRING
246 $$ = same_item($1);
248 | '$' macro_char
250 char buffer[3];
252 buffer[0] = '$';
253 buffer[1] = $2;
254 buffer[2] = 0;
256 $$ = same_item(string_lookup(buffer));
258 | '$' '$' TOKEN
260 $$ = shell_variable(same_item($3));
262 | MACRO_CHAR
264 $$ = same_char($1);
266 | '$' '{' TOKEN '}'
268 $$ = variable(same_item($3));
270 | '$' '(' TOKEN ')'
272 $$ = variable(same_item($3));
274 | '$' TOKEN
276 $$ = variable(same_item($2));
278 | '-'
280 $$ = same_char('-');
282 | '@'
284 $$ = same_char('@');
288 macro_char: MACRO_CHAR
289 | '@'
292 maybe_white_space:
294 $$ = same_copy(null);
296 | white_space
298 $$ = same_char($1);
302 white_space : WHITE_SPACE
303 | white_space WHITE_SPACE
306 #include <stdio.h>
307 #include <string.h>
308 #include <ctype.h>
310 /* mkmake.y */
311 void yyerror(char *);
312 void assign(same_t *, same_t *);
313 int yylex(void);
314 extern int yyparse(void);
315 int main(int, char *[]);
317 static int visitcheck(same_t *);
318 static int string_hashof(char *, int);
319 static int string_same(string_t *, string_t *);
320 static string_t *string_lookup(char *);
321 static same_t *same_search(same_t *, same_t *);
322 static same_t *same_cat(same_t *, same_t *);
323 static same_t *same_item(string_t *);
324 static same_t *same_copy(same_t *);
325 static same_t *same_merge(same_t *, same_t *);
326 static void same_free(same_t *);
327 static same_t *same_unlink(same_t *);
328 static void same_replace(same_t *, same_t *);
329 static same_t *same_char(int);
330 static void add_target(same_t *, same_t *);
331 static same_t *add_targets_actions(same_t *, same_t *);
332 static same_t *add_depends(same_t *, same_t *);
333 static same_t *value_of(same_t *);
334 static same_t *expand_variables(same_t *, int);
335 static same_t *ws_merge(same_t *);
336 static same_t *variable(same_t *);
337 static same_t *shell_variable(same_t *);
338 static same_t *for_statement(same_t *, same_t *, same_t *);
339 static same_t *do_command(same_t *, same_t *);
340 static int Getchar(void);
341 static int token_type(char *);
342 #if 0
343 static void dump_same(same_t *);
344 #endif
345 static void do_dump(void);
346 static int last_char, last_saved = 0;
347 static int column = 0, lineno = 1;
350 static string_t
351 *strings = 0;
353 static same_t
354 *variables = 0,
355 *targets = 0;
357 static same_t
358 *null,
359 *blank,
360 *cwd_line,
361 *newline;
363 static unsigned int
364 clock = -1;
366 struct {
367 same_t *first;
368 int next;
369 } visit_stack[20]; /* 20 maximum */
371 #define visit(what,via) \
372 (visit_stack[++clock].next = 0, visit_stack[clock].first = via = what)
373 #define visited(via) (visitcheck(via) || ((via) == 0) \
374 || (visit_stack[clock].next && (via == visit_stack[clock].first)))
375 #define visit_next(via) (visit_stack[clock].next = 1, (via) = (via)->nexttoken)
376 #define visit_end() (clock--)
378 void
379 yyerror(s)
380 char *s;
382 fprintf(stderr, "line %d, character %d: %s\n", lineno, column, s);
383 do_dump();
386 static int
387 visitcheck(same)
388 same_t *same;
390 if (same->string == 0) {
391 yyerror("BUG - freed 'same' in use...");
392 exit(1);
394 return 0;
397 static int
398 string_hashof(string, length)
399 char *string;
400 int length;
402 register int i = 0;
404 while (length--) {
405 i = ((i<<3) + *string) ^ ((i>>28)&0x7);
407 return i;
410 static int
411 string_same(s1, s2)
412 string_t
413 *s1, *s2;
415 if ((s1->hashval == s2->hashval) && (s1->length == s2->length)
416 && (memcmp(s1->string, s2->string, s1->length) == 0)) {
417 return 1;
418 } else {
419 return 0;
423 static string_t *
424 string_lookup(string)
425 char *string;
427 string_t ours;
428 string_t *ptr;
430 ours.length = strlen(string);
431 ours.hashval = string_hashof(string, ours.length);
432 ours.string = string;
434 for (ptr = strings; ptr; ptr = ptr->next) {
435 if (string_same(&ours, ptr)) {
436 return ptr;
439 if ((ptr = (string_t *)malloc(sizeof *ptr)) == 0) {
440 fprintf(stderr, "No space to add string *%s*!\n", string);
441 exit(1);
443 ptr->hashval = ours.hashval;
444 ptr->length = ours.length;
445 if ((ptr->string = malloc(ours.length+1)) == 0) {
446 fprintf(stderr, "No space to add literal *%s*!\n", string);
447 exit(1);
449 memcpy(ptr->string, string, ours.length+1);
450 ptr->next = strings;
451 strings = ptr;
452 return ptr;
455 #define same_singleton(s) ((s)->nexttoken == (s))
457 static same_t *
458 same_search(list, token)
459 same_t
460 *list,
461 *token;
463 same_t *ptr;
465 ptr = list;
466 for (visit(list, ptr); !visited(ptr); visit_next(ptr)) {
467 string_t *string;
469 string = ptr->string;
470 if (string_same(string, token->string)) {
471 visit_end();
472 return ptr;
475 visit_end();
476 return 0;
479 static same_t *
480 same_cat(list, tokens)
481 same_t
482 *list,
483 *tokens;
485 same_t *last;
487 if (tokens == 0) {
488 return list;
490 if (list) {
491 last = tokens->lasttoken;
492 tokens->lasttoken = list->lasttoken;
493 list->lasttoken = last;
494 tokens->lasttoken->nexttoken = tokens;
495 last->nexttoken = list;
496 return list;
497 } else {
498 return tokens;
502 static same_t *
503 same_item(string)
504 string_t *string;
506 same_t *ptr;
508 if ((ptr = (same_t *)malloc(sizeof *ptr)) == 0) {
509 fprintf(stderr, "No more space for tokens!\n");
510 exit(1);
512 memset((char *)ptr, 0, sizeof *ptr);
513 ptr->nexttoken = ptr->lasttoken = ptr;
514 ptr->string = string;
515 return ptr;
518 static same_t *
519 same_copy(same)
520 same_t *same;
522 same_t *head, *copy;
524 head = 0;
525 for (visit(same, copy); !visited(copy); visit_next(copy)) {
526 same_t *ptr;
528 ptr = same_item(copy->string);
529 head = same_cat(head, ptr);
531 visit_end();
532 return head;
536 static same_t *
537 same_merge(t1, t2)
538 same_t
539 *t1,
540 *t2;
542 if (same_singleton(t1) && same_singleton(t2)) {
543 int length = strlen(t1->string->string)+strlen(t2->string->string);
544 char *buffer = malloc(length+1);
545 same_t *value;
547 if (buffer == 0) {
548 yyerror("No space to merge strings in same_merge!");
549 exit(1);
551 strcpy(buffer, t1->string->string);
552 strcat(buffer, t2->string->string);
553 value = same_item(string_lookup(buffer));
554 free(buffer);
555 return value;
556 } else {
557 yyerror("Internal error - same_merge with non-singletons");
558 exit(1);
563 static void
564 same_free(list)
565 same_t *list;
567 same_t *token, *ptr;
569 if (list == 0) {
570 return;
573 token = list;
574 do {
575 ptr = token->nexttoken;
576 token->string = 0;
577 (void) free((char *)token);
578 token = ptr;
579 } while (token != list);
582 static same_t *
583 same_unlink(token)
584 same_t
585 *token;
587 same_t *tmp;
589 if (token == 0) {
590 return 0;
592 if ((tmp = token->nexttoken) == token) {
593 tmp = 0;
595 token->lasttoken->nexttoken = token->nexttoken;
596 token->nexttoken->lasttoken = token->lasttoken;
597 token->nexttoken = token->lasttoken = token;
598 return tmp;
601 static void
602 same_replace(old, new)
603 same_t
604 *old,
605 *new;
607 new->lasttoken->nexttoken = old->nexttoken;
608 old->nexttoken->lasttoken = new->lasttoken;
609 new->lasttoken = old->lasttoken;
610 /* rather than
611 * old->lasttoken->nexttoken = new
612 * we update in place (for the case where there isn't anything else)
614 *old = *new;
618 static same_t *
619 same_char(ch)
620 char ch;
622 char buffer[2];
624 buffer[0] = ch;
625 buffer[1] = 0;
627 return same_item(string_lookup(buffer));
631 static void
632 add_target(target, actions)
633 same_t
634 *target,
635 *actions;
637 same_t *ptr;
639 if ((ptr = same_search(targets, target)) == 0) {
640 targets = same_cat(targets, target);
641 ptr = target;
642 } else {
643 ptr->depend_list = same_cat(ptr->depend_list, target->depend_list);
645 if (actions) {
646 if (ptr->action_list) {
647 same_free(ptr->action_list);
649 ptr->action_list = same_copy(actions);
654 static same_t *
655 add_targets_actions(target, actions)
656 same_t
657 *target,
658 *actions;
660 same_t *ptr;
662 if (target == 0) {
663 return 0;
665 do {
666 ptr = same_unlink(target);
667 add_target(target, actions);
668 target = ptr;
669 } while (target);
671 same_free(actions);
672 return 0;
675 static same_t *
676 add_depends(target, depends)
677 same_t
678 *target,
679 *depends;
681 same_t *original = target;
683 depends = same_cat(depends, same_copy(blank)); /* Separator */
685 for (visit(original, target); !visited(target); visit_next(target)) {
686 target->depend_list = same_cat(target->depend_list, same_copy(depends));
688 visit_end();
689 same_free(depends);
691 return original;
696 * We know that variable is a singleton
699 void
700 assign(variable, value)
701 same_t
702 *variable,
703 *value;
705 same_t *ptr;
707 if ((ptr = same_search(variables, variable)) != 0) {
708 same_free(ptr->value_list);
709 variables = same_unlink(ptr);
710 same_free(ptr);
712 variable->value_list = value;
713 variables = same_cat(variables, variable);
716 static same_t *
717 value_of(variable)
718 same_t *variable;
720 same_t *ptr = same_search(variables, variable);
722 if (ptr == 0) {
723 return same_copy(null);
724 } else {
725 return same_copy(ptr->value_list);
730 static same_t *
731 expand_variables(token, free)
732 same_t *token;
733 int free;
735 same_t *head = 0;
737 if (!free) {
738 token = same_copy(token); /* Get our private copy */
741 while (token) {
742 char *string = token->string->string;
743 same_t *tmp = same_unlink(token);
745 if ((string[0] == '$') && (string[1] == '{')) { /* Expand time */
746 int len = strlen(string);
748 string[len-1] = 0;
749 head = same_cat(head, expand_variables(
750 value_of(same_item(string_lookup(string+2))), 1));
751 string[len-1] = '}';
752 } else {
753 head = same_cat(head, token);
755 token = tmp;
757 return head;
761 static same_t *
762 ws_merge(list)
763 same_t *list;
765 same_t *newlist = 0, *item = NULL;
766 int what = 0;
768 while (list) {
769 switch (what) {
770 case 0:
771 if (isspace(list->string->string[0])) {
773 } else {
774 item = same_item(list->string);
775 what = 1;
777 break;
778 case 1:
779 if (isspace(list->string->string[0])) {
780 newlist = same_cat(newlist, item);
781 item = 0;
782 what = 0;
783 } else {
784 item = same_merge(item, same_item(list->string));
785 what = 1;
787 break;
789 list = same_unlink(list);
791 return same_cat(newlist, item);
795 static same_t *
796 variable(var_name)
797 same_t *var_name;
799 int length = strlen(var_name->string->string);
800 same_t *resolved;
801 char *newname;
803 if ((newname = malloc(length+1+3)) == 0) {
804 fprintf(stderr, "Out of space for a variable name.\n");
805 exit(1);
807 newname[0] = '$';
808 newname[1] = '{';
809 strcpy(newname+2, var_name->string->string);
810 strcat(newname, "}");
811 resolved = same_item(string_lookup(newname));
812 free(newname);
814 return resolved;
818 static same_t *
819 shell_variable(var_name)
820 same_t *var_name;
822 int length = strlen(var_name->string->string);
823 same_t *resolved;
824 char *newname;
826 if ((newname = malloc(length+1+2)) == 0) {
827 fprintf(stderr, "Out of space for a variable name.\n");
828 exit(1);
830 newname[0] = '$';
831 newname[1] = '$';
832 strcpy(newname+2, var_name->string->string);
833 resolved = same_item(string_lookup(newname));
834 free(newname);
836 return resolved;
839 static same_t *
840 for_statement(special, variable, list)
841 same_t
842 *special,
843 *variable,
844 *list;
846 variable->shell_item = special;
847 variable->value_list = list;
848 return variable;
851 static same_t *
852 do_command(forlist, commands)
853 same_t
854 *forlist,
855 *commands;
857 same_t
858 *special,
859 *command_list = 0,
860 *new_commands,
861 *tmp,
862 *shell_item,
863 *value_list = forlist->value_list;
864 char
865 *tmpstr,
866 *variable_name = forlist->string->string;
868 special = forlist->shell_item;
869 if (same_unlink(forlist->shell_item) != 0) {
870 yyerror("Unexpected second item in special part of do_command");
871 exit(1);
874 while ((shell_item = value_list) != 0) {
875 value_list = same_unlink(shell_item);
876 /* Visit each item in commands. For each shell variable which
877 * matches ours, replace it with ours.
879 new_commands = same_copy(commands);
880 for (visit(new_commands, tmp); !visited(tmp); visit_next(tmp)) {
881 tmpstr = tmp->string->string;
882 if ((tmpstr[0] == '$') && (tmpstr[1] == '$')) {
883 if (strcmp(tmpstr+2, variable_name) == 0) {
884 same_replace(tmp, same_copy(shell_item));
888 visit_end();
889 command_list = same_cat(command_list, new_commands);
891 return same_cat(command_list, same_copy(newline));
895 static int
896 Getchar()
898 if (last_saved) {
899 last_saved = 0;
900 return last_char;
901 } else {
902 int c;
903 c = getchar();
904 switch (c) {
905 case '\n':
906 lineno++;
907 column = 0;
908 break;
909 default:
910 column++;
912 return c;
917 static int
918 token_type(string)
919 char *string;
921 switch (string[0]) {
922 case 'f':
923 if (strcmp(string, "for") == 0) {
924 return FOR;
926 break;
927 case 'd':
928 if (string[1] == 'o') {
929 if (strcmp(string, "do") == 0) {
930 return DO;
931 } else if (strcmp(string, "done") == 0) {
932 return DONE;
935 break;
936 case 'i':
937 if (strcmp(string, "in") == 0) {
938 return IN;
940 break;
941 default:
942 break;
944 return TOKEN;
949 yylex()
951 #define ret_token(c) if (bufptr != buffer) { \
952 save(c); \
953 *bufptr = 0; \
954 bufptr = buffer; \
955 yylval.string = string_lookup(buffer); \
956 return token_type(buffer); \
958 #define save(c) { last_char = c; last_saved = 1; }
959 #if defined(YYDEBUG)
960 #define Return(y,c) if (yydebug) { \
961 printf("[%d]", c); \
962 fflush(stdout); \
964 yylval.intval = c; \
965 return y;
966 #else /* defined(YYDEBUG) */
967 #define Return(y,c) { yylval.intval = c; return y; }
968 #endif /* defined(YYDEBUG) */
971 static char buffer[500], *bufptr = buffer;
972 static int eof_found = 0;
973 int c;
975 if (eof_found != 0) {
976 eof_found++;
977 if (eof_found > 2) {
978 fprintf(stderr, "End of file ignored.\n");
979 exit(1);
981 Return(EOF,0);
983 while ((c = Getchar()) != EOF) {
984 switch (c) {
985 case '#':
986 ret_token(c);
987 while (((c = Getchar()) != EOF) && (c != '\n')) {
990 save(c);
991 break;
992 case '<':
993 case '?':
994 ret_token(c);
995 Return(MACRO_CHAR, c);
996 case '\t':
997 case ' ':
998 ret_token(c);
999 Return(WHITE_SPACE, c);
1000 case '-':
1001 case '@':
1002 case ':':
1003 case ';':
1004 case '=':
1005 case '$':
1006 case '{':
1007 case '}':
1008 case '(':
1009 case ')':
1010 ret_token(c);
1011 Return(c,c);
1012 case '\'':
1013 case '"':
1014 if (bufptr != buffer) {
1015 if (bufptr[-1] == '\\') {
1016 bufptr[-1] = c;
1018 break;
1019 } else {
1020 int newc;
1022 ret_token(c);
1023 *bufptr++ = c;
1024 while (((newc = Getchar()) != EOF) && (newc != c)) {
1025 *bufptr++ = newc;
1027 *bufptr++ = c;
1028 *bufptr = 0;
1029 bufptr = buffer;
1030 yylval.string = string_lookup(buffer);
1031 return QUOTED_STRING;
1033 case '\n':
1034 if (bufptr != buffer) {
1035 if (bufptr[-1] == '\\') {
1036 bufptr--;
1037 if ((c = Getchar()) != '\t') {
1038 yyerror("continuation line doesn't begin with a tab");
1039 save(c);
1041 ret_token(c);
1042 Return(WHITE_SPACE, c);
1045 ret_token(c);
1046 Return(NL, 0);
1047 default:
1048 *bufptr++ = c;
1049 break;
1053 eof_found = 1;
1055 ret_token(' ');
1056 Return(EOF, 0);
1060 main(argc, argv)
1061 int argc;
1062 char *argv[];
1064 null = same_item(string_lookup(""));
1065 newline = same_item(string_lookup("\n"));
1066 blank = same_item(string_lookup(" "));
1067 cwd_line = same_cat(same_copy(newline),
1068 same_cat(same_item(string_lookup("cd ${CWD}")),
1069 same_copy(newline)));
1071 yyparse();
1073 do_dump();
1075 return 0;
1078 #if 0
1079 static void
1080 dump_same(same)
1081 same_t *same;
1083 same_t *same2;
1085 for (visit(same, same2); !visited(same2); visit_next(same2)) {
1086 printf("%s", same2->string->string);
1088 visit_end();
1090 #endif
1092 static void
1093 do_dump()
1095 string_t *string;
1096 same_t *same, *same2;
1098 if (yydebug > 1) {
1099 printf("strings...\n");
1100 for (string = strings; string; string = string->next) {
1101 printf("\t%s\n", string->string);
1105 printf("# variables...\n");
1106 for (visit(variables, same); !visited(same); visit_next(same)) {
1107 printf("%s =\t", same->string->string);
1108 for (visit(same->value_list, same2); !visited(same2);
1109 visit_next(same2)) {
1110 printf("%s", same2->string->string);
1112 visit_end();
1113 printf("\n");
1115 visit_end();
1117 printf("\n\n#targets...\n");
1118 for (visit(targets, same); !visited(same); visit_next(same)) {
1119 printf("\n%s:\t", same->string->string);
1120 for (visit(same->depend_list, same2); !visited(same2);
1121 visit_next(same2)) {
1122 printf("%s", same2->string->string);
1124 visit_end();
1125 printf("\n\t");
1126 for (visit(same->action_list, same2); !visited(same2);
1127 visit_next(same2)) {
1128 printf("%s", same2->string->string);
1129 if (same2->string->string[0] == '\n') {
1130 printf("\t");
1133 visit_end();
1134 printf("\n");
1136 visit_end();