1 diff -up ctags-5.8/ocaml.c.me ctags-5.8/ocaml.c
2 --- ctags-5.8/ocaml.c.me 2012-08-02 12:42:21.652211192 +0200
3 +++ ctags-5.8/ocaml.c 2012-08-02 13:06:59.751283639 +0200
4 @@ -72,6 +72,7 @@ typedef enum {
12 @@ -145,7 +146,7 @@ static const ocaKeywordDesc OcamlKeyword
13 { "try" , OcaKEYWORD_try },
14 { "type" , OcaKEYWORD_type },
15 { "val" , OcaKEYWORD_val },
16 - { "value" , OcaKEYWORD_let }, /* just to handle revised syntax */
17 + { "value" , OcaKEYWORD_value }, /* just to handle revised syntax */
18 { "virtual" , OcaKEYWORD_virtual },
19 { "while" , OcaKEYWORD_while },
20 { "with" , OcaKEYWORD_with },
21 @@ -297,7 +298,6 @@ static void eatComment (lexingState * st
27 /* we've reached the end of the comment */
28 else if (*c == ')' && lastIsStar)
29 @@ -308,13 +308,33 @@ static void eatComment (lexingState * st
41 + /* OCaml has a rule which says :
43 + * "Comments do not occur inside string or character literals.
44 + * Nested comments are handled correctly."
46 + * So if we encounter a string beginning, we must parse it to
47 + * get a good comment nesting (bug ID: 3117537)
57 lastIsStar = '*' == *c;
65 @@ -554,8 +574,7 @@ static int getLastNamedIndex ( void )
67 for (i = stackIndex - 1; i >= 0; --i)
69 - if (stack[i].contextName->buffer &&
70 - strlen (stack[i].contextName->buffer) > 0)
71 + if (vStringLength (stack[i].contextName) > 0)
75 @@ -866,6 +885,11 @@ static void prepareTag (tagEntryInfo * t
76 tag->kindName = OcamlKinds[kind].name;
77 tag->kind = OcamlKinds[kind].letter;
79 + if (kind == K_MODULE)
81 + tag->lineNumberEntry = TRUE;
82 + tag->lineNumber = 1;
84 parentIndex = getLastNamedIndex ();
87 @@ -880,9 +904,12 @@ static void prepareTag (tagEntryInfo * t
88 * more information to it in the future */
89 static void addTag (vString * const ident, int kind)
91 - tagEntryInfo toCreate;
92 - prepareTag (&toCreate, ident, kind);
93 - makeTagEntry (&toCreate);
94 + if (OcamlKinds [kind].enabled && ident != NULL && vStringLength (ident) > 0)
96 + tagEntryInfo toCreate;
97 + prepareTag (&toCreate, ident, kind);
98 + makeTagEntry (&toCreate);
102 boolean needStrongPoping = FALSE;
103 @@ -942,15 +969,17 @@ static void typeRecord (vString * const
107 - * exception ExceptionName ... */
108 + * exception ExceptionName of ... */
109 static void exceptionDecl (vString * const ident, ocaToken what)
111 if (what == OcaIDENTIFIER)
113 addTag (ident, K_EXCEPTION);
115 - /* don't know what to do on else... */
117 + else /* probably ill-formed, give back to global scope */
119 + globalScope (ident, what);
121 toDoNext = &globalScope;
124 @@ -1006,7 +1035,6 @@ static void constructorValidation (vStri
126 static void typeDecl (vString * const ident, ocaToken what)
132 @@ -1046,7 +1074,6 @@ static void typeDecl (vString * const id
133 * let typeRecord handle it. */
134 static void typeSpecification (vString * const ident, ocaToken what)
140 @@ -1243,8 +1270,14 @@ static void localLet (vString * const id
141 * than the let definitions.
142 * Used after a match ... with, or a function ... or fun ...
143 * because their syntax is similar. */
144 -static void matchPattern (vString * const UNUSED (ident), ocaToken what)
145 +static void matchPattern (vString * const ident, ocaToken what)
147 + /* keep track of [], as it
148 + * can be used in patterns and can
149 + * mean the end of match expression in
150 + * revised syntax */
151 + static int braceCount = 0;
156 @@ -1252,6 +1285,14 @@ static void matchPattern (vString * cons
157 toDoNext = &mayRedeclare;
164 + case OcaKEYWORD_value:
166 + globalScope (ident, what);
171 @@ -1269,6 +1310,11 @@ static void mayRedeclare (vString * cons
175 + case OcaKEYWORD_value:
176 + /* let globalScope handle it */
177 + globalScope (ident, what);
183 @@ -1388,6 +1434,7 @@ static void classSpecif (vString * const
184 * nearly a copy/paste of globalLet. */
185 static void methodDecl (vString * const ident, ocaToken what)
191 @@ -1435,6 +1482,7 @@ vString *lastModule;
193 static void moduleSpecif (vString * const ident, ocaToken what)
198 case OcaKEYWORD_functor:
199 @@ -1566,7 +1614,7 @@ static void globalScope (vString * const
201 /* Do not touch, this is used only by the global scope
202 * to handle an 'and' */
203 - static parseNext previousParser = NULL;
204 + static parseNext previousParser = &globalScope;
208 @@ -1608,6 +1656,7 @@ static void globalScope (vString * const
209 /* val is mixed with let as global
210 * to be able to handle mli & new syntax */
212 + case OcaKEYWORD_value:
214 cleanupPreviousParser ();
215 toDoNext = &globalLet;
216 @@ -1617,7 +1666,7 @@ static void globalScope (vString * const
217 case OcaKEYWORD_exception:
218 cleanupPreviousParser ();
219 toDoNext = &exceptionDecl;
220 - previousParser = NULL;
221 + previousParser = &globalScope;
224 /* must be a #line directive, discard the
225 @@ -1769,7 +1818,7 @@ static void computeModuleName ( void )
226 if (isLowerAlpha (moduleName->buffer[0]))
227 moduleName->buffer[0] += ('A' - 'a');
229 - makeSimpleTag (moduleName, OcamlKinds, K_MODULE);
230 + addTag (moduleName, K_MODULE);
231 vStringDelete (moduleName);
234 @@ -1779,6 +1828,7 @@ static void initStack ( void )
236 for (i = 0; i < OCAML_MAX_STACK_SIZE; ++i)
237 stack[i].contextName = vStringNew ();
241 static void clearStack ( void )
242 @@ -1794,8 +1844,8 @@ static void findOcamlTags (void)
246 - computeModuleName ();
248 + computeModuleName ();
249 tempIdent = vStringNew ();
250 lastModule = vStringNew ();
251 lastClass = vStringNew ();