diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2013-11-29 17:22:38 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2013-11-29 17:22:38 +0100 |
commit | 6fcba8424f8f8f606244da4d47729b1869a42bad (patch) | |
tree | 8f8f7ae213bb4cd948bf6356cc7d9f2c4933b648 | |
parent | a575460b571412b1861ccab6491938812a3cd584 (diff) | |
download | eo_tokenizer-6fcba8424f8f8f606244da4d47729b1869a42bad.zip eo_tokenizer-6fcba8424f8f8f606244da4d47729b1869a42bad.tar.gz |
add action tokenize_methods and +_eo_tokenizer_method_get()
-rw-r--r-- | eo_tokenizer.rl | 43 |
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) 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 { |