From c523229976f8fcddd5cd2f4d325a54ae9faa7d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 25 Nov 2013 11:39:58 +0100 Subject: start class support --- eo_tokenizer.rl | 53 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/eo_tokenizer.rl b/eo_tokenizer.rl index 0f2f2cf..bee773b 100644 --- a/eo_tokenizer.rl +++ b/eo_tokenizer.rl @@ -32,6 +32,17 @@ _eo_tokenizer_token_get(Eo_Tokenizer *toknz, char *p) return eina_stringshare_add(d); } +static Eo_Class_Def* +_eo_tokenizer_class_get(Eo_Tokenizer *toknz, char *p) +{ + Eo_Class_Def *kls = calloc(1, sizeof(Eo_Class_Def)); + if (kls == NULL) ABORT(toknz, "calloc Eo_Class failure"); + + kls->name = _eo_tokenizer_token_get(toknz, p); + + return kls; +} + %%{ machine common; @@ -106,16 +117,48 @@ _eo_tokenizer_token_get(Eo_Tokenizer *toknz, char *p) machine eo_tokenizer; include common; + write data; + + # TOKENIZE CLASS + + action end_class { + INF("end class:%s", toknz->tmp_kls->name); + toknz->classes= eina_list_append(toknz->classes, toknz->tmp_kls); + toknz->tmp_kls = NULL; + toknz->current_nesting--; + fgoto main; + } + + tokenize_class := |* + ignore+; #=> show_ignore; + comment => show_comment; + end_def => end_class; + any => show_error; + *|; + + # TOP LEVEL + + action begin_class { + INF("begin class: %s", toknz->tmp_kls->name); + toknz->current_nesting++; + fgoto tokenize_class; + } + + action end_class_name { + toknz->tmp_kls = _eo_tokenizer_class_get(toknz, fpc); + } + + begin_class = alpha_u+ >save_fpc %end_class_name ignore* begin_def; + main := |* - ignore+; #=> show_ignore; - comment => show_comment; - any => show_error; + ignore+; #=> show_ignore; + comment => show_comment; + begin_class => begin_class; + any => show_error; *|; }%% -%% write data; - Eina_Bool eo_tokenizer_walk(Eo_Tokenizer *toknz, const char *source) { -- cgit v1.1-2-g2b99