aboutsummaryrefslogtreecommitdiff
path: root/src/gram.y
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-05-23 19:18:14 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-05-23 19:18:14 +0300
commit7edbff3372dfd387e4f6da45f43ba8ada6dfbe43 (patch)
treed3049ab8c07773c82104e720f92be555ae276179 /src/gram.y
parent008b71a4d58ad33cf5a41e2aa55b9393e8420531 (diff)
downloadgdbm-7edbff3372dfd387e4f6da45f43ba8ada6dfbe43.tar.gz
gdbm-7edbff3372dfd387e4f6da45f43ba8ada6dfbe43.tar.bz2
gdbmtool: accept commands from command line as well as from file
Commands can be supplied to gdbmtool in three ways: 1. From a file, using the --file (-f) option: gdbmtool -f comfile 2. From the command line, if first argument is the database name: gdbmtool test.db count \; fetch mykey \; avail Note the use of semicolon to delimit commands. 3. From the interactive shell, if neither of the above is used. * src/Makefile.am: Add new sources. * src/gdbmtool.c: Use new stream functions for input. * src/gdbmtool.h (setsource): Remove proto. (instream_t): New data type. (instream_name, instream_read) (instream_close, instream_interactive) (instream_eq): New functions. (instream_stdin_create) (instream_argv_create) (instream_file_create) (interactive, input_context_push): New protos. * src/gram.y: Accept ; in place of newline. * src/input-argv.c: New file. * src/input-file.c: New file. * src/input-rl.c: Rewrite to provide instream_t API. * src/input-std.c: Likewise. * src/lex.l: Rewrite. * tests/.gitignore: Update. * tests/Makefile.am: Add new tests. Incorporate DejaGNU tests. * tests/config/default.exp: New file. * tests/gdbmtool/base.exp: New file. * tests/gdbmtool00.at: New file. * tests/gdbmtool01.at: New file. * tests/gdbmtool02.at: New file. * tests/testsuite.at: Include new tests.
Diffstat (limited to 'src/gram.y')
-rw-r--r--src/gram.y28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/gram.y b/src/gram.y
index 57d90c5..5372795 100644
--- a/src/gram.y
+++ b/src/gram.y
@@ -71,20 +71,20 @@ stmtlist : stmt
| stmtlist stmt
;
-stmt : /* empty */ '\n'
+stmt : /* empty */ eol
{
run_last_command ();
}
- | T_CMD arglist '\n'
+ | T_CMD arglist eol
{
- if (run_command ($1, &$2) && !interactive)
+ if (run_command ($1, &$2) && !interactive ())
exit (EXIT_USAGE);
}
- | set '\n'
- | defn '\n'
- | T_BOGUS '\n'
+ | set eol
+ | defn eol
+ | T_BOGUS eol
{
- if (interactive)
+ if (interactive ())
{
yyclearin;
yyerrok;
@@ -92,9 +92,9 @@ stmt : /* empty */ '\n'
else
YYERROR;
}
- | error { end_def(); } '\n'
+ | error { end_def(); } eol
{
- if (interactive)
+ if (interactive ())
{
yyclearin;
yyerrok;
@@ -104,6 +104,10 @@ stmt : /* empty */ '\n'
}
;
+eol : '\n'
+ | ';'
+ ;
+
arglist : /* empty */
{
gdbmarglist_init (&$$, NULL);
@@ -367,3 +371,9 @@ yyerror (char const *s)
terror ("%s", s);
return 0;
}
+
+void
+gram_trace (int n)
+{
+ yydebug = 1;
+}

Return to:

Send suggestions and report system problems to the System administrator.