1 /*
2 * Generated by ./misc/optlib2c from optlib/pod.ctags, Don't edit this manually.
3 */
4 #include "general.h"
5 #include "parse.h"
6 #include "routines.h"
7 #include "field.h"
8 #include "xtag.h"
9
10
11 typedef enum {
12 K_CHAPTER,
13 K_SECTION,
14 K_SUBSECTION,
15 K_SUBSUBSECTION,
16 } PodKind;
17
18
initializePodParser(const langType language CTAGS_ATTR_UNUSED)19 static void initializePodParser (const langType language CTAGS_ATTR_UNUSED)
20 {
21 addLanguageOptscriptToHook (language, SCRIPT_HOOK_PRELUDE,
22 "{{ /kindTable [\n"
23 " /chapter /section /subsection /subsubsection\n"
24 " ] def\n"
25 "\n"
26 " % numstr:str TOLEVEL int\n"
27 " /tolevel {\n"
28 " 0 get ?1 sub\n"
29 " } def\n"
30 "\n"
31 " /depthForCork {\n"
32 " :kind kindTable exch _aindex pop\n"
33 " } def\n"
34 "\n"
35 " % endline:int goal:int scopePopUpTo -\n"
36 " /scopePopUpTo\n"
37 " {\n"
38 " {\n"
39 " _scopetop {\n"
40 " dup\n"
41 " % endline goal scope scope\n"
42 " depthForCork 2 index ge {\n"
43 " % endline goal scope\n"
44 " 2 index end:\n"
45 " _scopepop\n"
46 " } {\n"
47 " pop\n"
48 " exit\n"
49 " } ifelse\n"
50 " } {\n"
51 " exit\n"
52 " } ifelse\n"
53 " } loop\n"
54 " pop\n"
55 " pop\n"
56 " } def\n"
57 "}}");
58 }
59
PodParser(void)60 extern parserDefinition* PodParser (void)
61 {
62 static const char *const extensions [] = {
63 "pod",
64 NULL
65 };
66
67 static const char *const aliases [] = {
68 NULL
69 };
70
71 static const char *const patterns [] = {
72 NULL
73 };
74
75 static kindDefinition PodKindTable [] = {
76 {
77 true, 'c', "chapter", "chapters",
78 },
79 {
80 true, 's', "section", "sections",
81 },
82 {
83 true, 'S', "subsection", "subsections",
84 },
85 {
86 true, 't', "subsubsection", "subsubsections",
87 },
88 };
89 static tagRegexTable PodTagRegexTable [] = {
90 {"^=head([1-4])[ \t]+(.+)", "",
91 "", ""
92 "{{\n"
93 " \\2\n"
94 " kindTable \\1 tolevel get\n"
95 " 2 /start _matchloc\n"
96 " _tag _commit\n"
97 " dup :line 1 sub \\1 tolevel scopePopUpTo\n"
98 " _scopetop {\n"
99 " 1 index exch scope: _scopepush\n"
100 " } {\n"
101 " _scopepush\n"
102 " } ifelse\n"
103 "}}", NULL, false},
104 };
105
106
107 parserDefinition* const def = parserNew ("Pod");
108
109 def->enabled = true;
110 def->extensions = extensions;
111 def->patterns = patterns;
112 def->aliases = aliases;
113 def->method = METHOD_NOT_CRAFTED|METHOD_REGEX;
114 def->useCork = CORK_QUEUE;
115 def->kindTable = PodKindTable;
116 def->kindCount = ARRAY_SIZE(PodKindTable);
117 def->tagRegexTable = PodTagRegexTable;
118 def->tagRegexCount = ARRAY_SIZE(PodTagRegexTable);
119 def->defaultScopeSeparator = "\"\"";
120 def->initialize = initializePodParser;
121
122 return def;
123 }
124