Skip to content

Commit

Permalink
Remove the not needed second pass for makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
sgranjoux committed Oct 31, 2009
1 parent 82a7288 commit a402de3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 105 deletions.
5 changes: 2 additions & 3 deletions src/ac-parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
%define api.push_pull "push"

%parse-param {AmpAcScanner* scanner}
%parse-param {AnjutaToken** last}
%lex-param {AmpAcScanner* scanner}

%name-prefix="amp_ac_yy"
Expand All @@ -110,7 +109,7 @@


%{
static void amp_ac_yyerror (YYLTYPE *loc, AmpAcScanner *scanner, AnjutaToken **last, char const *s);
static void amp_ac_yyerror (YYLTYPE *loc, AmpAcScanner *scanner, char const *s);

%}

Expand Down Expand Up @@ -659,7 +658,7 @@ any_macro:
%%

static void
amp_ac_yyerror (YYLTYPE *loc, AmpAcScanner *scanner, AnjutaToken **last, char const *s)
amp_ac_yyerror (YYLTYPE *loc, AmpAcScanner *scanner, char const *s)
{
amp_ac_scanner_yyerror (loc, scanner, s);
}
Expand Down
39 changes: 2 additions & 37 deletions src/ac-scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,10 @@ amp_ac_scanner_parse_token (AmpAcScanner *scanner, AnjutaToken *token, gint star
//ps2 = amp_ac_yypstate_new ();
yylval_param = NULL;
yylloc_param = NULL;
//amp_ac_yypush_parse (ps1, FIRST_PASS, &yylval_param, &yylloc_param, scanner, NULL);
switch (start)
{
case AC_SPACE_LIST_STATE:
amp_ac_yypush_parse (ps1, START_SPACE_LIST, &yylval_param, &yylloc_param, scanner, NULL);
amp_ac_yypush_parse (ps1, START_SPACE_LIST, &yylval_param, &yylloc_param, scanner);
yy_push_state (SPACE_LIST, scanner->scanner);
break;
default:
Expand All @@ -438,44 +437,10 @@ amp_ac_scanner_parse_token (AmpAcScanner *scanner, AnjutaToken *token, gint star
do
{
gint yychar = ac_yylex (&yylval_param, &yylloc_param, scanner->scanner);
AnjutaToken *last = NULL;

yylloc_param = yylval_param;
status = amp_ac_yypush_parse (ps1, yychar, &yylval_param, &yylloc_param, scanner, &last);
status = amp_ac_yypush_parse (ps1, yychar, &yylval_param, &yylloc_param, scanner);

#if 0
if ((status == 0) || (last != NULL))
{
//printf ("\n: ");
for (;;)
{
YYSTYPE yylval_param;
YYLTYPE yylloc_param;
gint yychar;
AnjutaToken *next;

yytok = anjuta_token_next_lex (yytok);
if (yytok != NULL)
{
yychar = anjuta_token_get_type (yytok);
}
else
{
yychar = 0;
}

yylval_param = yytok;
//printf ("2:%d (%.*s) ", yychar, yytok == NULL ? 0 : anjuta_token_get_length (yytok), yytok == NULL ? "" : anjuta_token_evaluate (yytok));
yylloc_param = yylval_param;
status = amp_ac_yypush_parse (ps2, yychar, &yylval_param, &yylloc_param, scanner, NULL);
if (status != YYPUSH_MORE) break;
if (yytok == last) break;
}
//printf ("\n");

last = NULL;
}
#endif
} while (status == YYPUSH_MORE);
amp_ac_yypstate_delete (ps1);
//amp_ac_yypstate_delete (ps2);
Expand Down
25 changes: 4 additions & 21 deletions src/mk-parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
%token _SILENT
%token _EXPORT_ALL_VARIABLES
%token _NOTPARALLEL
%token FIRST_PASS
%token SECOND_PASS

%defines

Expand All @@ -78,7 +76,6 @@
/*%glr-parser*/

%parse-param {void* scanner}
%parse-param {AnjutaToken** last}
%lex-param {void* scanner}

%name-prefix="mkp_yy"
Expand All @@ -95,7 +92,7 @@

//mkp_yydebug = 1;

static void mkp_yyerror (YYLTYPE *loc, MkpScanner *scanner, AnjutaToken **last, char const *s);
static void mkp_yyerror (YYLTYPE *loc, MkpScanner *scanner, char const *s);
static void mkp_special_target (AnjutaToken *list);
static gint mkp_special_prerequisite (AnjutaToken *token);

Expand All @@ -105,22 +102,8 @@ static gint mkp_special_prerequisite (AnjutaToken *token);
%%

file:
FIRST_PASS first_pass
| SECOND_PASS second_pass
;

first_pass:
all_token
| EOL
| first_pass all_token
| first_pass EOL {
*last = $2;
}
;

second_pass:
statement
| second_pass statement
| file statement
;

statement:
Expand Down Expand Up @@ -454,9 +437,9 @@ equal_token:
%%

static void
mkp_yyerror (YYLTYPE *loc, MkpScanner *scanner, AnjutaToken **last, char const *s)
mkp_yyerror (YYLTYPE *loc, MkpScanner *scanner, char const *s)
{
mkp_scanner_yyerror (loc, scanner, last, s);
mkp_scanner_yyerror (loc, scanner, s);
}

static gint
Expand Down
43 changes: 2 additions & 41 deletions src/mk-scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ mkp_scanner_update_variable (MkpScanner *scanner, AnjutaToken *variable)
}

void
mkp_scanner_yyerror (YYLTYPE *loc, MkpScanner *scanner, AnjutaToken **last, char const *s)
mkp_scanner_yyerror (YYLTYPE *loc, MkpScanner *scanner, char const *s)
{
AnjutaTokenFileLocation location;
gboolean found;
Expand Down Expand Up @@ -488,7 +488,6 @@ mkp_scanner_parse_token (MkpScanner *scanner, AnjutaToken *token, GError **error
else
{
mkp_yypstate *ps1;
mkp_yypstate *ps2;
gint status;
YYSTYPE yylval_param;
YYLTYPE yylloc_param;
Expand All @@ -502,54 +501,16 @@ mkp_scanner_parse_token (MkpScanner *scanner, AnjutaToken *token, GError **error
scanner->buffer = buffer;

ps1 = mkp_yypstate_new ();
ps2 = mkp_yypstate_new ();
mkp_yypush_parse (ps1, FIRST_PASS, &yylval_param, &yylloc_param, scanner, NULL);
mkp_yypush_parse (ps2, SECOND_PASS, &yylval_param, &yylloc_param, scanner, NULL);
do
{
gint yychar = mkp_mk_yylex (&yylval_param, &yylloc_param, scanner->scanner);
AnjutaToken *last = NULL;

yylloc_param = yylval_param;
status = mkp_yypush_parse (ps1, yychar, &yylval_param, &yylloc_param, scanner, &last);

if ((status == 0) || (last != NULL))
{
//printf ("\n: ");
for (;;)
{
YYSTYPE yylval_param;
YYLTYPE yylloc_param;
gint yychar;
AnjutaToken *next;

yytok = anjuta_token_next_lex (yytok);
if (yytok != NULL)
{
yychar = anjuta_token_get_type (yytok);
}
else
{
yychar = 0;
}

yylval_param = yytok;
//printf ("2:%d (%.*s) ", yychar, yytok == NULL ? 0 : anjuta_token_get_length (yytok), yytok == NULL ? "" : anjuta_token_evaluate (yytok));
yylloc_param = yylval_param;
status = mkp_yypush_parse (ps2, yychar, &yylval_param, &yylloc_param, scanner, NULL);
if (status != YYPUSH_MORE) break;
if (yytok == last) break;
}
//printf ("\n");

last = NULL;
}
status = mkp_yypush_parse (ps1, yychar, &yylval_param, &yylloc_param, scanner);
} while (status == YYPUSH_MORE);
mkp_yypstate_delete (ps1);
mkp_yypstate_delete (ps2);

return TRUE;
//return mkp_yyparse (scanner) == 0;
}
}

Expand Down
5 changes: 3 additions & 2 deletions tests/makefile.lst
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
VARIABLE: CFLAGS = -g -Wall
VARIABLE: OBJECTS = foobar.o
VARIABLE: OBJECTS = foo.o bar.o
VARIABLE: LDFLAGS = -Wl,-rpath,/usr/local/lib
VARIABLE: CC = gcc
VARIABLE: LIBS =
VARIABLE: INCFLAGS =
GROUP (0): makefile
TARGET (0:0): foobar
SOURCE (0:0:0): foobar.c
SOURCE (0:0:0): foo.c
SOURCE (0:0:1): bar.c
2 changes: 1 addition & 1 deletion tests/makefile/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

CC = gcc
CFLAGS = -g -Wall
OBJECTS = foobar.o
OBJECTS = foo.o bar.o
INCFLAGS =
LDFLAGS = -Wl,-rpath,/usr/local/lib
LIBS =
Expand Down

0 comments on commit a402de3

Please sign in to comment.