~vcs-imports/gawk/master

40 by Arnold D. Robbins
Bring latest byte code gawk into git. Hurray!
1
/*
2
 * cmd.h - definitions for command parser
3
 */
4
5
/* 
408.5.129 by Arnold D. Robbins
Update copyright years on files changed in 2014.
6
 * Copyright (C) 2004, 2010, 2011, 2013, 2014 the Free Software Foundation, Inc.
40 by Arnold D. Robbins
Bring latest byte code gawk into git. Hurray!
7
 * 
8
 * This file is part of GAWK, the GNU implementation of the
9
 * AWK Programming Language.
10
 * 
11
 * GAWK is free software; you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation; either version 2 of the License, or
14
 * (at your option) any later version.
15
 * 
16
 * GAWK is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 * 
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
24
 */
25
26
#ifdef HAVE_LIBREADLINE
27
#include <readline/readline.h>
28
#include <readline/history.h>
29
extern char **command_completion(const char *text, int start, int end);
30
extern void initialize_pager(FILE *fp); /* debug.c */
281.1.1 by john haque
Speed/memory performance improvements.
31
extern NODE *get_function(void);
40 by Arnold D. Robbins
Bring latest byte code gawk into git. Hurray!
32
#else
33
#define initialize_pager(x)		/* nothing */
34
#define add_history(x)		/* nothing */
35
#endif
36
37
extern int gprintf(FILE *fp, const char *format, ...);
38
extern jmp_buf pager_quit_tag;
319.1.9 by Arnold D. Robbins
Move to use of bool type, true, false, everywhere.
39
extern bool pager_quit_tag_valid;
40 by Arnold D. Robbins
Bring latest byte code gawk into git. Hurray!
40
387 by Arnold D. Robbins
Considerable additional portability fixes.
41
extern bool output_is_tty;
40 by Arnold D. Robbins
Bring latest byte code gawk into git. Hurray!
42
extern int input_fd;
319.1.9 by Arnold D. Robbins
Move to use of bool type, true, false, everywhere.
43
extern bool input_from_tty;
40 by Arnold D. Robbins
Bring latest byte code gawk into git. Hurray!
44
extern FILE *out_fp;
277.1.134 by Arnold D. Robbins
Minor cleanups in debugger.
45
extern char *dbg_prompt;
46
extern char *commands_prompt;
47
extern char *eval_prompt;
48
extern char *dgawk_prompt;
40 by Arnold D. Robbins
Bring latest byte code gawk into git. Hurray!
49
50
enum argtype {
51
	D_illegal,
52
53
	/* commands */
54
	D_backtrace,
55
	D_break,
56
	D_clear,
57
	D_commands,
58
	D_condition,
59
	D_continue,
60
	D_delete,
61
	D_disable,
62
	D_display,
63
	D_down,
64
	D_dump,
65
	D_enable,
66
	D_end,
67
	D_eval,
68
	D_finish,
69
	D_frame,
70
	D_help,
71
	D_ignore,
72
	D_info,
73
	D_list,
74
	D_next,
75
	D_nexti,
76
	D_option,
77
	D_print,
78
	D_printf,
79
	D_quit,
80
	D_return,
81
	D_run,
82
	D_save,
83
	D_set,
84
	D_silent,
85
	D_source,
86
	D_step,
87
	D_stepi,
88
	D_tbreak,
89
	D_trace,
90
	D_undisplay,
91
	D_until,
92
	D_unwatch,
93
	D_up,
94
	D_watch,
95
96
	/* arguments */
97
	D_argument,
98
	D_int,
99
	D_string,
100
	D_variable,
101
	D_node,
102
	D_field,
103
	D_array,
104
	D_subscript,
105
	D_func,
106
	D_range
107
};
108
109
/* non-number arguments to commands */ 
110
111
enum nametypeval {
408.5.92 by Arnold D. Robbins
Continue to straighten out enum usage.
112
	A_NONE = 0,
113
	A_ARGS,
40 by Arnold D. Robbins
Bring latest byte code gawk into git. Hurray!
114
	A_BREAK,
115
	A_DEL,
116
	A_DISPLAY,
117
	A_FRAME,
118
	A_FUNCTIONS,
119
	A_LOCALS,
120
	A_ONCE,
121
	A_SOURCE,
122
	A_SOURCES,
123
	A_TRACE_ON,
124
	A_TRACE_OFF,
125
	A_VARIABLES,
126
	A_WATCH
127
};
128
129
typedef struct cmd_argument {
130
	struct cmd_argument *next;
131
	enum argtype type;
132
	union {
133
		long lval;
134
		char *sval;
135
		NODE *nodeval;
136
	} value;
137
138
#define a_int       value.lval	/* type = D_int or D_range */ 
139
#define a_argument  value.lval	/* type = D_argument */
140
#define a_string  value.sval	/* type = D_string, D_array, D_subscript or D_variable */
141
#define a_node    value.nodeval /* type = D_node, D_field or D_func */
142
277.1.134 by Arnold D. Robbins
Minor cleanups in debugger.
143
	int a_count;		/* subscript count for D_subscript and D_array */
40 by Arnold D. Robbins
Bring latest byte code gawk into git. Hurray!
144
} CMDARG;
145
146
typedef int (*Func_cmd)(CMDARG *, int);
147
148
struct cmdtoken {
149
	const char *name;
150
	char *abbrvn;	/* abbreviation */
151
	enum argtype type;
152
	int class;
153
	Func_cmd cf_ptr;
154
	const char *help_txt;
155
};
156
157
/* command.c */
158
extern void free_cmdarg(CMDARG *list);
159
extern Func_cmd get_command(int ctype);
160
extern const char *get_command_name(int ctype);
161
162
/* debug.c */
163
extern void d_error(const char *mesg, ...);
164
165
/* command.c */
166
extern int find_option(char *name);
167
extern void option_help(void);
168
extern char *(*read_a_line)(const char *prompt);
169
extern char *read_commands_string(const char *prompt);
170
extern int in_cmd_src(const char *);
171
extern int get_eof_status(void);
319.1.9 by Arnold D. Robbins
Move to use of bool type, true, false, everywhere.
172
extern void push_cmd_src(int fd, bool istty, char * (*readfunc)(const char *),
277.1.134 by Arnold D. Robbins
Minor cleanups in debugger.
173
		int (*closefunc)(int), int cmd, int eofstatus);
