/*
 * Generated by ./misc/optlib2c from optlib/pkgConfig.ctags, Don't edit this manually.
 */
#include "general.h"
#include "parse.h"
#include "routines.h"
#include "field.h"
#include "xtag.h"


static void initializePkgConfigParser (const langType language)
{

	addLanguageRegexTable (language, "main");
	addLanguageRegexTable (language, "dep");
	addLanguageRegexTable (language, "rightside");

	addLanguageTagMultiTableRegex (language, "main",
	                               "^([-a-zA-Z0-9_.]+)[\t ]*=[^\n]*",
	                               "\\1", "v", "", NULL);
	addLanguageTagMultiTableRegex (language, "main",
	                               "^Name:[\t ]*([^\n]+)",
	                               "\\1", "N", ""
		"{{\n"
		"    % Name: ... is a display name. Not a package name.\n"
		"    . :input\n"
		"    ?/ _strrchr {\n"
		"        1 add dup\n"
		"        . :input length\n"
		"        exch sub 0 string _copyinterval\n"
		"    } if\n"
		"    (.pc) _strrstr {\n"
		"        % (pkgname.pc) offset\n"
		"        0 exch 0 string _copyinterval /pkg @1 _tag _commit\n"
		"        /PkgConfig.guessedFromFileName _markextra\n"
		"    } {\n"
		"        pop\n"
		"    } ifelse\n"
		"}}", NULL);
	addLanguageTagMultiTableRegex (language, "main",
	                               "^Requires(\\.private)?:[\t ]*",
	                               "", "", "{tenter=dep}"
		"{{\n"
		"    /required\n"
		"}}", NULL);
	addLanguageTagMultiTableRegex (language, "main",
	                               "^Provides:[\t ]*",
	                               "", "", "{tenter=dep}"
		"{{\n"
		"    /provided\n"
		"}}", NULL);
	addLanguageTagMultiTableRegex (language, "main",
	                               "^Conflicts:[\t ]*",
	                               "", "", "{tenter=dep}"
		"{{\n"
		"    /conflicted\n"
		"}}", NULL);
	addLanguageTagMultiTableRegex (language, "main",
	                               "^[^\n]+|[\n]",
	                               "", "", "", NULL);
	addLanguageTagMultiTableRegex (language, "dep",
	                               "^([^[:space:]=<>!]+)[ \t]*",
	                               "\\1", "p", ""
		"{{\n"
		"    dup . exch _assignrole\n"
		"}}", NULL);
	addLanguageTagMultiTableRegex (language, "dep",
	                               "^(=|<=?|>=?|!=)[\t ]*",
	                               "", "", "{tenter=rightside}", NULL);
	addLanguageTagMultiTableRegex (language, "dep",
	                               "^[\n]",
	                               "", "", "{tleave}"
		"{{\n"
		"    pop\n"
		"}}", NULL);
	addLanguageTagMultiTableRegex (language, "dep",
	                               "^[^\n]",
	                               "", "", "", NULL);
	addLanguageTagMultiTableRegex (language, "rightside",
	                               "^([^[:space:],]+)",
	                               "", "", "", NULL);
	addLanguageTagMultiTableRegex (language, "rightside",
	                               "^[ \t,]",
	                               "", "", "{tleave}", NULL);
	addLanguageTagMultiTableRegex (language, "rightside",
	                               "^.",
	                               "", "", "{_advanceTo=0start}{tleave}", NULL);
}

extern parserDefinition* PkgConfigParser (void)
{
	static const char *const extensions [] = {
		"pc",
		NULL
	};

	static const char *const aliases [] = {
		NULL
	};

	static const char *const patterns [] = {
		NULL
	};

	static roleDefinition PkgConfigPkgRoleTable [] = {
		{ true, "required", "required" },
		{ true, "provided", "provided" },
		{ true, "conflicted", "confliected" },
	};
	static kindDefinition PkgConfigKindTable [] = {
		{
		  true, 'N', "name", "display names",
		},
		{
		  true, 'p', "pkg", "packages",
		  ATTACH_ROLES(PkgConfigPkgRoleTable),
		},
		{
		  true, 'v', "var", "variabels",
		},
	};
	static xtagDefinition PkgConfigXtagTable [] = {
		{
		  .enabled     = true,
		  .name        = "guessedFromFileName",
		  .description = "the guessed package name of the .pc file",
		},
	};

	parserDefinition* const def = parserNew ("PkgConfig");

	def->versionCurrent= 0;
	def->versionAge    = 0;
	def->enabled       = true;
	def->extensions    = extensions;
	def->patterns      = patterns;
	def->aliases       = aliases;
	def->method        = METHOD_NOT_CRAFTED|METHOD_REGEX;
	def->useCork       = CORK_QUEUE;
	def->kindTable     = PkgConfigKindTable;
	def->kindCount     = ARRAY_SIZE(PkgConfigKindTable);
	def->xtagTable     = PkgConfigXtagTable;
	def->xtagCount     = ARRAY_SIZE(PkgConfigXtagTable);
	def->initialize    = initializePkgConfigParser;

	return def;
}
