summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-06-23 16:34:45 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-06-23 16:37:37 +0100
commit0fe4d4aa37088f10b082ce36864b48620ffebdb8 (patch)
tree65ca43393cc40afcd3b9e5eca91f97987d5357c9 /src
parent1d981756b9ab57344da0bce72ab317f3eae79e7c (diff)
eolian: simplify doc parsing logic a bit
Diffstat (limited to 'src')
-rw-r--r--src/lib/eolian/eo_lexer.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 24d7080..3a835e5 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -259,6 +259,7 @@ enum Doc_Tokens {
259static int 259static int
260doc_lex(Eo_Lexer *ls, Eina_Bool *term, Eina_Bool allow_since) 260doc_lex(Eo_Lexer *ls, Eina_Bool *term, Eina_Bool allow_since)
261{ 261{
262 int tokret = -1;
262 Eina_Bool contdoc = EINA_FALSE; 263 Eina_Bool contdoc = EINA_FALSE;
263 eina_strbuf_reset(ls->buff); 264 eina_strbuf_reset(ls->buff);
264 for (;; contdoc = EINA_TRUE) switch (ls->current) 265 for (;; contdoc = EINA_TRUE) switch (ls->current)
@@ -281,8 +282,8 @@ doc_lex(Eo_Lexer *ls, Eina_Bool *term, Eina_Bool allow_since)
281 } 282 }
282 while (is_newline(ls->current)) 283 while (is_newline(ls->current))
283 next_line_ws(ls); 284 next_line_ws(ls);
284 eina_strbuf_trim(ls->buff); 285 tokret = DOC_TEXT;
285 return DOC_TEXT; 286 goto exit_with_token;
286 /* escape case: for any \X, output \X 287 /* escape case: for any \X, output \X
287 * except for \\]], then output just ]] 288 * except for \\]], then output just ]]
288 */ 289 */
@@ -308,10 +309,8 @@ doc_lex(Eo_Lexer *ls, Eina_Bool *term, Eina_Bool allow_since)
308 if (ls->current == ']') 309 if (ls->current == ']')
309 { 310 {
310 /* terminate doc */ 311 /* terminate doc */
311 next_char(ls); 312 tokret = DOC_TEXT;
312 *term = EINA_TRUE; 313 goto terminated;
313 eina_strbuf_trim(ls->buff);
314 return DOC_TEXT;
315 } 314 }
316 eina_strbuf_append_char(ls->buff, ']'); 315 eina_strbuf_append_char(ls->buff, ']');
317 continue; 316 continue;
@@ -319,19 +318,18 @@ doc_lex(Eo_Lexer *ls, Eina_Bool *term, Eina_Bool allow_since)
319 case '@': 318 case '@':
320 eina_strbuf_append_char(ls->buff, '@'); 319 eina_strbuf_append_char(ls->buff, '@');
321 next_char(ls); 320 next_char(ls);
321 if (contdoc)
322 continue;
322 while (ls->current && isalpha(ls->current)) 323 while (ls->current && isalpha(ls->current))
323 { 324 {
324 eina_strbuf_append_char(ls->buff, ls->current); 325 eina_strbuf_append_char(ls->buff, ls->current);
325 next_char(ls); 326 next_char(ls);
326 } 327 }
327 if (contdoc)
328 continue;
329 if (!strcmp(eina_strbuf_string_get(ls->buff), "@since")) 328 if (!strcmp(eina_strbuf_string_get(ls->buff), "@since"))
330 { 329 {
331 /* since-token */ 330 /* since-token */
332 if (!allow_since) 331 if (!allow_since)
333 return DOC_MANGLED; 332 return DOC_MANGLED;
334 *term = EINA_TRUE;
335 eina_strbuf_reset(ls->buff); 333 eina_strbuf_reset(ls->buff);
336 skip_ws(ls); 334 skip_ws(ls);
337 while (ls->current && (ls->current == '.' || 335 while (ls->current && (ls->current == '.' ||
@@ -343,16 +341,8 @@ doc_lex(Eo_Lexer *ls, Eina_Bool *term, Eina_Bool allow_since)
343 } 341 }
344 if (!eina_strbuf_length_get(ls->buff)) 342 if (!eina_strbuf_length_get(ls->buff))
345 return DOC_UNFINISHED; 343 return DOC_UNFINISHED;
346 skip_ws(ls); 344 tokret = DOC_SINCE;
347 while (is_newline(ls->current)) 345 goto force_terminate;
348 next_line_ws(ls);
349 if (ls->current == ']')
350 next_char(ls);
351 if (ls->current != ']')
352 return DOC_MANGLED;
353 next_char(ls);
354 eina_strbuf_trim(ls->buff);
355 return DOC_SINCE;
356 } 346 }
357 /* default case - append character */ 347 /* default case - append character */
358 default: 348 default:
@@ -360,6 +350,21 @@ doc_lex(Eo_Lexer *ls, Eina_Bool *term, Eina_Bool allow_since)
360 next_char(ls); 350 next_char(ls);
361 continue; 351 continue;
362 } 352 }
353
354force_terminate:
355 skip_ws(ls);
356 while (is_newline(ls->current))
357 next_line_ws(ls);
358 if (ls->current == ']')
359 next_char(ls);
360 if (ls->current != ']')
361 return DOC_MANGLED;
362terminated:
363 next_char(ls);
364 *term = EINA_TRUE;
365exit_with_token:
366 eina_strbuf_trim(ls->buff);
367 return tokret;
363} 368}
364 369
365void doc_error(Eo_Lexer *ls, const char *msg, Eolian_Documentation *doc, Eina_Strbuf *buf) 370void doc_error(Eo_Lexer *ls, const char *msg, Eolian_Documentation *doc, Eina_Strbuf *buf)