1- Source extraction program for chew.
2-  Copyright (C) 1990-2024 Free Software Foundation, Inc.
3-  This file is part of BFD, the Binary File Descriptor library.
4
5-  This program is free software; you can redistribute it and/or modify
6-  it under the terms of the GNU General Public License as published by
7-  the Free Software Foundation; either version 3 of the License, or
8-  (at your option) any later version.
9
10-  This program is distributed in the hope that it will be useful,
11-  but WITHOUT ANY WARRANTY; without even the implied warranty of
12-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13-  GNU General Public License for more details.
14
15-  You should have received a copy of the GNU General Public License
16-  along with this program; if not, write to the Free Software
17-  Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
18
19- chew.c keywords defined here put output into bfd-in2.h and libbfd.h or
20- libcoff.h, from comments in the source.  See also doc.str.
21- Output lines generally come from comment lines starting with a dot,
22- or from keywords like SYNOPSIS.  Output switches to bfd-in2.h at the
23- end of each comment.  Use INTERNAL* to output to libbfd.h.
24-
25- EXTERNAL: output to bfd-in2.h, nothing to docs
26- INTERNAL: output to libbfd.h, nothing to docs
27- CODE_FRAGMENT: output to header and docs
28- FUNCTION: output to bfd-in2.h and docs
29- INTERNAL_FUNCTION: output to libbfd.h and docs
30- DEFINITION: alias for FUNCTION, but generally doesn't have SYNOPSIS,
31-         used for structs and other random code
32- INTERNAL_DEFINITION: as above, but output to libbfd.h and docs
33- ENUM* outputs to bfd-in2.h, libbfd.h and docs.
34
35: SYNOPSIS
36          skip_past_newline
37          get_stuff_in_command
38          translatecomments
39          strip_trailing_newlines
40          remchar
41          " ATTRIBUTE_HIDDEN" internalmode @ catstrif
42          ";\n\n" catstr
43          indent
44          maybecatstr
45;
46
47- Ignore stuff that is for the docs.  Output lines starting with dots.
48: ignore
49          skip_past_newline
50          get_stuff_in_command
51          outputdots
52          maybecatstr
53          ;
54
55: CODE_FRAGMENT
56          ignore ;
57
58- Output goes to bfd-in2.h
59: EXTERNAL
60          0 internalmode ! ignore ;
61
62- Output goes to libbfd.h/libcoff.h
63: INTERNAL
64          1 internalmode ! ignore ;
65
66- input stack { a b } output b if internal, a if external
67: ifinternal
68          "" swap 1 internalmode ! maybecatstr
69          swap
70          "" swap 0 internalmode ! maybecatstr
71          catstr
72          ;
73
74- Put note in output string, regardless of internal mode.
75: COMMENT
76          skip_past_newline
77          get_stuff_in_command
78          translatecomments
79          catstr
80          ;
81
82- SENUM    enum-type-name
83- ENUM     enum-name
84- ENUMX    addl-enum-name
85- ENUMDOC  doc for preceding enums
86- ENDSENUM max-enum-name
87
88: make_enum_header
89          dup
90          "enum " swap catstr
91          "\n{\n" catstr
92          swap "  _dummy_first_" swap catstr catstr
93          ",\n" catstr
94          ;
95: make_string_table_header
96          dup
97          "#ifdef _BFD_MAKE_TABLE_" swap catstr swap
98          "\n\nstatic const char *const " swap catstr catstr
99          "_names[] = { \"@@uninitialized@@\",\n" catstr
100          ;
101: SENUM
102          skip_past_newline
103          copy_past_newline
104          remchar
105          dup
106          make_enum_header
107          swap
108          make_string_table_header
109          ifinternal
110          catstr
111          get_stuff_in_command catstr
112          translatecomments ;
113: ENDSENUM
114          skip_past_newline
115          copy_past_newline strip_trailing_newlines
116          dup
117          "  " swap catstr "\n};\n" catstr swap
118          " \"@@overflow: " swap catstr "@@\",\n};\n#endif\n\n" catstr
119          ifinternal
120          catstr
121          ;
122: make_enumerator
123          "  " swap catstr
124          ",\n" catstr
125          ;
126: make_enumerator_string
127          "  \"" swap catstr
128          "\",\n" catstr
129          ;
130: ENUM
131          skip_past_newline
132          copy_past_newline
133          remchar
134          dup
135          make_enumerator
136          swap
137          make_enumerator_string
138          ifinternal
139          ;
140: ENUMX ENUM catstr ;
141: ENUMEQ
142          skip_past_newline
143          "#define "
144          copy_past_newline remchar
145          catstr
146          " "
147          catstr
148          copy_past_newline
149          catstr
150          "" swap 0 internalmode ! maybecatstr
151          ;
152: ENUMEQX ENUMEQ catstr ;
153: ENUMDOC
154          skip_past_newline
155          get_stuff_in_command
156          strip_trailing_newlines
157          "  " wrap_comment
158          "\n" swap catstr "\n" catstr
159          - discard it if we're doing internal mode
160          "" swap 0 internalmode ! maybecatstr
161          swap
162          catstr catstr
163          ;
164: SECTION ignore ;
165: SUBSECTION ignore ;
166: SUBSUBSECTION ignore ;
167: INODE ignore ;
168: DESCRIPTION ignore ;
169: ENDDD EXTERNAL ;
170: FUNCTION EXTERNAL ;
171: INTERNAL_FUNCTION INTERNAL ;
172: DEFINITION EXTERNAL ;
173: INTERNAL_DEFINITION INTERNAL ;
174