]>
Commit | Line | Data |
---|---|---|
a70083a3 | 1 | /* Input parser for bison |
76514394 | 2 | Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. |
a70083a3 AD |
3 | |
4 | This file is part of Bison, the GNU Compiler Compiler. | |
5 | ||
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) | |
9 | any later version. | |
10 | ||
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. | |
15 | ||
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. */ | |
20 | ||
21 | #ifndef READER_H_ | |
22 | # define READER_H_ | |
23 | ||
e9955c83 AD |
24 | typedef struct symbol_list |
25 | { | |
26 | struct symbol_list *next; | |
27 | symbol_t *sym; | |
28 | int line; | |
280a38c3 | 29 | |
e9955c83 AD |
30 | /* The action is attached to the LHS of a rule. */ |
31 | const char *action; | |
32 | int action_line; | |
a70083a3 | 33 | |
e9955c83 AD |
34 | symbol_t *ruleprec; |
35 | } symbol_list; | |
36 | ||
37 | # include "parse-gram.h" | |
38 | ||
39 | typedef int location_t; | |
40 | ||
41 | /* Initialize LOC. */ | |
42 | # define LOCATION_RESET(Loc) \ | |
43 | (Loc).first_column = (Loc).first_line = 1; \ | |
44 | (Loc).last_column = (Loc).last_line = 1; | |
45 | ||
46 | /* Advance of NUM columns. */ | |
47 | # define LOCATION_COLUMNS(Loc, Num) \ | |
48 | (Loc).last_column += Num; | |
49 | ||
50 | /* Advance of NUM lines. */ | |
51 | # define LOCATION_LINES(Loc, Num) \ | |
52 | (Loc).last_column = 1; \ | |
53 | (Loc).last_line += Num; | |
54 | ||
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; | |
59 | ||
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); \ | |
70 | else \ | |
71 | fprintf (Out, "%d.%d", (Loc).first_line, (Loc).first_column) | |
a70083a3 | 72 | |
e9955c83 AD |
73 | typedef struct gram_control_s |
74 | { | |
75 | int errcode; | |
76 | } gram_control_t; | |
77 | ||
78 | /* From the scanner. */ | |
79 | extern FILE *gram_in; | |
80 | extern int gram__flex_debug; | |
4cdb01db | 81 | void scanner_last_string_free PARAMS ((void)); |
1d6412ad | 82 | void scanner_initialize PARAMS ((void)); |
4cdb01db | 83 | void scanner_free PARAMS ((void)); |
e9955c83 AD |
84 | |
85 | # define YY_DECL \ | |
86 | int gram_lex (yystype *yylval, yyltype *yylloc, \ | |
87 | gram_control_t *yycontrol) | |
88 | YY_DECL; | |
89 | ||
90 | ||
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); | |
96 | ||
97 | char *get_type_name PARAMS ((int n, symbol_list *rule)); | |
98 | extern int typed; | |
99 | ||
100 | /* From reader.c. */ | |
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, | |
111 | int line)); | |
112 | extern symbol_list *current_rule; | |
113 | void reader PARAMS ((void)); | |
a70083a3 AD |
114 | |
115 | #endif /* !READER_H_ */ |