From 628e5914b88c9690a4222ee23ed78352fe7eb477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Granjoux?= Date: Sat, 17 Oct 2009 10:39:56 +0200 Subject: [PATCH] Use Bison push interface --- src/mk-parser.y | 4 +++- src/mk-scanner.l | 28 +++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/mk-parser.y b/src/mk-parser.y index 90e674a..1ae7faf 100644 --- a/src/mk-parser.y +++ b/src/mk-parser.y @@ -62,7 +62,9 @@ %defines -%pure_parser +%define api.pure +%define api.push_pull "push" + /* Necessary because autotools wrapper always looks for a file named "y.tab.c", * not "amp-scanner.c" diff --git a/src/mk-scanner.l b/src/mk-scanner.l index 2ddaa33..59f2743 100644 --- a/src/mk-scanner.l +++ b/src/mk-scanner.l @@ -52,7 +52,6 @@ static gint mkp_scanner_parse_end (MkpScanner *scanner); void mkp_project_update_variable (MkpProject *project, AnjutaToken *variable); void mkp_project_add_rule (MkpProject *project, AnjutaToken *rule); -gboolean mkp_ac_yyparse (MkpScanner *scanner); #define RETURN(tok) *yylval = mkp_scanner_append_token (yyextra, tok); \ return tok @@ -407,6 +406,10 @@ gboolean mkp_scanner_parse (MkpScanner *scanner, AnjutaTokenFile *file, GError **error) { gboolean ok; + gint status; + mkp_yypstate *ps; + YYSTYPE yylval_param; + YYLTYPE yylloc_param; g_return_val_if_fail (file != NULL, FALSE); @@ -417,7 +420,13 @@ mkp_scanner_parse (MkpScanner *scanner, AnjutaTokenFile *file, GError **error) scanner->buffer->begin = 0; scanner->buffer->token = NULL; - ok = mkp_yyparse (scanner) == 0; + ps = mkp_yypstate_new (); + do + { + status = mkp_yypush_parse (ps, mkp_yylex (&yylval_param, &yylloc_param, scanner), &yylval_param, &yylloc_param, scanner); + } while (status == YYPUSH_MORE); + mkp_yypstate_delete (ps); + //ok = mkp_yyparse (scanner) == 0; g_free (scanner->buffer); scanner->buffer = NULL; @@ -482,9 +491,22 @@ mkp_scanner_parse_token (MkpScanner *scanner, AnjutaToken *token, GError **error } else { + mkp_yypstate *ps; + gint status; + YYSTYPE yylval_param; + YYLTYPE yylloc_param; + scanner->buffer = buffer; - return mkp_yyparse (scanner) == 0; + ps = mkp_yypstate_new (); + do + { + status = mkp_yypush_parse (ps, mkp_yylex (&yylval_param, &yylloc_param, scanner), &yylval_param, &yylloc_param, scanner); + } while (status == YYPUSH_MORE); + mkp_yypstate_delete (ps); + + return TRUE; + //return mkp_yyparse (scanner) == 0; } }