From e51051a752f985bb77b9b83dce8c7f812d47907d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 27 Nov 2013 02:46:45 +0000 Subject: add tokenize_property --- eo_tokenizer.rl | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/eo_tokenizer.rl b/eo_tokenizer.rl index 9281126..e92163b 100644 --- a/eo_tokenizer.rl +++ b/eo_tokenizer.rl @@ -57,6 +57,17 @@ _eo_tokenizer_property_get(Eo_Tokenizer *toknz, char *p) return prop; } +static Eo_Accessor_Def * +_eo_tokenizer_accessor_get(Eo_Tokenizer *toknz, Eo_Accessor_Type type) +{ + Eo_Accessor_Def *accessor = calloc(1, sizeof(Eo_Accessor_Def)); + if (accessor == NULL) ABORT(toknz, "calloc Eo_Accessor_Def failure"); + + accessor->type = type; + + return accessor; +} + %%{ machine common; @@ -136,6 +147,54 @@ _eo_tokenizer_property_get(Eo_Tokenizer *toknz, char *p) write data; +###### TOKENIZE PROPERTY + + action begin_property_get { + INF(" get {"); + toknz->tmp.accessor = _eo_tokenizer_accessor_get(toknz, GETTER); + toknz->current_nesting++; + #fgoto tokenize_accessor; + } + + action begin_property_set { + INF(" set {"); + toknz->tmp.accessor = _eo_tokenizer_accessor_get(toknz, SETTER); + toknz->current_nesting++; + #fgoto tokenize_accessor; + } + + action begin_property_params { + INF(" params {"); + toknz->current_nesting++; + #fgoto tokenize_params; + } + + action end_property { + if (eina_list_count(toknz->tmp.prop->params) == 0) + WRN("property %s has no parameters.", toknz->tmp.prop->name); + if (eina_list_count(toknz->tmp.prop->accessors) == 0) + WRN("property %s has no accessors.", toknz->tmp.prop->name); + INF(" }", toknz->tmp.prop->name); + toknz->tmp.kls->properties = eina_list_append(toknz->tmp.kls->properties, toknz->tmp.prop); + toknz->tmp.prop = NULL; + toknz->current_nesting--; + fgoto tokenize_properties; + } + + get = 'get' ws* begin_def; + set = 'set' ws* begin_def; + params = 'params' ws* begin_def; + + tokenize_property := |* + ignore+; #=> show_ignore; + comment => show_comment; + get => begin_property_get; + set => begin_property_set; + params => begin_property_params; + end_def => end_property; + any => show_error; + *|; + ###### TOKENIZE PROPERTIES action end_prop_name { @@ -146,7 +205,7 @@ _eo_tokenizer_property_get(Eo_Tokenizer *toknz, char *p) action begin_property { INF(" %s {", toknz->tmp.prop->name); toknz->current_nesting++; - #fgoto tokenize_property; + fgoto tokenize_property; } action end_property_name { -- cgit v1.1-2-g2b99