From 6fcba8424f8f8f606244da4d47729b1869a42bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 29 Nov 2013 17:22:38 +0100 Subject: add action tokenize_methods and +_eo_tokenizer_method_get() --- eo_tokenizer.rl | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) 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) return prop; } +static Eo_Method_Def* +_eo_tokenizer_method_get(Eo_Tokenizer *toknz, char *p) +{ + Eo_Method_Def *meth = calloc(1, sizeof(Eo_Method_Def)); + if (meth == NULL) ABORT(toknz, "calloc Eo_Method_Def failure"); + + meth->name = _eo_tokenizer_token_get(toknz, p); + + return meth; +} + static Eo_Param_Def* _eo_tokenizer_param_get(Eo_Tokenizer *toknz, char *p) { @@ -415,6 +426,36 @@ _eo_tokenizer_accessor_get(Eo_Tokenizer *toknz, Eo_Accessor_Type type) any => show_error; *|; +###### TOKENIZE METHODS + + action begin_method { + INF(" %s {", toknz->tmp.meth->name); + toknz->current_nesting++; + /* fgoto tokenize_method; */ + } + + action end_method_name { + if (toknz->tmp.meth != NULL) + ABORT(toknz, "there is a pending method definition %s", toknz->tmp.meth->name); + toknz->tmp.meth = _eo_tokenizer_method_get(toknz, fpc); + } + + action end_methods { + INF(" }"); + toknz->current_nesting--; + fgoto tokenize_class; + } + + begin_method = ident %end_method_name ignore* begin_def; + + tokenize_methods := |* + ignore+; #=> show_ignore; + comment => show_comment; + begin_method => begin_method; + end_def => end_methods; + any => show_error; + *|; + ###### TOKENIZE CLASS action end_class_comment { @@ -437,7 +478,7 @@ _eo_tokenizer_accessor_get(Eo_Tokenizer *toknz, Eo_Accessor_Type type) action begin_methods { INF(" begin methods"); toknz->current_nesting++; - /* fgoto tokenize_methods; */ + fgoto tokenize_methods; } action end_class { -- cgit v1.1-2-g2b99