summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-11-29 17:24:15 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2013-11-29 17:24:15 +0100
commita88084e4dfecd099949192679152e1d9cc1f6853 (patch)
treeff380310e64337a82d8c64eb3bfb8e3a6dc14558
parent4dfc360d1d5db5c7f4ccfaf673d71bf8b096c2c7 (diff)
add tokenize_method action
-rw-r--r--eo_tokenizer.rl61
1 files changed, 60 insertions, 1 deletions
diff --git a/eo_tokenizer.rl b/eo_tokenizer.rl
index 6709614..f2e0454 100644
--- a/eo_tokenizer.rl
+++ b/eo_tokenizer.rl
@@ -426,12 +426,71 @@ _eo_tokenizer_accessor_get(Eo_Tokenizer *toknz, Eo_Accessor_Type type)
426 any => show_error; 426 any => show_error;
427 *|; 427 *|;
428 428
429###### TOKENIZE METHOD
430
431 action end_method_comment {
432 if (toknz->tmp.meth->comment != NULL)
433 ABORT(toknz, "method has already a comment");
434 toknz->tmp.meth->comment = _eo_tokenizer_token_get(toknz, fpc-1);
435 INF(" %s", toknz->tmp.meth->comment);
436 }
437
438 action begin_method_params {
439 INF(" params {");
440 toknz->current_nesting++;
441 fgoto tokenize_params;
442 }
443
444 action end_method_rettype {
445 if (toknz->tmp.meth->ret.type != NULL)
446 ABORT(toknz, "method '%s' has already a return type", toknz->tmp.meth->name);
447 toknz->tmp.meth->ret.type = _eo_tokenizer_token_get(toknz, fpc);
448 INF(" %s", toknz->tmp.meth->ret.type);
449 }
450
451 action end_method_rettype_comment {
452 if (toknz->tmp.meth->ret.comment != NULL)
453 ABORT(toknz, "method '%s' return type has already a comment", toknz->tmp.meth->name);
454 toknz->tmp.meth->ret.comment = _eo_tokenizer_token_get(toknz, fpc-2);
455 INF(" %s", toknz->tmp.meth->ret.comment);
456 }
457
458 action end_method_legacy {
459 toknz->tmp.meth->legacy = _eo_tokenizer_token_get(toknz, fpc);
460 }
461
462 action end_method {
463 if (eina_list_count(toknz->tmp.meth->params) == 0)
464 WRN("method '%s' has no parameters.", toknz->tmp.meth->name);
465 INF(" }");
466 toknz->tmp.kls->methods = eina_list_append(toknz->tmp.kls->methods, toknz->tmp.meth);
467 toknz->tmp.meth = NULL;
468 toknz->current_nesting--;
469 fgoto tokenize_methods;
470 }
471
472 meth_params = 'params' ws* begin_def;
473 meth_legacy = 'legacy' ws+ ident %end_method_legacy end_statement;
474 meth_rettype_comment = ws* eo_comment %end_method_rettype_comment;
475 meth_rettype = 'return' ws+ alpha+ >save_fpc (alnum_u | '*' | ws )+ %end_method_rettype end_statement meth_rettype_comment?;
476
477 tokenize_method := |*
478 ignore+; #=> show_ignore;
479 eo_comment => end_method_comment;
480 comment => show_comment;
481 meth_params => begin_method_params;
482 meth_rettype;
483 meth_legacy;
484 end_def => end_method;
485 any => show_error;
486 *|;
487
429###### TOKENIZE METHODS 488###### TOKENIZE METHODS
430 489
431 action begin_method { 490 action begin_method {
432 INF(" %s {", toknz->tmp.meth->name); 491 INF(" %s {", toknz->tmp.meth->name);
433 toknz->current_nesting++; 492 toknz->current_nesting++;
434 /* fgoto tokenize_method; */ 493 fgoto tokenize_method;
435 } 494 }
436 495
437 action end_method_name { 496 action end_method_name {