Small update of German translation
[geany-mirror.git] / ctags / parsers / abaqus.c
blobea71581e06418d7f363eae1a001867f80b24f3ec
1 /*
2 * Copyright (c) 2013, Baptiste Pierrat
4 * This source code is released for free distribution under the terms of the
5 * GNU General Public License version 2 or (at your opinion) any later version.
7 * This module contains functions for generating tags for source files
8 * for Abaqus inp files (https://en.wikipedia.org/wiki/Abaqus).
9 */
12 * INCLUDE FILES
14 #include "general.h" /* must always come first */
16 #include <ctype.h>
17 #include <string.h>
19 #include "parse.h"
20 #include "read.h"
21 #include "vstring.h"
22 #include "routines.h"
25 * DATA DEFINITIONS
27 typedef enum {
28 K_PART,
29 K_ASSEMBLY,
30 K_STEP
31 } AbaqusKind;
33 static kindDefinition AbaqusKinds[] = {
34 { true, 'p', "part", "Parts" },
35 { true, 'a', "assembly", "Assembly" },
36 { true, 's', "step", "Steps" }
40 * FUNCTION DEFINITIONS
43 static int getWord(const char *ref, const char **ptr)
45 const char *p = *ptr;
47 while ((*ref != '\0') && (*p != '\0') && (tolower(*ref) == tolower(*p))) ref++, p++;
49 if (*ref) return false;
51 *ptr = p;
52 return true;
56 static void createTag(AbaqusKind kind, const char *buf)
58 vString *name;
60 if (*buf == '\0') return;
62 buf = strstr(buf, "=");
63 if (buf == NULL) return;
65 buf += 1;
67 if (*buf == '\0') return;
69 name = vStringNew();
73 vStringPut(name, (int) *buf);
74 ++buf;
75 } while ((*buf != '\0') && (*buf != ','));
76 makeSimpleTag(name, kind);
77 vStringDelete(name);
81 static void findAbaqusTags(void)
83 const char *line;
85 while ((line = (const char*)readLineFromInputFile()) != NULL)
87 const char *cp = line;
89 for (; *cp != '\0'; cp++)
91 if (*cp == '*')
93 cp++;
95 /* Parts*/
96 if (getWord("part", &cp))
98 createTag(K_PART, cp);
99 continue;
101 /* Assembly */
102 if (getWord("assembly", &cp))
104 createTag(K_ASSEMBLY, cp);
105 continue;
107 /* Steps */
108 if (getWord("step", &cp))
110 createTag(K_STEP, cp);
111 continue;
119 extern parserDefinition* AbaqusParser (void)
121 static const char *const extensions [] = { "inp", NULL };
122 parserDefinition * def = parserNew ("Abaqus");
123 def->kindTable = AbaqusKinds;
124 def->kindCount = ARRAY_SIZE (AbaqusKinds);
125 def->extensions = extensions;
126 def->parser = findAbaqusTags;
127 return def;