-
Notifications
You must be signed in to change notification settings - Fork 591
/
parse.h
163 lines (139 loc) · 6.05 KB
/
parse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
*
* Copyright (c) 1998-2001, Darren Hiebert
*
* This source code is released for free distribution under the terms of the
* GNU General Public License.
*
* Private definitions for parsing support.
*/
#ifndef _PARSE_H
#define _PARSE_H
/*
* INCLUDE FILES
*/
#include "general.h" /* must always come first */
#include "parsers.h" /* contains list of parsers */
#include "strlist.h"
#include "entry.h"
/*
* MACROS
*/
#define LANG_AUTO (-1)
#define LANG_IGNORE (-2)
/*
* DATA DECLARATIONS
*/
typedef int langType;
typedef void (*createRegexTag) (const vString* const name);
typedef void (*simpleParser) (void);
typedef boolean (*rescanParser) (const unsigned int passCount);
typedef void (*parserInitialize) (langType language);
typedef int (*tagEntryFunction) (const tagEntryInfo *const tag, void *user_data);
typedef enum {
METHOD_NOT_CRAFTED = 1 << 0,
METHOD_REGEX = 1 << 1,
METHOD_XCMD = 1 << 2,
METHOD_XCMD_AVAILABLE = 1 << 3,
METHOD_XPATH = 1 << 4,
} parsingMethod;
typedef struct {
const char *const regex;
const char* const name;
const char* const kinds;
const char *const flags;
boolean *disabled;
} tagRegexTable;
typedef struct {
const char *name;
const int id;
} keywordTable;
typedef struct {
/* defined by parser */
char* name; /* name of language */
kindOption* kinds; /* tag kinds handled by parser */
unsigned int kindCount; /* size of `kinds' list */
kindOption* fileKind; /* kind for overriding the default fileKind */
const char* const* extensions; /* list of default extensions */
const char* const* patterns; /* list of default file name patterns */
parserInitialize initialize; /* initialization routine, if needed */
simpleParser parser; /* simple parser (common case) */
rescanParser parser2; /* rescanning parser (unusual case) */
unsigned int method; /* See PARSE__... definitions above */
/* used internally */
unsigned int id; /* id assigned to language */
boolean enabled; /* currently enabled? */
stringList* currentPatterns; /* current list of file name patterns */
stringList* currentExtensions; /* current list of extensions */
tagRegexTable *tagRegexTable;
unsigned int tagRegexCount;
const keywordTable *keywordTable;
unsigned int keywordCount;
unsigned int initialized:1; /* initialize() is called or not */
unsigned int tagRegexInstalled:1; /* tagRegexTable is installed or not. */
unsigned int keywordInstalled:1; /* keywordTable is installed or not. */
} parserDefinition;
typedef parserDefinition* (parserDefinitionFunc) (void);
typedef struct {
int start; /* character index in line where match starts */
size_t length; /* length of match */
} regexMatch;
typedef void (*regexCallback) (const char *line, const regexMatch *matches, unsigned int count);
/*
* FUNCTION PROTOTYPES
*/
/* Each parsers' definition function is called. The routine is expected to
* return a structure allocated using parserNew(). This structure must,
* at minimum, set the `parser' field.
*/
extern parserDefinitionFunc PARSER_LIST;
extern parserDefinition** LanguageTable;
extern unsigned int LanguageCount;
/* Legacy interface */
extern boolean includingDefineTags (void);
extern void processLegacyKindOption (const char *const parameter);
/* Language processing and parsing */
extern void makeSimpleTag (const vString* const name, kindOption* const kinds, const int kind);
extern void makeSimpleScopedTag (const vString* const name, kindOption* const kinds, const int kind, const char* scope, const char* scope2, const char *access);
extern parserDefinition* parserNew (const char* name);
extern parserDefinition* parserNewFull (const char* name, char fileKind);
extern const char *getLanguageName (const langType language);
extern kindOption* getLanguageFileKind (const langType language);
extern langType getNamedLanguage (const char *const name);
extern langType getFileLanguage (const char *const fileName);
extern void installLanguageMapDefault (const langType language);
extern void installLanguageMapDefaults (void);
extern void clearLanguageMap (const langType language);
extern void addLanguageExtensionMap (const langType language, const char* extension);
extern void addLanguagePatternMap (const langType language, const char* ptrn);
extern void printLanguageMap (const langType language);
extern void enableLanguages (const boolean state);
extern void enableLanguage (const langType language, const boolean state);
extern void initializeParsing (void);
extern void freeParserResources (void);
extern void processLanguageDefineOption (const char *const option, const char *const parameter);
extern boolean processKindOption (const char *const option, const char *const parameter);
extern void printKindOptions (void);
extern boolean parseFile (const char *const fileName);
extern void installKeywordTable (const langType language);
/* Regex interface */
#ifdef HAVE_REGEX
extern void findRegexTags (void);
extern boolean matchRegex (const vString* const line, const langType language);
#endif
extern boolean processRegexOption (const char *const option, const char *const parameter);
extern void addLanguageRegex (const langType language, const char* const regex);
extern void installTagRegexTable (const langType language);
extern void addTagRegex (const langType language, const char* const regex, const char* const name, const char* const kinds, const char* const flags);
extern void addCallbackRegex (const langType language, const char* const regex, const char* flags, const regexCallback callback);
extern void disableRegexKinds (const langType UNUSED language);
extern boolean enableRegexKind (const langType language, const int kind, const boolean mode);
extern void printRegexKindOptions (const langType language);
extern void freeRegexResources (void);
extern void checkRegex (void);
/* Extra stuff for Tag Manager */
extern tagEntryFunction TagEntryFunction;
extern void *TagEntryUserData;
extern void setTagEntryFunction(tagEntryFunction entry_function, void *user_data);
#endif /* _PARSE_H */
/* vi:set tabstop=4 shiftwidth=4: */