1 /* 2 * 3 * Copyright (c) 2016, Masatake YAMATO 4 * Copyright (c) 2016, Red Hat, K.K. 5 * Copyright (c) 2022, Vasily Kulikov 6 * 7 * This source code is released for free distribution under the terms of the 8 * GNU General Public License version 2 or (at your option) any later version. 9 * 10 */ 11 12 #ifndef CTAGS_YAML__H 13 #define CTAGS_YAML__H 14 15 #include "general.h" 16 #include "subparser.h" 17 #include "types.h" 18 19 #ifdef HAVE_LIBYAML 20 #include <yaml.h> 21 #else 22 #define yaml_token_t void 23 #endif 24 25 struct ypathTypeStack; 26 27 typedef struct sYamlSubparser yamlSubparser; 28 struct sYamlSubparser { 29 subparser subparser; 30 void (* newTokenNotfify) (yamlSubparser *s, yaml_token_t *token); 31 struct ypathTypeStack *ypathTypeStack; 32 }; 33 #define YAML(S) ((yamlSubparser *)S) 34 35 extern void attachYamlPosition (tagEntryInfo *tag, yaml_token_t *token, bool asEndPosition); 36 37 /* 38 * Experimental Ypath code 39 */ 40 typedef struct sTagYpathTable { 41 const char * ypath; 42 int expected_state; 43 /* If INITTAGENTRY filed is non-NULL, call it for initializing 44 * a tagEntry. If it is NULL, initializing the tagEntry in usual way: 45 * call initTagEntry() defined in the main part with KIND. */ 46 int kind; 47 bool (* initTagEntry) (tagEntryInfo *, char *, void *); 48 void *data; 49 void *code; /* YAML base parser private */ 50 } tagYpathTable; 51 52 extern int ypathCompileTable (langType language, tagYpathTable *table, int keywordId); 53 extern void ypathCompileTables (langType language, tagYpathTable tables[], size_t count, int keywordId); 54 extern void ypathCompiledCodeDelete (tagYpathTable tables[], size_t count); 55 56 extern void ypathHandleToken (yamlSubparser *yaml, yaml_token_t *token, int state, tagYpathTable tables[], size_t count); 57 58 extern void ypathPushType (yamlSubparser *yaml, yaml_token_t *token); 59 extern void ypathPopType (yamlSubparser *yaml); 60 extern void ypathPopAllTypes (yamlSubparser *yaml); 61 extern void ypathFillKeywordOfTokenMaybe (yamlSubparser *yaml, yaml_token_t *token, langType lang); 62 63 extern void ypathPrintTypeStack(yamlSubparser *yaml); 64 #endif 65