aboutsummaryrefslogtreecommitdiffstats
path: root/command.y
diff options
context:
space:
mode:
Diffstat (limited to 'command.y')
-rw-r--r--command.y46
1 files changed, 31 insertions, 15 deletions
diff --git a/command.y b/command.y
index 64066a02..a5a711b2 100644
--- a/command.y
+++ b/command.y
@@ -1,5 +1,5 @@
/*
- * command.y - yacc/bison parser for debugger command
+ * command.y - yacc/bison parser for debugger commands.
*/
/*
@@ -39,8 +39,8 @@ static int find_command(const char *token, size_t toklen);
static int want_nodeval = FALSE;
-static int cmd_idx = -1; /* index of current command in cmd table */
-static int repeat_idx = -1; /* index of last repeatable command in command table */
+static int cmd_idx = -1; /* index of current command in cmd table */
+static int repeat_idx = -1; /* index of last repeatable command in command table */
static CMDARG *arg_list = NULL; /* list of arguments */
static long errcount = 0;
static char *lexptr_begin = NULL;
@@ -220,8 +220,9 @@ eval_prologue
* non-terminal (empty rule action). See below.
*/
if (input_from_tty) {
- dPrompt = eval_Prompt;
- fprintf(out_fp, _("Type (g)awk statement(s). End with the command \"end\"\n"));
+ dbg_prompt = eval_prompt;
+ fprintf(out_fp,
+ _("Type (g)awk statement(s). End with the command \"end\"\n"));
rl_inhibit_completion = 1;
}
cmd_idx = -1;
@@ -256,7 +257,7 @@ eval_cmd
str[len - 2] = '\0';
}
if (input_from_tty) {
- dPrompt = in_commands ? commands_Prompt : dgawk_Prompt;
+ dbg_prompt = in_commands ? commands_prompt : dgawk_prompt;
rl_inhibit_completion = 0;
}
cmd_idx = find_command("eval", 4);
@@ -343,7 +344,7 @@ command
if (type) {
in_commands = TRUE;
if (input_from_tty) {
- dPrompt = commands_Prompt;
+ dbg_prompt = commands_prompt;
fprintf(out_fp, _("Type commands for when %s %d is hit, one per line.\n"),
(type == D_break) ? "breakpoint" : "watchpoint", num);
fprintf(out_fp, _("End with the command \"end\"\n"));
@@ -356,7 +357,7 @@ command
yyerror(_("`end' valid only in command `commands' or `eval'"));
else {
if (input_from_tty)
- dPrompt = dgawk_Prompt;
+ dbg_prompt = dgawk_prompt;
in_commands = FALSE;
}
}
@@ -685,7 +686,7 @@ node
if ((n->flags & NUMBER) == 0)
yyerror(_("non-numeric value found, numeric expected"));
else
- $2->a_node->numbr = - n->numbr;
+ negate_num(n);
$$ = $2;
}
;
@@ -1037,7 +1038,7 @@ yylex(void)
if (lexptr_begin == NULL) {
again:
- lexptr_begin = read_a_line(dPrompt);
+ lexptr_begin = read_a_line(dbg_prompt);
if (lexptr_begin == NULL) { /* EOF or error */
if (get_eof_status() == EXIT_FATAL)
exit(EXIT_FATAL);
@@ -1238,22 +1239,37 @@ err:
return D_STRING;
}
- /* assert(want_nodval == TRUE); */
-
/* look for awk number */
if (isdigit((unsigned char) tokstart[0])) {
- double d;
+ NODE *r = NULL;
errno = 0;
- d = strtod(tokstart, &lexptr);
+#ifdef HAVE_MPFR
+ if (do_mpfr) {
+ int tval;
+ r = mpg_float();
+ tval = mpfr_strtofr(r->mpg_numbr, tokstart, & lexptr, 0, ROUND_MODE);
+ IEEE_FMT(r->mpg_numbr, tval);
+ if (mpfr_integer_p(r->mpg_numbr)) {
+ /* integral value, convert to a GMP type. */
+ NODE *tmp = r;
+ r = mpg_integer();
+ mpfr_get_z(r->mpg_i, tmp->mpg_numbr, MPFR_RNDZ);
+ unref(tmp);
+ }
+ } else
+#endif
+ r = make_number(strtod(tokstart, & lexptr));
+
if (errno != 0) {
yyerror(strerror(errno));
+ unref(r);
errno = 0;
return '\n';
}
yylval = mk_cmdarg(D_node);
- yylval->a_node = make_number(d);
+ yylval->a_node = r;
append_cmdarg(yylval);
return D_NODE;
}