/[bison]/bison/src/options.c
ViewVC logotype

Diff of /bison/src/options.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by akim, Thu May 2 15:06:46 2002 UTC revision 1.15 by akim, Sat May 25 16:12:40 2002 UTC
# Line 29  Line 29 
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'.
# Line 52  const char *shortopts = "yvegdhrltknVo:b Line 52  const char *shortopts = "yvegdhrltknVo:b
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.
# Line 71  const struct option_table_struct option_ Line 71  const struct option_table_struct option_
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)
# Line 92  const struct option_table_struct option_ Line 94  const struct option_table_struct option_
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
# Line 111  const struct option_table_struct option_ Line 114  const struct option_table_struct option_
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')
# Line 122  const struct option_table_struct option_ Line 124  const struct option_table_struct option_
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    
# Line 153  long_option_table_new () Line 155  long_option_table_new ()
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;

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26