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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
/*************************************************************************
*
* $RCSfile: parse.c,v $
*
* $Revision: 1.3 $
*
* last change: $Author: hr $ $Date: 2003-03-25 14:02:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/*
--
-- SYNOPSIS
-- Parse the input, and perform semantic analysis
--
-- DESCRIPTION
-- This file contains the routines that parse the input makefile and
-- call the appropriate routines to perform the semantic analysis and
-- build the internal dag.
--
-- AUTHOR
-- Dennis Vadura, dvadura@dmake.wticorp.com
--
-- WWW
-- http://dmake.wticorp.com/
--
-- COPYRIGHT
-- Copyright (c) 1996,1997 by WTI Corp. All rights reserved.
--
-- This program is NOT free software; you can redistribute it and/or
-- modify it under the terms of the Software License Agreement Provided
-- in the file <distribution-root>/readme/license.txt.
--
-- LOG
-- Use cvs log to obtain detailed change logs.
*/
#include "extern.h"
PUBLIC void
Parse( fil )/*
============== Parse the makefile input */
FILE *fil;
{
int rule = FALSE; /* have seen a recipe line */
char *p; /* termporary pointer into Buffer */
char *pTmpBuf;
DB_ENTER( "Parse" );
State = NORMAL_SCAN;
Group = FALSE; /* true if scanning a group rcpe */
while( TRUE ) {
if( Get_line( Buffer, fil ) ) {
if( fil != NIL( FILE ) ) /* end of parsable input */
Closefile();
Bind_rules_to_targets( F_DEFAULT );
if( Group ) Fatal( "Incomplete rule recipe group detected" );
DB_VOID_RETURN;
}
else {
#ifdef _MPW
if ( Buffer[0] == 10 )
pTmpBuf = Buffer+1;
else
#endif
pTmpBuf = Buffer;
#ifdef _MPW
p = pTmpBuf;
while ( *p )
{
if ( *p == 10 )
*p = '\t';
p++;
}
#endif
switch( State ) {
case RULE_SCAN:
/* Check for the `[' that starts off a group rule definition.
* It must appear as the first non-white space
* character in the line. */
p = DmStrSpn( Buffer, " \t\r\n" );
if( Set_group_attributes( p ) ) {
if( rule && Group )
Fatal( "Cannot mix single and group recipe lines" );
else
Group = TRUE;
rule = TRUE;
break; /* ignore the group start */
}
if( Group ) {
if( *p != ']' ) {
Add_recipe_to_list( pTmpBuf, TRUE, TRUE );
rule = TRUE;
}
else
State = NORMAL_SCAN;
}
else {
if( *pTmpBuf == '\t'
|| (Notabs && *pTmpBuf == ' ') ) {
Add_recipe_to_list( pTmpBuf, FALSE, FALSE );
rule = TRUE;
}
else if( *p == ']' )
Fatal( "Found unmatched ']'" );
else if( (*pTmpBuf && *p) || (Notabs && !*pTmpBuf && !*p))
State = NORMAL_SCAN;
}
if( State == RULE_SCAN ) break; /* ie. keep going */
Bind_rules_to_targets( (Group) ? F_GROUP: F_DEFAULT );
rule = FALSE;
if( Group ) {
Group = FALSE;
break;
}
/*FALLTRHOUGH*/
/* In this case we broke out of the rule scan because we do not
* have a recipe line that begins with a <TAB>, so lets
* try to scan the thing as a macro or rule definition. */
case NORMAL_SCAN:
if( !*pTmpBuf ) continue; /* we have null input line */
/* STUPID AUGMAKE uses "include" at the start of a line as
* a signal to include a new file, so let's look for it.
* if we see it replace it by .INCLUDE: and stick this back
* into the buffer. */
if( !strncmp( "include", pTmpBuf, 7 ) &&
(pTmpBuf[7] == ' ' || pTmpBuf[7] == '\t') )
{
char *tmp;
tmp = DmStrJoin( ".INCLUDE:", pTmpBuf+7, -1, FALSE );
strcpy( pTmpBuf, tmp );
FREE( tmp );
}
/* look for a macro definition, they all contain an = sign
* if we fail to recognize it as a legal macro op then try to
* parse the same line as a rule definition, it's one or the
* other */
if( Parse_macro(pTmpBuf, M_DEFAULT) ) break;/* it's a macro def*/
if( Parse_rule_def( &State ) ) break;/* it's a rule def */
/* if just blank line then ignore it */
if( *DmStrSpn( Buffer, " \t\r\n" ) == '\0' ) break;
/* otherwise assume it was a line of unrecognized input, or a
* recipe line out of place so print a message */
Fatal( "Expecting macro or rule defn, found neither" );
break;
default:
Fatal( "Internal -- UNKNOWN Parser state %d", State );
}
}
}
}
|