]>
git.saurik.com Git - bison.git/blob - src/getargs.c
890179ec5b5c3f5a72ad95c2330bc43cbb3fad8b
1 /* Parse command line arguments for bison.
2 Copyright 1984, 1986, 1989, 1992, 2000, 2001 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 it
7 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, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 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 the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
29 int locations_flag
= 0;
30 int no_lines_flag
= 0;
31 int no_parser_flag
= 0;
34 int token_table_flag
= 0;
36 int statistics_flag
= 0;
37 int yacc_flag
= 0; /* for -y */
39 extern char *program_name
;
40 const char *shortopts
= "yvdhrltknVo:b:p:S:";
41 static struct option longopts
[] =
43 /* Operation modes. */
44 {"help", no_argument
, 0, 'h'},
45 {"version", no_argument
, 0, 'V'},
46 {"yacc", no_argument
, 0, 'y'},
47 {"fixed-output-files",no_argument
, 0, 'y'},
50 {"skeleton", required_argument
, 0, 'S'},
51 {"debug", no_argument
, 0, 'd'},
52 {"locations", no_argument
, &locations_flag
, 1},
53 /* was 'a'; apparently unused -wjh */
54 {"name-prefix", required_argument
, 0, 'p'},
55 {"no-lines", no_argument
, 0, 'l'},
56 {"no-parser", no_argument
, 0, 'n'},
57 {"raw", no_argument
, 0, 'r'},
58 {"token-table", no_argument
, 0, 'k'},
61 {"defines", no_argument
, 0, 'd'},
62 {"verbose", no_argument
, 0, 'v'},
63 {"file-prefix", required_argument
, 0, 'b'},
64 {"output-file", required_argument
, 0, 'o'},
67 {"statistics", no_argument
, &statistics_flag
, 1},
71 /*---------------------------.
72 | Display the help message. |
73 `---------------------------*/
78 /* Some efforts were made to ease the translators' task, please
81 GNU bison generates parsers for LALR(1) grammars.\n"), stream
);
85 Usage: %s [OPTION]... FILE\n"), program_name
);
89 If a long option shows an argument as mandatory, then it is mandatory\n\
90 for the equivalent short option also. Similarly for optional arguments.\n"),
96 -h, --help display this help and exit\n\
97 -V, --version output version information and exit\n\
98 -y, --yacc emulate POSIX yacc\n"), stream
);
103 -S, --skeleton=FILE specify the skeleton to use\n\
104 -t, --debug instrument the parser for debugging\n\
105 --locations enable locations computation\n\
106 -p, --name-prefix=PREFIX prepend PREFIX to the external symbols\n\
107 -l, --no-lines don't generate `#line' directives\n\
108 -n, --no-parser generate the tables only\n\
109 -r, --raw number the tokens from 3\n\
110 -k, --token-table include a table of token names\n\
116 -d, --defines also produce a header file\n\
117 -v, --verbose also produce an explanation of the automaton\n\
118 -b, --file-prefix=PREFIX specify a PREFIX for output files\n\
119 -o, --output-file=FILE leave output to FILE\n"), stream
);
123 Report bugs to <bug-bison@gnu.org>.\n"), stream
);
127 /*------------------------------.
128 | Display the version message. |
129 `------------------------------*/
132 version (FILE *stream
)
134 /* Some efforts were made to ease the translators' task, please
136 fprintf (stream
, _("\
137 bison (GNU Bison) %s"), VERSION
);
142 Copyright 1984, 1986, 1989, 1992, 2000, 2001 Free Software Foundation, Inc.\n"),
146 This is free software; see the source for copying conditions. There is NO\n\
147 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
153 /*----------------------.
154 | Process the options. |
155 `----------------------*/
158 getargs (int argc
, char *argv
[])
162 while ((c
= getopt_long (argc
, argv
, shortopts
, longopts
, NULL
)) != EOF
)
166 /* Certain long options cause getopt_long to return 0. */
198 token_table_flag
= 1;
214 spec_outfile
= optarg
;
218 spec_file_prefix
= optarg
;
222 spec_name_prefix
= optarg
;
226 fprintf (stderr
, _("Try `%s --help' for more information.\n"),
233 fprintf (stderr
, _("%s: no grammar file given\n"), program_name
);
236 if (optind
< argc
- 1)
237 fprintf (stderr
, _("%s: extra arguments ignored after `%s'\n"),
238 program_name
, argv
[optind
]);
240 infile
= argv
[optind
];