]>
git.saurik.com Git - bison.git/blob - src/getargs.c
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;
33 int token_table_flag
= 0;
35 int statistics_flag
= 0;
36 int yacc_flag
= 0; /* for -y */
38 extern char *program_name
;
39 const char *shortopts
= "yvdhrltknVo:b:p:S:";
40 static struct option longopts
[] =
42 /* Operation modes. */
43 {"help", no_argument
, 0, 'h'},
44 {"version", no_argument
, 0, 'V'},
45 {"yacc", no_argument
, 0, 'y'},
46 {"fixed-output-files",no_argument
, 0, 'y'},
49 {"skeleton", required_argument
, 0, 'S'},
50 {"debug", no_argument
, 0, 'd'},
51 {"locations", no_argument
, &locations_flag
, 1},
52 /* was 'a'; apparently unused -wjh */
53 {"name-prefix", required_argument
, 0, 'p'},
54 {"no-lines", no_argument
, 0, 'l'},
55 {"no-parser", no_argument
, 0, 'n'},
56 {"raw", no_argument
, 0, 'r'},
57 {"token-table", no_argument
, 0, 'k'},
60 {"defines", no_argument
, 0, 'd'},
61 {"verbose", no_argument
, 0, 'v'},
62 {"file-prefix", required_argument
, 0, 'b'},
63 {"output-file", required_argument
, 0, 'o'},
66 {"statistics", no_argument
, &statistics_flag
, 1},
70 /*---------------------------.
71 | Display the help message. |
72 `---------------------------*/
77 /* Some efforts were made to ease the translators' task, please
80 GNU bison generates parsers for LALR(1) grammars.\n"), stream
);
84 Usage: %s [OPTION]... FILE\n"), program_name
);
88 If a long option shows an argument as mandatory, then it is mandatory\n\
89 for the equivalent short option also. Similarly for optional arguments.\n"),
95 -h, --help display this help and exit\n\
96 -V, --version output version information and exit\n\
97 -y, --yacc emulate POSIX yacc\n"), stream
);
102 -S, --skeleton=FILE specify the skeleton to use\n\
103 -t, --debug instrument the parser for debugging\n\
104 --locations enable locations computation\n\
105 -p, --name-prefix=PREFIX prepend PREFIX to the external symbols\n\
106 -l, --no-lines don't generate `#line' directives\n\
107 -n, --no-parser generate the tables only\n\
108 -k, --token-table include a table of token names\n\
114 -d, --defines also produce a header file\n\
115 -v, --verbose also produce an explanation of the automaton\n\
116 -b, --file-prefix=PREFIX specify a PREFIX for output files\n\
117 -o, --output-file=FILE leave output to FILE\n"), stream
);
121 Report bugs to <bug-bison@gnu.org>.\n"), stream
);
125 /*------------------------------.
126 | Display the version message. |
127 `------------------------------*/
130 version (FILE *stream
)
132 /* Some efforts were made to ease the translators' task, please
134 fprintf (stream
, _("\
135 bison (GNU Bison) %s"), VERSION
);
140 Copyright 1984, 1986, 1989, 1992, 2000, 2001 Free Software Foundation, Inc.\n"),
144 This is free software; see the source for copying conditions. There is NO\n\
145 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
151 /*----------------------.
152 | Process the options. |
153 `----------------------*/
156 getargs (int argc
, char *argv
[])
160 while ((c
= getopt_long (argc
, argv
, shortopts
, longopts
, NULL
)) != EOF
)
164 /* Certain long options cause getopt_long to return 0. */
196 token_table_flag
= 1;
200 fatal (_("`%s' is no longer supported"), "--raw");
212 spec_outfile
= optarg
;
216 spec_file_prefix
= optarg
;
220 spec_name_prefix
= optarg
;
224 fprintf (stderr
, _("Try `%s --help' for more information.\n"),
231 fprintf (stderr
, _("%s: no grammar file given\n"), program_name
);
234 if (optind
< argc
- 1)
235 fprintf (stderr
, _("%s: extra arguments ignored after `%s'\n"),
236 program_name
, argv
[optind
]);
238 infile
= argv
[optind
];