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

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 98233b3 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
RevLine 
[7f389a5c]1#pragma once
2
3struct cfa_option {
[80d3b1b]4      int val; // reserved
[7f389a5c]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
[fd54fef]16forall(T & | { bool parse(const char *, T & ); })
[7f389a5c]17static inline void ?{}( cfa_option & this, char short_name, const char * long_name, const char * help, T & variable ) {
[80d3b1b]18      this.val        = 0;
[7f389a5c]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
[fd54fef]26forall(T &)
[7f389a5c]27static inline void ?{}( cfa_option & this, char short_name, const char * long_name, const char * help, T & variable, bool (*parse)(const char *, T & )) {
[80d3b1b]28      this.val        = 0;
[7f389a5c]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
[7874d77]36void parse_args( cfa_option options[], size_t opt_count, const char * usage, char ** & left );
[7f389a5c]37void parse_args( int argc, char * argv[], cfa_option options[], size_t opt_count, const char * usage, char ** & left );
38
[419c434]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
[d411769c]42bool parse_yesno    (const char *, bool & );
43bool parse_truefalse(const char *, bool & );
44bool parse_settrue  (const char *, bool & );
45bool parse_setfalse (const char *, bool & );
[7f389a5c]46
47bool parse(const char *, const char * & );
[7f6e9eb]48bool parse(const char *, int & );
[53e4562]49bool parse(const char *, unsigned & );
[56e8cb3]50bool parse(const char *, unsigned long & );
51bool parse(const char *, unsigned long long & );
[cd02108]52bool parse(const char *, double & );
Note: See TracBrowser for help on using the repository browser.