diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-10-22 23:03:24 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-10-23 00:42:30 +0300 |
commit | 21ffba77b92f79a59c62728ede4ad7a4ecb5a0ee (patch) | |
tree | c3204285a3ba57d590d815c682f1113b6f48d834 /src/meta1lex.l | |
parent | eb8797c9a28f3f4e238bad89b56d331492df7828 (diff) | |
download | pies-21ffba77b92f79a59c62728ede4ad7a4ecb5a0ee.tar.gz pies-21ffba77b92f79a59c62728ede4ad7a4ecb5a0ee.tar.bz2 |
Switch to the latest Grecs.
* Makefile.am (ChangeLog): Use git2chg.awk to build it.
* NEWS: Update.
* bootstrap.conf (gnulib_modules): Grecs does not depend on gnulib any more.
* configure.ac: Version 1.2.90.
Define GRECS_HOST_PROJECT_INCLUDES, remove grecs Makefiles from
AC_CONFIG_FILES: it is now done by GRECS_SETUP itself.
* gnulib.modules (gitlog-to-changelog,argp): Remove.
(configmake): New module.
* grecs: Update to a52ab6c6.
* lib/libpies.h: Remove redefinitions of _() and N_().
* src/Makefile.am: Update for the recent grecs.
* src/acl.c: Rewrite using Grecs support for lists and symtabs.
* src/acl.h: Likewise.
* src/diag.c: Likewise.
* src/inetd.c: Likewise.
* src/meta1gram.y: Likewise.
* src/meta1lex.h: Likewise.
* src/meta1lex.l: Likewise.
* src/pies.c: Likewise.
* src/pies.h: Likewise.
* src/progman.c: Likewise.
* src/userprivs.c: Likewise.
Diffstat (limited to 'src/meta1lex.l')
-rw-r--r-- | src/meta1lex.l | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/src/meta1lex.l b/src/meta1lex.l index 4eca9e2..7faaf41 100644 --- a/src/meta1lex.l +++ b/src/meta1lex.l @@ -1,7 +1,7 @@ /* MeTA1 configuration lexer for GNU Pies. -*- c -*- */ %top { /* MeTA1 configuration lexer for GNU Pies. - Copyright (C) 2008, 2009, 2010 Sergey Poznyakoff + Copyright (C) 2008, 2009, 2010, 2011 Sergey Poznyakoff GNU Pies is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,16 +26,27 @@ %{ #include "pies.h" +#include "grecs-locus.h" #include "meta1gram.h" #include "meta1lex.h" -grecs_locus_t meta1_locus; -size_t meta1_error_count; +static struct grecs_locus_point meta1_locus_point; struct obstack meta1_stk; int meta1_stk_init; char *meta1_queue_dir; - #define yylval meta1lval + +#define YY_USER_ACTION do \ + { \ + if (YYSTATE == 0) \ + { \ + meta1lloc.beg = meta1_locus_point; \ + meta1lloc.beg.col++; \ + } \ + meta1_locus_point.col += yyleng; \ + meta1lloc.end = meta1_locus_point; \ + } \ + while (0); %} %x COMMENT STR @@ -45,10 +56,10 @@ X [0-9a-fA-F] "/*" BEGIN (COMMENT); <COMMENT>[^*\n]* /* eat anything that's not a '*' */ <COMMENT>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ -<COMMENT>\n ++meta1_locus.line; +<COMMENT>\n grecs_locus_point_advance_line(meta1_locus_point); <COMMENT>"*"+"/" BEGIN (INITIAL); /* End-of-line comments */ -#.*\n { meta1_locus.line++; } +#.*\n grecs_locus_point_advance_line(meta1_locus_point); #.* /* end-of-file comment */; /* Number */ 0[xX]{X}+ | @@ -82,18 +93,18 @@ X [0-9a-fA-F] yylval.string = meta1_line_finish (); return META1_STRING; } <STR>[^\\"\n]*\n { BEGIN (INITIAL); - meta1_parse_error (_("newline in a string")); + grecs_error (&meta1lloc, 0, _("newline in a string")); meta1_line_add (yytext, yyleng - 1); yylval.string = meta1_line_finish (); return META1_STRING; } /* Other tokens */ [ \t\f][ \t\f]* ; -\n { meta1_locus.line++; } +\n grecs_locus_point_advance_line(meta1_locus_point); [,;{}=] return yytext[0]; . { if (isascii (yytext[0]) && isprint (yytext[0])) - meta1_parse_error (_("stray character %c"), yytext[0]); + grecs_error (&meta1lloc, 0, _("stray character %c"), yytext[0]); else - meta1_parse_error (_("stray character \\%03o"), + grecs_error (&meta1lloc, 0, _("stray character \\%03o"), (unsigned char) yytext[0]); } %% @@ -135,7 +146,7 @@ unescape_to_line (int c) { t = unescape_char (c); if (t == c && t != '\\' && t != '\"') - meta1_parse_error (_("unknown escape sequence '\\%c'"), c); + grecs_error (&meta1lloc, 0, _("unknown escape sequence '\\%c'"), c); } obstack_1grow (&meta1_stk, t); } @@ -182,20 +193,6 @@ meta1_string (const char *str, size_t len) } void -meta1_parse_error (const char *fmt, ...) -{ - va_list ap; - - logmsg_printf (LOG_ERR, "%s:%lu: ", meta1_locus.file, - (unsigned long) meta1_locus.line); - va_start (ap, fmt); - logmsg_vprintf (LOG_ERR, fmt, ap); - va_end (ap); - logmsg_printf (LOG_ERR, "\n"); - meta1_error_count++; -} - -void meta1_lexer_set_debug () { char *p = getenv ("META1_DEBUG_LEX"); @@ -217,15 +214,17 @@ meta1_config_parse (const char *name) _("%s: cannot open file: %s"), name, strerror (errno)); return 1; } - meta1_locus.file = meta1_string (name, strlen (name)); - meta1_locus.line = 1; + meta1_locus_point.file = meta1_string (name, strlen (name)); + meta1_locus_point.line = 1; + meta1_locus_point.col = 0; meta1_lexer_set_debug (); meta1_parser_set_debug (); yyrestart (fp); + grecs_error_count = 0; rc = meta1parse (); fclose (fp); - if (meta1_error_count) + if (grecs_error_count) rc = 1; return rc; } |