1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) Sébastien Granjoux 2009 <seb.sfo@free.fr>
6 * main.c is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * main.c is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "am-scanner.h"
22 #include "am-parser.h"
28 /* Token location is found directly from token value, there is no need to
29 * maintain a separate location variable */
30 #define YYLLOC_DEFAULT(Current, Rhs, N) ((Current) = YYRHSLOC(Rhs, (N) ? 1 : 0))
35 %token END_OF_LINE
'\n'
42 %token DOUBLE_COLON
"::"
46 %token IMMEDIATE_EQUAL
":="
47 %token CONDITIONAL_EQUAL
"?="
81 %token TARGET_CPPFLAGS
83 %token TARGET_CXXFLAGS
84 %token TARGET_JAVACFLAGS
85 %token TARGET_VALAFLAGS
87 %token TARGET_OBJCFLAGS
90 %token TARGET_DEPENDENCIES
98 %define api.push_pull
"push"
100 %parse
-param
{AmpAmScanner
* scanner
}
101 %lex
-param
{AmpAmScanner
* scanner
}
103 %name
-prefix
="amp_am_yy"
117 //amp_am_yydebug = 1;
120 amp_am_automake_variable
(AnjutaToken
*token
)
122 switch
(anjuta_token_get_type
(token
))
124 case SUBDIRS
: return AM_TOKEN_SUBDIRS
;
125 case DIST_SUBDIRS
: return AM_TOKEN_DIST_SUBDIRS
;
126 case _DATA
: return AM_TOKEN__DATA
;
127 case _HEADERS
: return AM_TOKEN__HEADERS
;
128 case _LIBRARIES
: return AM_TOKEN__LIBRARIES
;
129 case _LISP
: return AM_TOKEN__LISP
;
130 case _LTLIBRARIES
: return AM_TOKEN__LTLIBRARIES
;
131 case _MANS
: return AM_TOKEN__MANS
;
132 case _PROGRAMS
: return AM_TOKEN__PROGRAMS
;
133 case _PYTHON
: return AM_TOKEN__PYTHON
;
134 case _JAVA
: return AM_TOKEN__JAVA
;
135 case _SCRIPTS
: return AM_TOKEN__SCRIPTS
;
136 case _SOURCES
: return AM_TOKEN__SOURCES
;
137 case _TEXINFOS
: return AM_TOKEN__TEXINFOS
;
138 case _DIR
: return AM_TOKEN_DIR
;
139 case _LDFLAGS
: return AM_TOKEN__LDFLAGS
;
140 case _CPPFLAGS
: return AM_TOKEN__CPPFLAGS
;
141 case _CFLAGS
: return AM_TOKEN__CFLAGS
;
142 case _CXXFLAGS
: return AM_TOKEN__CXXFLAGS
;
143 case _JAVACFLAGS
: return AM_TOKEN__JAVACFLAGS
;
144 case _VALAFLAGS
: return AM_TOKEN__VALAFLAGS
;
145 case _FCFLAGS
: return AM_TOKEN__FCFLAGS
;
146 case _OBJCFLAGS
: return AM_TOKEN__OBJCFLAGS
;
147 case _LFLAGS
: return AM_TOKEN__LFLAGS
;
148 case _YFLAGS
: return AM_TOKEN__YFLAGS
;
149 case TARGET_LDFLAGS
: return AM_TOKEN_TARGET_LDFLAGS
;
150 case TARGET_CPPFLAGS
: return AM_TOKEN_TARGET_CPPFLAGS
;
151 case TARGET_CFLAGS
: return AM_TOKEN_TARGET_CFLAGS
;
152 case TARGET_CXXFLAGS
: return AM_TOKEN_TARGET_CXXFLAGS
;
153 case TARGET_JAVACFLAGS
: return AM_TOKEN_TARGET_JAVACFLAGS
;
154 case TARGET_VALAFLAGS
: return AM_TOKEN_TARGET_VALAFLAGS
;
155 case TARGET_FCFLAGS
: return AM_TOKEN_TARGET_FCFLAGS
;
156 case TARGET_OBJCFLAGS
: return AM_TOKEN_TARGET_OBJCFLAGS
;
157 case TARGET_LFLAGS
: return AM_TOKEN_TARGET_LFLAGS
;
158 case TARGET_YFLAGS
: return AM_TOKEN_TARGET_YFLAGS
;
159 case TARGET_DEPENDENCIES
: return AM_TOKEN_TARGET_DEPENDENCIES
;
160 case TARGET_LIBADD
: return AM_TOKEN_TARGET_LIBADD
;
161 case TARGET_LDADD
: return AM_TOKEN_TARGET_LDADD
;
163 default
: return ANJUTA_TOKEN_NAME
;
171 /* File cannot be empty, there at least the END_OF_FILE token */
180 | definition end_of_line
181 | am_variable end_of_line
182 | include end_of_line
188 optional_space automake_token optional_space equal_token value_list
{
189 $$
= anjuta_token_new_static
(amp_am_automake_variable
($2), NULL
);
190 if
($1 != NULL
) anjuta_token_set_type
($1, ANJUTA_TOKEN_START
);
191 anjuta_token_merge
($$
, $2);
192 if
($3 != NULL
) anjuta_token_set_type
($3, ANJUTA_TOKEN_NEXT
);
193 anjuta_token_merge
($$
, $4);
194 anjuta_token_merge
($$
, $5);
195 amp_am_scanner_set_am_variable
(scanner
, $$
);
197 | optional_space automake_token optional_space equal_token
200 list
= anjuta_token_new_static
(ANJUTA_TOKEN_LIST
, NULL
);
201 anjuta_token_insert_after
($4, list
);
202 $$
= anjuta_token_new_static
(amp_am_automake_variable
($2), NULL
);
203 anjuta_token_merge
($$
, $2);
204 anjuta_token_merge
($$
, list
);
205 amp_am_scanner_set_am_variable
(scanner
, $$
);
210 optional_space include_token value_list
{
211 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_LIST
, NULL
);
212 anjuta_token_merge
($$
, $2);
213 anjuta_token_merge
($$
, $3);
214 amp_am_scanner_include
(scanner
, $$
);
218 head_list equal_token value_list
{
219 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_DEFINITION
, NULL
);
220 anjuta_token_merge_own_children
($1);
221 anjuta_token_merge
($$
, $1);
222 anjuta_token_merge
($$
, $2);
223 anjuta_token_merge
($$
, $3);
224 amp_am_scanner_update_variable
(scanner
, $$
);
226 | head_list equal_token
{
228 list
= anjuta_token_new_static
(ANJUTA_TOKEN_LIST
, NULL
);
229 anjuta_token_insert_after
($2, list
);
230 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_DEFINITION
, NULL
);
231 anjuta_token_merge_own_children
($1);
232 anjuta_token_merge
($$
, $1);
233 anjuta_token_merge
($$
, $2);
234 anjuta_token_merge
($$
, list
);
235 amp_am_scanner_update_variable
(scanner
, $$
);
240 depend_list end_of_line
241 | depend_list SEMI_COLON command_line END_OF_LINE
242 | depend_list SEMI_COLON command_line END_OF_FILE
246 head_list rule_token prerequisite_list
251 | command_list TAB command_line END_OF_LINE
252 | command_list TAB command_line END_OF_FILE
260 *----------------------------------------------------------------------------*/
264 anjuta_token_set_type
($1, ANJUTA_TOKEN_EOL
);
271 anjuta_token_set_type
($1, ANJUTA_TOKEN_COMMENT
);
278 | not_eol_list not_eol_token
284 | optional_space prerequisite_list_body optional_space
287 prerequisite_list_body:
289 | prerequisite_list_body space prerequisite
293 optional_space head_list_body optional_space
{
294 $$
= anjuta_token_merge_previous
($2, $1);
295 anjuta_token_merge
($$
, $3);
301 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_NAME
, NULL
);
302 anjuta_token_merge
($$
, $1);
304 | head_list_body space next_head
{
305 anjuta_token_merge
($1, $2);
306 anjuta_token_merge
($1, $3);
308 | head_list_body space head
{
309 anjuta_token_merge
($1, $2);
310 anjuta_token_merge
($1, $3);
316 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_LIST
, NULL
);
317 if
($1 != NULL
) anjuta_token_set_type
($1, ANJUTA_TOKEN_START
);
318 anjuta_token_merge
($$
, $1);
320 | optional_space value_list_body optional_space
{
321 if
($1 != NULL
) anjuta_token_set_type
($1, ANJUTA_TOKEN_START
);
322 if
($3 != NULL
) anjuta_token_set_type
($3, ANJUTA_TOKEN_LAST
);
323 anjuta_token_merge_previous
($2, $1);
324 anjuta_token_merge
($2, $3);
330 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_LIST
, NULL
);
331 anjuta_token_merge
($$
, $1);
333 | value_list_body space value
{
334 anjuta_token_set_type
($2, ANJUTA_TOKEN_NEXT
);
335 anjuta_token_merge
($1, $2);
336 anjuta_token_merge
($1, $3);
344 | command_line command_token
348 *----------------------------------------------------------------------------*/
359 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_SPACE
, NULL
);
360 anjuta_token_merge
($$
, $1);
363 $$ = anjuta_token_new_static (ANJUTA_TOKEN_SPACE, NULL);
364 anjuta_token_merge ($$, $1);
366 | space space_token
{
367 anjuta_token_merge
($1, $2);
369 /*| space space_variable {
370 anjuta_token_merge ($1, $2);
376 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_NAME
, NULL
);
377 anjuta_token_merge
($$
, $1);
380 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_NAME
, NULL
);
381 anjuta_token_merge
($$
, $1);
384 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_NAME
, NULL
);
385 anjuta_token_merge
($$
, $1);
388 anjuta_token_merge
($1, $2);
390 | head automake_token
{
391 anjuta_token_merge
($1, $2);
393 | head include_token
{
394 anjuta_token_merge
($1, $2);
397 anjuta_token_merge
($1, $2);
400 anjuta_token_merge
($1, $2);
406 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_NAME
, NULL
);
407 anjuta_token_merge
($$
, $1);
410 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_NAME
, NULL
);
411 anjuta_token_merge
($$
, $1);
413 | next_head head_token
{
414 anjuta_token_merge
($1, $2);
416 | next_head automake_token
{
417 anjuta_token_merge
($1, $2);
419 | next_head include_token
{
420 anjuta_token_merge
($1, $2);
422 | next_head variable
{
423 anjuta_token_merge
($1, $2);
425 | next_head ac_variable
{
426 anjuta_token_merge
($1, $2);
432 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_ARGUMENT
, NULL
);
433 anjuta_token_merge
($$
, $1);
436 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_ARGUMENT
, NULL
);
437 anjuta_token_merge
($$
, $1);
440 $$
= anjuta_token_new_static
(ANJUTA_TOKEN_ARGUMENT
, NULL
);
441 anjuta_token_merge
($$
, $1);
443 | value value_token
{
444 anjuta_token_merge
($1, $2);
447 anjuta_token_merge
($1, $2);
449 | value ac_variable
{
450 anjuta_token_merge
($1, $2);
462 | name_prerequisite prerequisite_token
463 | name_prerequisite variable
464 | name_prerequisite ac_variable
469 amp_am_scanner_parse_variable
(scanner
, $$
);
475 amp_am_scanner_parse_ac_variable
(scanner
, $$
);
480 *----------------------------------------------------------------------------*/
599 | TARGET_DEPENDENCIES