1 /* 2 * Copyright (c) 2021 Jan Dolinár 3 * 4 * This source code is released for free distribution under the terms of the 5 * GNU General Public License version 2 or (at your option) any later version. 6 * 7 * This module contains macros, data decls and prototypes to generate tags for Kotlin. 8 */ 9 10 /* 11 * INCLUDE FILES 12 */ 13 14 #include "kind.h" 15 #include "peg_common.h" 16 17 18 /* 19 * MACROS 20 */ 21 #undef PCC_GETCHAR 22 #define PCC_GETCHAR(auxil) getcFromKotlinFile(auxil) 23 24 /* 25 * DATA DECLARATIONS 26 */ 27 typedef enum { 28 K_PACKAGE, 29 K_INTERFACE, 30 K_CLASS, 31 K_OBJECT, 32 K_METHOD, 33 K_TYPEALIAS, 34 K_CONSTANT, 35 K_VARIABLE, 36 K_IGNORE 37 } KotlinKind; 38 39 static kindDefinition KotlinKinds [] = { 40 { true, 'p', "package", "packages", }, 41 { true, 'i', "interface", "interfaces", }, 42 { true, 'c', "class", "classes", }, 43 { true, 'o', "object", "objects", }, 44 { true, 'm', "method", "methods", }, 45 { true, 'T', "typealias", "typealiases", }, 46 { true, 'C', "constant", "constants", }, 47 { true, 'v', "variable", "variables", }, 48 }; 49 50 struct parserCtx { 51 struct parserBaseCtx base; 52 int parenthesis_level; 53 #ifdef DEBUG 54 long fail_offset; 55 #endif 56 }; 57 58 /* 59 * FUNCTION PROTOTYPES 60 */ 61 static int getcFromKotlinFile(struct parserCtx *auxil); 62 static void makeKotlinTag (struct parserCtx *auxil, const char *name, long offset, bool pushScope); 63 #ifdef DEBUG 64 static void reportFailure(struct parserCtx *auxil, long offset); 65 static void resetFailure(struct parserCtx *auxil, long offset); 66 #else 67 #define reportFailure(AUXIL, OFFSET) 68 #define resetFailure(AUXIL, OFFSET) 69 #endif 70