29 |
#include "options.h" |
#include "options.h" |
30 |
|
|
31 |
/* Shorts options. */ |
/* Shorts options. */ |
32 |
const char *shortopts = "yvegdhrltknVo:b:p:S:"; |
const char *shortopts = "yvegdhr:ltknVo:b:p:S:"; |
33 |
|
|
34 |
/* A CLI option only. |
/* A CLI option only. |
35 |
Arguments is the policy: `no', `optional', `required'. |
Arguments is the policy: `no', `optional', `required'. |
52 |
(String), (Arguments##_argument), (Var), (Token), (OptionChar) }, |
(String), (Arguments##_argument), (Var), (Token), (OptionChar) }, |
53 |
|
|
54 |
|
|
55 |
const struct option_table_struct option_table[] = |
const struct option_table_s option_table[] = |
56 |
{ |
{ |
57 |
/* |
/* |
58 |
* Command line. |
* Command line. |
71 |
OPTN ("output", required, 0, 0, 'o') |
OPTN ("output", required, 0, 0, 'o') |
72 |
OPTN ("output-file", required, 0, 0, 'o') |
OPTN ("output-file", required, 0, 0, 'o') |
73 |
OPTN ("graph", optional, 0, 0, 'g') |
OPTN ("graph", optional, 0, 0, 'g') |
74 |
|
OPTN ("report", required, 0, 0, 'r') |
75 |
|
OPTN ("verbose", no, 0, 0, 'v') |
76 |
|
|
77 |
/* Hidden. */ |
/* Hidden. */ |
78 |
OPTN ("trace", no, &trace_flag, 0, 1) |
OPTN ("trace", no, &trace_flag, 0, 1) |
94 |
DRTV ("nonassoc", no, NULL, tok_nonassoc) |
DRTV ("nonassoc", no, NULL, tok_nonassoc) |
95 |
DRTV ("binary", no, NULL, tok_nonassoc) |
DRTV ("binary", no, NULL, tok_nonassoc) |
96 |
DRTV ("prec", no, NULL, tok_prec) |
DRTV ("prec", no, NULL, tok_prec) |
97 |
|
DRTV ("verbose", no, &report_flag, tok_intopt) |
98 |
DRTV ("error-verbose",no, &error_verbose, tok_intopt) |
DRTV ("error-verbose",no, &error_verbose, tok_intopt) |
99 |
|
|
100 |
/* FIXME: semantic parsers will output an `include' of an |
/* FIXME: semantic parsers will output an `include' of an |
114 |
|
|
115 |
/* Output. */ |
/* Output. */ |
116 |
BOTH ("defines", optional, &defines_flag, tok_intopt, 'd') |
BOTH ("defines", optional, &defines_flag, tok_intopt, 'd') |
|
BOTH ("verbose", no, &verbose_flag, tok_intopt, 'v') |
|
117 |
|
|
118 |
/* Operation modes. */ |
/* Operation modes. */ |
119 |
BOTH ("fixed-output-files", no, &yacc_flag, tok_intopt, 'y') |
BOTH ("fixed-output-files", no, &yacc_flag, tok_intopt, 'y') |
124 |
BOTH ("locations", no, &locations_flag, tok_intopt, 1) |
BOTH ("locations", no, &locations_flag, tok_intopt, 1) |
125 |
BOTH ("no-lines", no, &no_lines_flag, tok_intopt, 'l') |
BOTH ("no-lines", no, &no_lines_flag, tok_intopt, 'l') |
126 |
BOTH ("no-parser", no, &no_parser_flag, tok_intopt, 'n') |
BOTH ("no-parser", no, &no_parser_flag, tok_intopt, 'n') |
127 |
BOTH ("raw", no, 0, tok_obsolete, 'r') |
BOTH ("raw", no, 0, tok_obsolete, 0) |
128 |
BOTH ("skeleton", required, 0, tok_skel, 'S') |
BOTH ("skeleton", required, 0, tok_skel, 'S') |
129 |
BOTH ("token-table", no, &token_table_flag, tok_intopt, 'k') |
BOTH ("token-table", no, &token_table_flag, tok_intopt, 'k') |
130 |
|
|
155 |
if (option_table[i].access == opt_cmd_line |
if (option_table[i].access == opt_cmd_line |
156 |
|| option_table[i].access == opt_both) |
|| option_table[i].access == opt_both) |
157 |
{ |
{ |
|
/* Copy the struct information in the longoptions. */ |
|
158 |
res[j].name = option_table[i].name; |
res[j].name = option_table[i].name; |
159 |
res[j].has_arg = option_table[i].has_arg; |
res[j].has_arg = option_table[i].has_arg; |
160 |
/* When an options is declared having 'optional_argument' and |
/* When a getopt_long option has an associated variable |
161 |
a flag is specified to be set, the option is skipped on |
(member FLAG), then it is set of the VAL member value. In |
162 |
command line. So we never use a flag when a command line |
other words, we cannot expect getopt_long to store the |
163 |
option is declared 'optional_argument. */ |
argument if we also want a short option. */ |
164 |
if (res[j].has_arg == optional_argument) |
if (res[j].has_arg == optional_argument) |
165 |
res[j].flag = NULL; |
res[j].flag = NULL; |
166 |
else |
else |
167 |
res[j].flag = option_table[i].set_flag; |
res[j].flag = option_table[i].flag; |
168 |
res[j++].val = option_table[i].val; |
res[j++].val = option_table[i].val; |
169 |
} |
} |
170 |
res[number_options].name = NULL; |
res[number_options].name = NULL; |