aboutsummaryrefslogtreecommitdiff
path: root/src/dhcpd-lex.l
diff options
context:
space:
mode:
Diffstat (limited to 'src/dhcpd-lex.l')
-rw-r--r--src/dhcpd-lex.l154
1 files changed, 77 insertions, 77 deletions
diff --git a/src/dhcpd-lex.l b/src/dhcpd-lex.l
index 79c7274..e1d8257 100644
--- a/src/dhcpd-lex.l
+++ b/src/dhcpd-lex.l
@@ -1,4 +1,4 @@
-/* grecs - Gray's Extensible Configuration System -*- c -*- */
+/* argot - Gray's Extensible Configuration System -*- c -*- */
%option noinput
%top {
#ifdef HAVE_CONFIG_H
@@ -6,7 +6,7 @@
#endif
}
%{
-/* grecs - Gray's Extensible Configuration System
+/* argot - Gray's Extensible Configuration System
Copyright (C) 2007-2016 Sergey Poznyakoff
Grecs is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
You should have received a copy of the GNU General Public License along
with Grecs. If not, see <http://www.gnu.org/licenses/>. */
-#include <grecs.h>
+#include <argot.h>
#include <dhcpd-gram.h>
#include <unistd.h>
#include <fcntl.h>
@@ -35,11 +35,11 @@
#define YY_USER_ACTION do { \
if (YYSTATE == 0) { \
- yylloc.beg = grecs_current_locus_point; \
+ yylloc.beg = argot_current_locus_point; \
yylloc.beg.col++; \
} \
- grecs_current_locus_point.col += yyleng; \
- yylloc.end = grecs_current_locus_point; \
+ argot_current_locus_point.col += yyleng; \
+ yylloc.end = argot_current_locus_point; \
} while (0);
#define ISWS(c) ((c)==' '||(c)=='\t')
@@ -54,18 +54,18 @@ P [1-9][0-9]*
%%
/* Line directive */
-^[ \t]*#[ \t]*{P}[ \t]+\".*\".*\n { grecs_parse_line_directive_cpp(yytext,
+^[ \t]*#[ \t]*{P}[ \t]+\".*\".*\n { argot_parse_line_directive_cpp(yytext,
&yylloc,
- &grecs_current_locus_point,
+ &argot_current_locus_point,
NULL); }
-^[ \t]*#[ \t]*line[ \t].*\n { grecs_parse_line_directive(yytext,
+^[ \t]*#[ \t]*line[ \t].*\n { argot_parse_line_directive(yytext,
&yylloc,
- &grecs_current_locus_point,
+ &argot_current_locus_point,
NULL); }
/* End-of-line comments */
-#.*\n { grecs_locus_point_advance_line(grecs_current_locus_point); }
+#.*\n { argot_locus_point_advance_line(argot_current_locus_point); }
#.* /* end-of-file comment */;
-"//".*\n { grecs_locus_point_advance_line(grecs_current_locus_point); }
+"//".*\n { argot_locus_point_advance_line(argot_current_locus_point); }
"//".* /* end-of-file comment */;
"if" return DHCPD_IF;
"elsif" return DHCPD_ELSIF;
@@ -77,10 +77,10 @@ P [1-9][0-9]*
for (p = yytext, len = yyleng - 1; ISWS(*p) && len > 0; p++, len--)
;
if (len) {
- grecs_line_add(p, len);
- grecs_line_add(" ", 1);
+ argot_line_add(p, len);
+ argot_line_add(" ", 1);
}
- grecs_locus_point_advance_line(grecs_current_locus_point);
+ argot_locus_point_advance_line(argot_current_locus_point);
}
<BOOL>[^\{\n]*\{ {
char *p;
@@ -91,9 +91,9 @@ P [1-9][0-9]*
;
for (; len > 0 && ISWS(p[len-1]); len--)
;
- grecs_line_add(p, len);
+ argot_line_add(p, len);
BEGIN(INITIAL);
- yylval.string = grecs_line_finish();
+ yylval.string = argot_line_finish();
return DHCPD_EXPR;
}
@@ -103,10 +103,10 @@ P [1-9][0-9]*
for (p = yytext, len = yyleng - 1; ISWS(*p) && len > 0; p++, len--)
;
if (len) {
- grecs_line_add(p, len);
- grecs_line_add(" ", 1);
+ argot_line_add(p, len);
+ argot_line_add(" ", 1);
}
- grecs_locus_point_advance_line(grecs_current_locus_point);
+ argot_locus_point_advance_line(argot_current_locus_point);
}
<EXPR>[^;\n]*; {
char *p;
@@ -117,67 +117,67 @@ P [1-9][0-9]*
;
for (; len > 0 && ISWS(p[len-1]); len--)
;
- grecs_line_add(p, len);
+ argot_line_add(p, len);
BEGIN(INITIAL);
- yylval.string = grecs_line_finish();
+ yylval.string = argot_line_finish();
return DHCPD_EXPR;
}
/* Identifiers */
-{ID} { grecs_line_begin();
- grecs_line_add(yytext, yyleng);
- yylval.string = grecs_line_finish();
+{ID} { argot_line_begin();
+ argot_line_add(yytext, yyleng);
+ yylval.string = argot_line_finish();
return DHCPD_IDENT;
}
/* Strings */
[a-zA-Z0-9_\.\*/:@-]([a-zA-Z0-9_\./:@-][a-zA-Z0-9_\.\*/:@-]*)? {
- grecs_line_begin();
- grecs_line_add(yytext, yyleng);
- yylval.string = grecs_line_finish();
+ argot_line_begin();
+ argot_line_add(yytext, yyleng);
+ yylval.string = argot_line_finish();
return DHCPD_STRING; }
/* Quoted strings */
-\"[^\\"\n]*\" { grecs_line_begin();
- grecs_line_add(yytext + 1, yyleng - 2);
- yylval.string = grecs_line_finish();
+\"[^\\"\n]*\" { argot_line_begin();
+ argot_line_add(yytext + 1, yyleng - 2);
+ yylval.string = argot_line_finish();
return DHCPD_STRING; }
\"[^\\"\n]*\\. |
\"[^\\"\n]*\\\n { BEGIN(STR);
- grecs_line_begin();
- grecs_line_acc_grow_unescape_last(yytext + 1,
+ argot_line_begin();
+ argot_line_acc_grow_unescape_last(yytext + 1,
yyleng - 1,
&yylloc); }
\"[^\\"\n]*\n { BEGIN(STR);
- grecs_line_begin();
- grecs_line_acc_grow(yytext + 1, yyleng - 1); }
+ argot_line_begin();
+ argot_line_acc_grow(yytext + 1, yyleng - 1); }
<STR>[^\\"\n]*\\. |
-<STR>\"[^\\"\n]*\\\n { grecs_line_acc_grow_unescape_last(yytext, yyleng,
+<STR>\"[^\\"\n]*\\\n { argot_line_acc_grow_unescape_last(yytext, yyleng,
&yylloc); }
<STR>[^\\"\n]*\n |
-<STR>\"[^\\"\n]*\n { grecs_line_acc_grow(yytext, yyleng); }
+<STR>\"[^\\"\n]*\n { argot_line_acc_grow(yytext, yyleng); }
<STR>[^\\"\n]*\" { BEGIN(INITIAL);
if (yyleng > 1)
- grecs_line_add(yytext, yyleng - 1);
- yylval.string = grecs_line_finish();
+ argot_line_add(yytext, yyleng - 1);
+ yylval.string = argot_line_finish();
return DHCPD_STRING; }
{WS} ;
/* Other tokens */
-\n { grecs_locus_point_advance_line(grecs_current_locus_point); }
+\n { argot_locus_point_advance_line(argot_current_locus_point); }
[,;{}()!=] return yytext[0];
. { if (isascii(yytext[0]) && isprint(yytext[0]))
- grecs_error(&yylloc, 0,
+ argot_error(&yylloc, 0,
_("stray character %c"), yytext[0]);
else
- grecs_error(&yylloc, 0, _("stray character \\%03o"),
+ argot_error(&yylloc, 0, _("stray character \\%03o"),
(unsigned char) yytext[0]); }
%%
void
-grecs_dhcpd_begin_bool(void)
+argot_dhcpd_begin_bool(void)
{
BEGIN(BOOL);
}
void
-grecs_dhcpd_begin_expr(void)
+argot_dhcpd_begin_expr(void)
{
BEGIN(EXPR);
}
@@ -185,13 +185,13 @@ grecs_dhcpd_begin_expr(void)
struct dhcpd_input_context {
ino_t i_node;
dev_t i_dev;
- struct grecs_locus_point point;
- grecs_locus_t locus; /* Current input location */
+ struct argot_locus_point point;
+ argot_locus_t locus; /* Current input location */
YY_BUFFER_STATE state;
FILE *input;
};
-static struct grecs_list *input_stack;
+static struct argot_list *input_stack;
static ino_t i_node;
static dev_t i_dev;
@@ -211,37 +211,37 @@ cmp_context(const void *a, const void *b)
}
static int
-_push_context(const char *name, ino_t i_node, dev_t i_dev, grecs_locus_t *loc)
+_push_context(const char *name, ino_t i_node, dev_t i_dev, argot_locus_t *loc)
{
struct dhcpd_input_context ctx, *pctx;
if (!input_stack) {
- input_stack = grecs_list_create();
+ input_stack = argot_list_create();
input_stack->free_entry = free_context;
input_stack->cmp = cmp_context;
} else {
ctx.i_dev = i_dev;
ctx.i_node = i_node;
- pctx = grecs_list_locate(input_stack, &ctx);
+ pctx = argot_list_locate(input_stack, &ctx);
if (pctx) {
- grecs_error(&yylloc, 0,
+ argot_error(&yylloc, 0,
_("%s has already been included"), name);
- grecs_error(&pctx->locus, 0,
+ argot_error(&pctx->locus, 0,
_("this is where the previous inclusion occurred"));
return 1;
}
- pctx = grecs_malloc(sizeof(*pctx));
+ pctx = argot_malloc(sizeof(*pctx));
pctx->i_node = i_node;
pctx->i_dev = i_dev;
if (loc)
pctx->locus = *loc;
else
memset(&pctx->locus, 0, sizeof(pctx->locus)); /* FIXME */
- pctx->point = grecs_current_locus_point;
+ pctx->point = argot_current_locus_point;
pctx->state = YY_CURRENT_BUFFER;
pctx->input = yyin;
- grecs_list_push(input_stack, pctx);
+ argot_list_push(input_stack, pctx);
}
return 0;
}
@@ -253,22 +253,22 @@ _pop_context()
if (!yyin)
return 1;
- if (grecs_preprocessor)
+ if (argot_preprocessor)
pclose(yyin);
else
fclose(yyin);
- pctx = grecs_list_pop(input_stack);
+ pctx = argot_list_pop(input_stack);
if (!pctx) {
yyin = NULL;
return 1;
}
i_node = pctx->i_node;
i_dev = pctx->i_dev;
- grecs_current_locus_point = pctx->point;
+ argot_current_locus_point = pctx->point;
yyin = pctx->input;
yy_delete_buffer(YY_CURRENT_BUFFER);
yy_switch_to_buffer(pctx->state);
- grecs_free(pctx);
+ argot_free(pctx);
return 0;
}
@@ -279,48 +279,48 @@ yywrap()
}
int
-grecs_dhcpd_new_source(const char *name, grecs_locus_t *loc)
+argot_dhcpd_new_source(const char *name, argot_locus_t *loc)
{
struct stat st;
FILE *fp;
if (access(name, F_OK)) {
int ec = errno;
- char *tmp = grecs_find_include_file(name, 0);
+ char *tmp = argot_find_include_file(name, 0);
if (!tmp) {
- grecs_error(loc, ec, _("cannot open `%s'"), name);
+ argot_error(loc, ec, _("cannot open `%s'"), name);
return 1;
}
- name = grecs_install_text(tmp);
+ name = argot_install_text(tmp);
free(tmp);
}
fp = fopen(name, "r");
if (!fp) {
- grecs_error(loc, errno, _("cannot open `%s'"), name);
+ argot_error(loc, errno, _("cannot open `%s'"), name);
return 1;
}
if (fstat(fileno(fp), &st)) {
- grecs_error(loc, errno, _("can't state %s"), name);
+ argot_error(loc, errno, _("can't state %s"), name);
fclose(fp);
return 1;
}
- if (grecs_preprocessor) {
+ if (argot_preprocessor) {
char *cmd = NULL;
size_t size = 0;
fclose(fp);
- if (grecs_asprintf(&cmd, &size, "%s \"%s\"",
- grecs_preprocessor, name))
- grecs_alloc_die();
+ if (argot_asprintf(&cmd, &size, "%s \"%s\"",
+ argot_preprocessor, name))
+ argot_alloc_die();
fp = popen(cmd, "r");
if (!fp) {
- grecs_error(loc, errno, _("cannot open `%s'"), cmd);
- grecs_free(cmd);
+ argot_error(loc, errno, _("cannot open `%s'"), cmd);
+ argot_free(cmd);
return 1;
}
- grecs_free(cmd);
+ argot_free(cmd);
}
if (_push_context(name, st.st_ino, st.st_dev, loc)) {
@@ -330,17 +330,17 @@ grecs_dhcpd_new_source(const char *name, grecs_locus_t *loc)
i_dev = st.st_dev;
yyin = fp;
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
- grecs_current_locus_point.file = grecs_install_text(name);
- grecs_current_locus_point.line = 1;
- grecs_current_locus_point.col = 0;
+ argot_current_locus_point.file = argot_install_text(name);
+ argot_current_locus_point.line = 1;
+ argot_current_locus_point.col = 0;
return 0;
}
void
-grecs_dhcpd_close_sources()
+argot_dhcpd_close_sources()
{
while (!_pop_context())
;
- grecs_list_free(input_stack);
+ argot_list_free(input_stack);
input_stack = NULL;
}

Return to:

Send suggestions and report system problems to the System administrator.