/* Copyright (c) 1982 Regents of the University of California */
static char sccsid[] = "@(#)grammar.yacc 1.2 1/20/82";
* yacc grammar for debugger commands
%term ALIAS ASSIGN CALL CHFILE
%term GRIPE HELP LIST NEXT
%term STOP STOPI TRACE TRACEI
%term INT REAL NAME STRING
%left '*' '/' DIV MOD AND '&'
%type <y_int> trace TRACE TRACEI stop STOP STOPI
%type <y_op> addop mulop relop
%type <y_string> STRING FILENAME SH opt_filename
%type <y_node> command rcommand what where opt_arglist opt_cond
%type <y_node> exp_list exp boolean_exp term constant
%type <y_node> line_list line_number address_list
* There are two kinds of commands, those that can be redirected
$$ = build(O_ASSIGN, $2, $3);
$$ = build(O_CHFILE, $2);
$$ = build(O_LIST, build(O_NAME, $2));
$$ = build($1, NIL, $2, $3);
$$ = build($1, $2, NIL, $3);
$$ = build($1, NIL, NIL, $3);
| trace what where opt_cond
$$ = build($1, $2, $3, $4);
$$ = build($1, NIL, $2, $3);
$$ = build($1, $2, NIL, $3);
$$ = build($1, NIL, NIL, $2);
$$ = build(O_DELETE, $2);
$$ = build(O_WHATIS, $2);
ALIAS FILENAME opt_filename
$$ = build(O_ALIAS, $2, $3);
$$ = build(O_ALIAS, NIL, NIL);
$$ = build(O_CALL, $2, $3);
$$ = build(O_SOURCE, $2);
$$ = build(O_QLINE, $1, $2);
$$ = build(O_QLINE, cursource, $2);
| AT FILENAME line_number
$$ = build(O_QLINE, $2, $3);
first = build(O_LCON, (long) 1);
last = build(O_LCON, (long) lastlinenum);
$$ = build(O_COMMA, first, last);
$$ = build(O_COMMA, $1, $1);
| line_number ',' line_number
$$ = build(O_COMMA, $1, $3);
$$ = build(O_LCON, (long) lastlinenum);
$$ = build(O_COMMA, $1, $1);
$$ = build(O_COMMA, $1, $3);
$$ = build(O_COMMA, $1, NIL);
$$ = build(O_COMMA, $1, $3);
$$ = build(O_CALL, $1, $3);
| '+' exp %prec UNARYSIGN
| '-' exp %prec UNARYSIGN
| exp addop exp %prec '+'
| exp mulop exp %prec '*'
| exp relop exp %prec '<'
s = st_lookup(symtab, "at");
error("\"at\" is not defined");
if (strcmp(s, "syntax error") == 0) {
error("bad command syntax");
* In recovering from an error we gobble input up to a newline.
while ((t = yylex()) != '\n' && t != 0);