40 by Arnold D. Robbins
Bring latest byte code gawk into git. Hurray!
174
extern int pop_cmd_src(void);
319.1.9 by Arnold D. Robbins
Move to use of bool type, true, false, everywhere.
175
extern int has_break_or_watch_point(int *pnum, bool any);
40 by Arnold D. Robbins
Bring latest byte code gawk into git. Hurray!
176
extern int do_list(CMDARG *arg, int cmd);
177
extern int do_info(CMDARG *arg, int cmd);
178
extern int do_print_var(CMDARG *arg, int cmd);
179
extern int do_backtrace(CMDARG *arg, int cmd);
180
extern int do_breakpoint(CMDARG *arg, int cmd);
181
extern int do_tmp_breakpoint(CMDARG *arg, int cmd);
182
extern int do_delete_breakpoint(CMDARG *arg, int cmd);
183
extern int do_enable_breakpoint(CMDARG *arg, int cmd);
184
extern int do_disable_breakpoint(CMDARG *arg, int cmd) ;
185
extern int do_ignore_breakpoint(CMDARG *arg, int cmd) ;
186
extern int do_run(CMDARG *arg, int cmd);
187
extern int do_quit(CMDARG *arg, int cmd);
188
extern int do_continue(CMDARG *arg, int cmd);
189
extern int do_step(CMDARG *arg, int cmd) ;
190
extern int do_stepi(CMDARG *arg, int cmd) ;
191
extern int do_next(CMDARG *arg, int cmd);
192
extern int do_nexti(CMDARG *arg, int cmd);
193
extern int do_clear(CMDARG *arg, int cmd);
194
extern int do_finish(CMDARG *arg, int cmd) ;
195
extern int do_help(CMDARG *arg, int cmd) ;
196
extern int do_up(CMDARG *arg, int cmd);
197
extern int do_down(CMDARG *arg, int cmd);
198
extern int do_frame(CMDARG *arg, int cmd);
199
extern int do_until(CMDARG *arg, int cmd);
200
extern int do_set_var(CMDARG *arg, int cmd);
201
extern int do_return(CMDARG *arg, int cmd);
202
extern int do_display(CMDARG *arg, int cmd);
203
extern int do_undisplay(CMDARG *arg, int cmd);
204
extern int do_watch(CMDARG *arg, int cmd);
205
extern int do_unwatch(CMDARG *arg, int cmd);
206
extern int do_dump_instructions(CMDARG *arg, int cmd);
207
extern int do_trace_instruction(CMDARG *arg, int cmd);
208
extern int do_option(CMDARG *arg, int cmd);
209
extern int do_commands(CMDARG *arg, int cmd);
210
extern int do_print_f(CMDARG *arg, int cmd);
211
extern int do_source(CMDARG *arg, int cmd);
212
extern int do_save(CMDARG *arg, int cmd);
213
extern int do_eval(CMDARG *arg, int cmd);
214
extern int do_condition(CMDARG *arg, int cmd);