Blame src/driver/amgc_paradigm_meta.c

fd0662
/**********************************************************/
fd0662
/*  apimagic: cparser-based API normalization utility     */
fd0662
/*  Copyright (C) 2015--2016  Z. Gilboa                   */
fd0662
/*  Released under GPLv2 and GPLv3; see COPYING.APIMAGIC. */
fd0662
/**********************************************************/
fd0662
fd0662
#include <cparser/driver/c_driver.h>
58e7b9
#include <apimagic/apimagic.h>
fd0662
fd0662
struct amgc_paradigm_meta {
fd0662
	const char * const	string;
fd0662
	int			val;
fd0662
};
fd0662
fd0662
static const struct amgc_paradigm_meta cparser_lang_std_meta[] = {
fd0662
	{"c++",			STANDARD_CXX98	},
fd0662
	{"c++98",		STANDARD_CXX98	},
fd0662
	{"c11",			STANDARD_C11	},
fd0662
	{"c1x",			STANDARD_C11	},
fd0662
	{"c89",			STANDARD_C89	},
fd0662
	{"c90",			STANDARD_C89	},
fd0662
	{"c99",			STANDARD_C99	},
fd0662
	{"c9x",			STANDARD_C99	},
fd0662
	{"gnu++98",		STANDARD_GNUXX98},
fd0662
	{"gnu11",		STANDARD_GNU11	},
fd0662
	{"gnu1x",		STANDARD_GNU11	},
fd0662
	{"gnu89",		STANDARD_GNU89	},
fd0662
	{"gnu99",		STANDARD_GNU99	},
fd0662
	{"gnu9x",		STANDARD_GNU99	},
fd0662
	{"iso9899:1990",	STANDARD_C89	},
fd0662
	{"iso9899:199409",	STANDARD_C89AMD1},
fd0662
	{"iso9899:1999",	STANDARD_C99	},
fd0662
	{"iso9899:199x",	STANDARD_C99	},
fd0662
	{"iso9899:2011",	STANDARD_C11},
fd0662
	{0,0}
fd0662
};
fd0662
fd0662
static int amgc_paradigm_member(
fd0662
	const struct amgc_paradigm_meta	meta[],
fd0662
	const char *			string)
fd0662
{
fd0662
	const struct amgc_paradigm_meta * rec;
fd0662
fd0662
	for (rec = meta; rec->string; rec++)
fd0662
		if (!(strcmp(rec->string,string)))
fd0662
			return rec->val;
fd0662
fd0662
	return -1;
fd0662
}
fd0662
fd0662
int amgc_lang_std_from_string(const char * std)
fd0662
{
fd0662
	return amgc_paradigm_member(cparser_lang_std_meta,std);
fd0662
}