diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-05-11 05:01:49 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-05-11 05:01:49 +0000 |
commit | 4785154fda6411a384a4ead5abb18c22bb77a8f0 (patch) | |
tree | a066bdac8c98434cb3b0edaf13ee4f48769117b9 /src/gdbmtool.h | |
parent | 19f30b06d3dacb1ab87ebc654411ea84e6123d08 (diff) | |
download | gdbm-4785154fda6411a384a4ead5abb18c22bb77a8f0.tar.gz gdbm-4785154fda6411a384a4ead5abb18c22bb77a8f0.tar.bz2 |
Rewrite gdbmtool parser.
* src/testgdbm.c: Remove.
* src/gdbmtool.c: New file.
* src/gdbmtool.h: New file.
* src/gram.y: New file.
* src/lex.l: New file.
* src/Makefile.am: Update.
Diffstat (limited to 'src/gdbmtool.h')
-rw-r--r-- | src/gdbmtool.h | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/src/gdbmtool.h b/src/gdbmtool.h new file mode 100644 index 0000000..f2807b9 --- /dev/null +++ b/src/gdbmtool.h @@ -0,0 +1,122 @@ +/* This file is part of GDBM, the GNU data base manager. + Copyright (C) 1990, 1991, 1993, 2007, 2011, 2013 Free Software Foundation, + Inc. + + GDBM is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GDBM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GDBM. If not, see <http://www.gnu.org/licenses/>. */ + +#include "autoconf.h" +#include "gdbmdefs.h" +#include "gdbm.h" +#include "gdbmapp.h" +#include <stdlib.h> +#include <stdio.h> +#include <stdarg.h> + +/* Position in input file */ +struct point +{ + char *file; /* file name */ + unsigned line; /* line number */ + unsigned col; /* column number */ +}; + +/* Location in input file */ +struct locus +{ + struct point beg, end; +}; + +typedef struct locus gdbm_yyltype_t; + +#define YYLTYPE gdbm_yyltype_t + +#define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + { \ + if (N) \ + { \ + (Current).beg = YYRHSLOC(Rhs, 1).beg; \ + (Current).end = YYRHSLOC(Rhs, N).end; \ + } \ + else \ + { \ + (Current).beg = YYRHSLOC(Rhs, 0).end; \ + (Current).end = (Current).beg; \ + } \ + } \ + while (0) + +#define YY_LOCATION_PRINT(File, Loc) \ + do \ + { \ + if ((Loc).beg.col == 0) \ + fprintf (File, "%s:%u", \ + (Loc).beg.file, \ + (Loc).beg.line); \ + else if (strcmp ((Loc).beg.file, (Loc).end.file)) \ + fprintf (File, "%s:%u.%u-%s:%u.%u", \ + (Loc).beg.file, \ + (Loc).beg.line, (Loc).beg.col, \ + (Loc).end.file, \ + (Loc).end.line, (Loc).end.col); \ + else if ((Loc).beg.line != (Loc).end.line) \ + fprintf (File, "%s:%u.%u-%u.%u", \ + (Loc).beg.file, \ + (Loc).beg.line, (Loc).beg.col, \ + (Loc).end.line, (Loc).end.col); \ + else if ((Loc).beg.col != (Loc).end.col) \ + fprintf (File, "%s:%u.%u-%u", \ + (Loc).beg.file, \ + (Loc).beg.line, (Loc).beg.col, \ + (Loc).end.col); \ + else \ + fprintf (File, "%s:%u.%u", \ + (Loc).beg.file, \ + (Loc).beg.line, \ + (Loc).beg.col); \ + } \ + while (0) + +void vparse_error (struct locus *loc, const char *fmt, va_list ap); +void parse_error (struct locus *loc, const char *fmt, ...); + +void syntax_error (const char *fmt, ...); + +void print_prompt (void); + +void setsource (const char *filename, FILE *file); + +extern int interactive; + +/* Argument to a command handler */ +struct gdbmarg +{ + struct gdbmarg *next; + char *string; +}; + +/* List of arguments */ +struct gdbmarglist +{ + struct gdbmarg *head, *tail; +}; + +void gdbmarglist_init (struct gdbmarglist *, struct gdbmarg *); +void gdbmarglist_add (struct gdbmarglist *, struct gdbmarg *); +void gdbmarglist_free (struct gdbmarglist *lst); + +struct gdbmarg *gdbmarg_new (char *); + +int run_command (const char *verb, struct gdbmarglist *arglist); + |