summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-11-29 17:22:38 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2013-11-29 17:22:38 +0100
commit6fcba8424f8f8f606244da4d47729b1869a42bad (patch)
tree8f8f7ae213bb4cd948bf6356cc7d9f2c4933b648
parenta575460b571412b1861ccab6491938812a3cd584 (diff)
add action tokenize_methods and +_eo_tokenizer_method_get()
-rw-r--r--eo_tokenizer.rl43
1 files changed, 42 insertions, 1 deletions
diff --git a/eo_tokenizer.rl b/eo_tokenizer.rl
index 1bc1d6c..6709614 100644
--- a/eo_tokenizer.rl
+++ b/eo_tokenizer.rl
@@ -101,6 +101,17 @@ _eo_tokenizer_property_get(Eo_Tokenizer *toknz, char *p)
101 return prop; 101 return prop;
102} 102}
103 103
104static Eo_Method_Def*
105_eo_tokenizer_method_get(Eo_Tokenizer *toknz, char *p)
106{
107 Eo_Method_Def *meth = calloc(1, sizeof(Eo_Method_Def));
108 if (meth == NULL) ABORT(toknz, "calloc Eo_Method_Def failure");
109
110 meth->name = _eo_tokenizer_token_get(toknz, p);
111
112 return meth;
113}
114
104static Eo_Param_Def* 115static Eo_Param_Def*
105_eo_tokenizer_param_get(Eo_Tokenizer *toknz, char *p) 116_eo_tokenizer_param_get(Eo_Tokenizer *toknz, char *p)
106{ 117{
@@ -415,6 +426,36 @@ _eo_tokenizer_accessor_get(Eo_Tokenizer *toknz, Eo_Accessor_Type type)
415 any => show_error; 426 any => show_error;
416 *|; 427 *|;
417 428
429###### TOKENIZE METHODS
430
431 action begin_method {
432 INF(" %s {", toknz->tmp.meth->name);
433 toknz->current_nesting++;
434 /* fgoto tokenize_method; */
435 }
436
437 action end_method_name {
438 if (toknz->tmp.meth != NULL)
439 ABORT(toknz, "there is a pending method definition %s", toknz->tmp.meth->name);
440 toknz->tmp.meth = _eo_tokenizer_method_get(toknz, fpc);
441 }
442
443 action end_methods {
444 INF(" }");
445 toknz->current_nesting--;
446 fgoto tokenize_class;
447 }
448
449 begin_method = ident %end_method_name ignore* begin_def;
450
451 tokenize_methods := |*
452 ignore+; #=> show_ignore;
453 comment => show_comment;
454 begin_method => begin_method;
455 end_def => end_methods;
456 any => show_error;
457 *|;
458
418###### TOKENIZE CLASS 459###### TOKENIZE CLASS
419 460
420 action end_class_comment { 461 action end_class_comment {
@@ -437,7 +478,7 @@ _eo_tokenizer_accessor_get(Eo_Tokenizer *toknz, Eo_Accessor_Type type)
437 action begin_methods { 478 action begin_methods {
438 INF(" begin methods"); 479 INF(" begin methods");
439 toknz->current_nesting++; 480 toknz->current_nesting++;
440 /* fgoto tokenize_methods; */ 481 fgoto tokenize_methods;
441 } 482 }
442 483
443 action end_class { 484 action end_class {