aboutsummaryrefslogtreecommitdiff
path: root/src/meta1lex.l
diff options
context:
space:
mode:
Diffstat (limited to 'src/meta1lex.l')
-rw-r--r--src/meta1lex.l55
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
@@ -3,3 +3,3 @@
/* MeTA1 configuration lexer for GNU Pies.
- Copyright (C) 2008, 2009, 2010 Sergey Poznyakoff
+ Copyright (C) 2008, 2009, 2010, 2011 Sergey Poznyakoff
@@ -28,2 +28,3 @@
#include "pies.h"
+#include "grecs-locus.h"
#include "meta1gram.h"
@@ -31,4 +32,3 @@
-grecs_locus_t meta1_locus;
-size_t meta1_error_count;
+static struct grecs_locus_point meta1_locus_point;
struct obstack meta1_stk;
@@ -36,4 +36,15 @@ 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);
%}
@@ -47,6 +58,6 @@ X [0-9a-fA-F]
<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 */;
@@ -84,3 +95,3 @@ X [0-9a-fA-F]
<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);
@@ -90,8 +101,8 @@ X [0-9a-fA-F]
[ \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]); }
@@ -137,3 +148,3 @@ unescape_to_line (int c)
if (t == c && t != '\\' && t != '\"')
- meta1_parse_error (_("unknown escape sequence '\\%c'"), c);
+ grecs_error (&meta1lloc, 0, _("unknown escape sequence '\\%c'"), c);
}
@@ -184,16 +195,2 @@ 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 ()
@@ -219,4 +216,5 @@ meta1_config_parse (const char *name)
}
- 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 ();
@@ -225,5 +223,6 @@ meta1_config_parse (const char *name)
yyrestart (fp);
+ grecs_error_count = 0;
rc = meta1parse ();
fclose (fp);
- if (meta1_error_count)
+ if (grecs_error_count)
rc = 1;

Return to:

Send suggestions and report system problems to the System administrator.