source: libcfa/src/parseargs.hfa @ 53692b3

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 53692b3 was fd54fef, checked in by Michael Brooks <mlbrooks@…>, 4 years ago

Converting the project to use the new syntax for otype, dtype and ttytpe.

Changed prelude (gen), libcfa and test suite to use it. Added a simple deprecation rule of the old syntax to the parser; we might wish to support both syntaxes "officially," like with an extra CLI switch, but this measure should serve as a simple reminder for our team to try the new syntax.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1#pragma once
2
3struct cfa_option {
4      int val; // reserved
5      char short_name;
6      const char * long_name;
7      const char * help;
8      void * variable;
9      bool (*parse)(const char *, void * );
10};
11
12extern cfa_option last_option;
13
14static inline void ?{}( cfa_option & this ) {}
15
16forall(T & | { bool parse(const char *, T & ); })
17static inline void ?{}( cfa_option & this, char short_name, const char * long_name, const char * help, T & variable ) {
18      this.val        = 0;
19      this.short_name = short_name;
20      this.long_name  = long_name;
21      this.help       = help;
22      this.variable   = (void*)&variable;
23      this.parse      = (bool (*)(const char *, void * ))parse;
24}
25
26forall(T &)
27static inline void ?{}( cfa_option & this, char short_name, const char * long_name, const char * help, T & variable, bool (*parse)(const char *, T & )) {
28      this.val        = 0;
29      this.short_name = short_name;
30      this.long_name  = long_name;
31      this.help       = help;
32      this.variable   = (void*)&variable;
33      this.parse      = (bool (*)(const char *, void * ))parse;
34}
35
36void parse_args( cfa_option options[], size_t opt_count, const char * usage, char ** & left );
37void parse_args( int argc, char * argv[], cfa_option options[], size_t opt_count, const char * usage, char ** & left );
38
39void print_args_usage(cfa_option options[], size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn));
40void print_args_usage(int argc, char * argv[], cfa_option options[], size_t opt_count, const char * usage, bool error)  __attribute__ ((noreturn));
41
42bool parse_yesno    (const char *, bool & );
43bool parse_truefalse(const char *, bool & );
44bool parse_settrue  (const char *, bool & );
45bool parse_setfalse (const char *, bool & );
46
47bool parse(const char *, const char * & );
48bool parse(const char *, int & );
49bool parse(const char *, unsigned & );
50bool parse(const char *, unsigned long & );
51bool parse(const char *, unsigned long long & );
52bool parse(const char *, double & );
Note: See TracBrowser for help on using the repository browser.