%{
+
+/*
+ * Copyright (c) 1984-1987 by the Regents of the
+ * University of California and by Gregory Glenn Minshall.
+ *
+ * Permission to use, copy, modify, and distribute these
+ * programs and their documentation for any purpose and
+ * without fee is hereby granted, provided that this
+ * copyright and permission appear on all copies and
+ * supporting documentation, the name of the Regents of
+ * the University of California not be used in advertising
+ * or publicity pertaining to distribution of the programs
+ * without specific prior permission, and notice be given in
+ * supporting documentation that copying and distribution is
+ * by permission of the Regents of the University of California
+ * and by Gregory Glenn Minshall. Neither the Regents of the
+ * University of California nor Gregory Glenn Minshall make
+ * representations about the suitability of this software
+ * for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
typedef struct string {
int
hashval,
%token <intval> MACRO_CHAR NL WHITE_SPACE
%token <intval> ':' '=' '$' '{' '}' ';' '-' '@' '(' ')' ' ' '\t'
%type <same> target target1 assignment assign1 actions action
-%type <same> command_list command list
+%type <same> command_list list list_element
%type <same> for_statement maybe_at_minus tokens token
%type <same> maybe_white_space
%type <intval> white_space macro_char
| target_action
;
-assignment :
- assign1 tokens NL
+assignment : assign1 tokens NL
{
assign($1, $2);
}
}
;
-target :
- target1 tokens NL
+target : target1 tokens NL
{
$$ = add_depends($1, $2);
}
actions: action
| actions action
{
- $$ = same_cat($1, $2);
+ $$ = same_cat(same_cat($1, same_copy(newline)), $2);
}
;
for_statement: maybe_at_minus FOR white_space token
in tokens semi_colon
{
- $$ = for_statement($1, $4, expand_variables($6, 0));
+ $$ = for_statement($1, $4, ws_merge(expand_variables($6, 0)));
}
;
}
;
-list: command
- | list semi_colon maybe_white_space command
+list: token
+ | list list_element
{
- $$ = same_cat($1, same_cat(same_copy(newline), $4));
+ $$ = same_cat($1, $2);
+ }
+ | list white_space list_element
+ {
+ $$ = same_cat($1, same_cat(same_copy(blank), $3));
}
;
-command: tokens
+list_element: token
+ | semi_colon
+ {
+ $$ = same_copy(newline);
+ }
;
maybe_at_minus: /* empty */
char *string = token->string->string;
same_t *tmp = same_unlink(token);
- if ((string[0] == '$') && (string[1] == '{')) {/* '}' Expand time */
+ if ((string[0] == '$') && (string[1] == '{')) { /* Expand time */
int len = strlen(string);
string[len-1] = 0;
head = same_cat(head, expand_variables(
value_of(same_item(string_lookup(string+2))), 1));
string[len-1] = '}';
- } else if (!isspace(string[0])) {
+ } else {
head = same_cat(head, token);
}
token = tmp;
Return(c,c);
case '\'':
case '"':
- {
+ if (bufptr != buffer) {
+ if (bufptr[-1] == '\\') {
+ bufptr[-1] = c;
+ }
+ break;
+ } else {
int newc;
ret_token(c);
}
visit_end();
- printf("#targets...\n");
+ printf("\n\n#targets...\n");
for (visit(targets, same); !visited(same); visit_next(same)) {
- printf("%s:\t", same->string->string);
+ printf("\n%s:\t", same->string->string);
for (visit(same->depend_list, same2); !visited(same2);
visit_next(same2)) {
printf(same2->string->string);