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


typedef enum {
	K_CHAPTER,
	K_SECTION,
	K_SUBSECTION,
	K_SUBSUBSECTION,
} PodKind;


static void initializePodParser (const langType language CTAGS_ATTR_UNUSED)
{
	addLanguageOptscriptToHook (language, SCRIPT_HOOK_PRELUDE,
		"{{    /kindTable [\n"
		"        /chapter /section /subsection /subsubsection\n"
		"    ] def\n"
		"\n"
		"    % numstr:str TOLEVEL int\n"
		"    /tolevel {\n"
		"        0 get ?1 sub\n"
		"    } def\n"
		"\n"
		"    % cork:int DEPTHFORCORK depth:int\n"
		"    /depthForCork {\n"
		"        :kind kindTable exch _aindex pop\n"
		"    } def\n"
		"\n"
		"    % endline:int goal:int scopePopUpTo -\n"
		"    /scopePopUpTo\n"
		"    {\n"
		"        {\n"
		"            _scopetop {\n"
		"                dup\n"
		"                % endline goal scope scope\n"
		"                depthForCork 2 index ge {\n"
		"                    % endline goal scope\n"
		"                    2 index end:\n"
		"                    _scopepop\n"
		"                } {\n"
		"                    pop\n"
		"                    exit\n"
		"                } ifelse\n"
		"            } {\n"
		"                exit\n"
		"            } ifelse\n"
		"        } loop\n"
		"        pop\n"
		"        pop\n"
		"    } def\n"
		"}}");
}

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

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

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

	static kindDefinition PodKindTable [] = {
		{
		  true, 'c', "chapter", "chapters",
		},
		{
		  true, 's', "section", "sections",
		},
		{
		  true, 'S', "subsection", "subsections",
		},
		{
		  true, 't', "subsubsection", "subsubsections",
		},
	};
	static tagRegexTable PodTagRegexTable [] = {
		{"^=head([1-4])[ \t]+(.+)", "",
		"", ""
		"{{\n"
		"    \\2\n"
		"    kindTable \\1 tolevel get\n"
		"    @2\n"
		"    _tag _commit\n"
		"    dup :line 1 sub \\1 tolevel scopePopUpTo\n"
		"    _scopetop {\n"
		"        1 index exch scope: _scopepush\n"
		"    } {\n"
		"        _scopepush\n"
		"    } ifelse\n"
		"}}", NULL, false},
	};


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

	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     = PodKindTable;
	def->kindCount     = ARRAY_SIZE(PodKindTable);
	def->tagRegexTable = PodTagRegexTable;
	def->tagRegexCount = ARRAY_SIZE(PodTagRegexTable);
	def->defaultScopeSeparator = "\"\"";
	def->initialize    = initializePodParser;

	return def;
}
