1 /* Input parser for bison
2 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
4 This file is part of Bison, the GNU Compiler Compiler.
6 Bison is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 Bison is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Bison; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
24 typedef struct symbol_list
26 struct symbol_list
*next
;
30 /* The action is attached to the LHS of a rule. */
37 # include "parse-gram.h"
39 typedef int location_t
;
42 # define LOCATION_RESET(Loc) \
43 (Loc).first_column = (Loc).first_line = 1; \
44 (Loc).last_column = (Loc).last_line = 1;
46 /* Advance of NUM columns. */
47 # define LOCATION_COLUMNS(Loc, Num) \
48 (Loc).last_column += Num;
50 /* Advance of NUM lines. */
51 # define LOCATION_LINES(Loc, Num) \
52 (Loc).last_column = 1; \
53 (Loc).last_line += Num;
55 /* Restart: move the first cursor to the last position. */
56 # define LOCATION_STEP(Loc) \
57 (Loc).first_column = (Loc).last_column; \
58 (Loc).first_line = (Loc).last_line;
60 /* Output LOC on the stream OUT. */
61 # define LOCATION_PRINT(Out, Loc) \
62 fprintf (stderr, "%s:", infile); \
63 if ((Loc).first_line != (Loc).last_line) \
64 fprintf (Out, "%d.%d-%d.%d", \
65 (Loc).first_line, (Loc).first_column, \
66 (Loc).last_line, (Loc).last_column - 1); \
67 else if ((Loc).first_column < (Loc).last_column - 1) \
68 fprintf (Out, "%d.%d-%d", (Loc).first_line, \
69 (Loc).first_column, (Loc).last_column - 1); \
71 fprintf (Out, "%d.%d", (Loc).first_line, (Loc).first_column)
73 typedef struct gram_control_s
78 /* From the scanner. */
80 extern int gram__flex_debug
;
81 void scanner_last_string_free
PARAMS ((void));
82 void scanner_initialize
PARAMS ((void));
83 void scanner_free
PARAMS ((void));
86 int gram_lex (yystype *yylval, yyltype *yylloc, \
87 gram_control_t *yycontrol)
91 /* From the parser. */
92 extern int gram_debug
;
93 void gram_error (gram_control_t
*control
,
94 yyltype
*loc
, const char *msg
);
95 int gram_parse (void *control
);
97 char *get_type_name
PARAMS ((int n
, symbol_list
*rule
));
101 void grammar_start_symbol_set
PARAMS ((symbol_t
*s
));
102 void prologue_augment
PARAMS ((const char *prologue
, location_t location
));
103 void epilogue_set
PARAMS ((const char *epilogue
, location_t location
));
104 void grammar_symbol_append
PARAMS ((symbol_t
*s
));
105 void grammar_rule_begin
PARAMS ((symbol_t
*lhs
));
106 void grammar_rule_end
PARAMS ((void));
107 void grammar_midrule_action
PARAMS ((void));
108 void grammar_current_rule_prec_set
PARAMS ((symbol_t
*precsym
));
109 void grammar_current_rule_symbol_append
PARAMS ((symbol_t
*symbol
));
110 void grammar_current_rule_action_append
PARAMS ((const char *action
,
112 extern symbol_list
*current_rule
;
113 void reader
PARAMS ((void));
115 #endif /* !READER_H_ */