diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2013-11-29 17:24:15 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2013-11-29 17:24:15 +0100 |
commit | a88084e4dfecd099949192679152e1d9cc1f6853 (patch) | |
tree | ff380310e64337a82d8c64eb3bfb8e3a6dc14558 | |
parent | 4dfc360d1d5db5c7f4ccfaf673d71bf8b096c2c7 (diff) | |
download | eo_tokenizer-a88084e4dfecd099949192679152e1d9cc1f6853.zip eo_tokenizer-a88084e4dfecd099949192679152e1d9cc1f6853.tar.gz |
add tokenize_method action
-rw-r--r-- | eo_tokenizer.rl | 61 |
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) any => show_error; *|; +###### TOKENIZE METHOD + + action end_method_comment { + if (toknz->tmp.meth->comment != NULL) + ABORT(toknz, "method has already a comment"); + toknz->tmp.meth->comment = _eo_tokenizer_token_get(toknz, fpc-1); + INF(" %s", toknz->tmp.meth->comment); + } + + action begin_method_params { + INF(" params {"); + toknz->current_nesting++; + fgoto tokenize_params; + } + + action end_method_rettype { + if (toknz->tmp.meth->ret.type != NULL) + ABORT(toknz, "method '%s' has already a return type", toknz->tmp.meth->name); + toknz->tmp.meth->ret.type = _eo_tokenizer_token_get(toknz, fpc); + INF(" %s", toknz->tmp.meth->ret.type); + } + + action end_method_rettype_comment { + if (toknz->tmp.meth->ret.comment != NULL) + ABORT(toknz, "method '%s' return type has already a comment", toknz->tmp.meth->name); + toknz->tmp.meth->ret.comment = _eo_tokenizer_token_get(toknz, fpc-2); + INF(" %s", toknz->tmp.meth->ret.comment); + } + + action end_method_legacy { + toknz->tmp.meth->legacy = _eo_tokenizer_token_get(toknz, fpc); + } + + action end_method { + if (eina_list_count(toknz->tmp.meth->params) == 0) + WRN("method '%s' has no parameters.", toknz->tmp.meth->name); + INF(" }"); + toknz->tmp.kls->methods = eina_list_append(toknz->tmp.kls->methods, toknz->tmp.meth); + toknz->tmp.meth = NULL; + toknz->current_nesting--; + fgoto tokenize_methods; + } + + meth_params = 'params' ws* begin_def; + meth_legacy = 'legacy' ws+ ident %end_method_legacy end_statement; + meth_rettype_comment = ws* eo_comment %end_method_rettype_comment; + meth_rettype = 'return' ws+ alpha+ >save_fpc (alnum_u | '*' | ws )+ %end_method_rettype end_statement meth_rettype_comment?; + + tokenize_method := |* + ignore+; #=> show_ignore; + eo_comment => end_method_comment; + comment => show_comment; + meth_params => begin_method_params; + meth_rettype; + meth_legacy; + end_def => end_method; + any => show_error; + *|; + ###### TOKENIZE METHODS action begin_method { INF(" %s {", toknz->tmp.meth->name); toknz->current_nesting++; - /* fgoto tokenize_method; */ + fgoto tokenize_method; } action end_method_name { |