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


static void initializeLEXParser (const langType language)
{

	addLanguageRegexTable (language, "main");
	addLanguageRegexTable (language, "comment");
	addLanguageRegexTable (language, "codeblock");
	addLanguageRegexTable (language, "rulesec");
	addLanguageRegexTable (language, "usercode");
	addLanguageRegexTable (language, "cond");

	addLanguageTagMultiTableRegex (language, "main",
	                               "^/\\*",
	                               "", "", "{tenter=comment}", NULL);
	addLanguageTagMultiTableRegex (language, "main",
	                               "^%[sx][ \t]+",
	                               "", "", "{tenter=cond}", NULL);
	addLanguageTagMultiTableRegex (language, "main",
	                               "^%(top)?\\{",
	                               "", "", "{tenter=codeblock}{_guest=C,0end,}", NULL);
	addLanguageTagMultiTableRegex (language, "main",
	                               "^%%",
	                               "", "", "{tjump=rulesec}", NULL);
	addLanguageTagMultiTableRegex (language, "main",
	                               "^([a-zA-Z_][-a-zA-Z0-9_]*)[^\n]+\n",
	                               "\\1", "r", "", NULL);
	addLanguageTagMultiTableRegex (language, "main",
	                               "^[^\n]*\n",
	                               "", "", "", NULL);
	addLanguageTagMultiTableRegex (language, "comment",
	                               "^[^*]+",
	                               "", "", "", NULL);
	addLanguageTagMultiTableRegex (language, "comment",
	                               "^\\*/",
	                               "", "", "{tleave}", NULL);
	addLanguageTagMultiTableRegex (language, "comment",
	                               "^.",
	                               "", "", "", NULL);
	addLanguageTagMultiTableRegex (language, "codeblock",
	                               "^[^%]+",
	                               "", "", "", NULL);
	addLanguageTagMultiTableRegex (language, "codeblock",
	                               "^%\\}",
	                               "", "", "{tleave}{_guest=,,0start}", NULL);
	addLanguageTagMultiTableRegex (language, "codeblock",
	                               "^.",
	                               "", "", "", NULL);
	addLanguageTagMultiTableRegex (language, "rulesec",
	                               "^[^%]+",
	                               "", "", "", NULL);
	addLanguageTagMultiTableRegex (language, "rulesec",
	                               "^%%",
	                               "", "", "{tjump=usercode}{_guest=C,0end,}", NULL);
	addLanguageTagMultiTableRegex (language, "rulesec",
	                               "^.",
	                               "", "", "", NULL);
	addLanguageTagMultiTableRegex (language, "usercode",
	                               "^.+",
	                               "", "", "{_guest=,,0end}", NULL);
	addLanguageTagMultiTableRegex (language, "cond",
	                               "^([_a-zA-Z][_a-zA-Z0-9]*)[ \t]*",
	                               "\\1", "c", "", NULL);
	addLanguageTagMultiTableRegex (language, "cond",
	                               "^\n",
	                               "", "", "{tleave}", NULL);
	addLanguageTagMultiTableRegex (language, "cond",
	                               "^.",
	                               "", "", "", NULL);
}

extern parserDefinition* LEXParser (void)
{
	static const char *const extensions [] = {
		"lex",
		"l",
		NULL
	};

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

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

	static kindDefinition LEXKindTable [] = {
		{
		  true, 'r', "regex", "named regular expression",
		},
		{
		  true, 'c', "cond", "start or exclusive condition",
		},
	};
	static selectLanguage selectors[] = { selectLispOrLEXByLEXMarker, NULL };

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

	def->versionCurrent= 0;
	def->versionAge    = 0;
	def->enabled       = true;
	def->extensions    = extensions;
	def->patterns      = patterns;
	def->aliases       = aliases;
	def->selectLanguage= selectors;
	def->method        = METHOD_NOT_CRAFTED|METHOD_REGEX;
	def->kindTable     = LEXKindTable;
	def->kindCount     = ARRAY_SIZE(LEXKindTable);
	def->initialize    = initializeLEXParser;

	return def;
}
