From 769c864c07a3e89fce73ab4d98be58479181db80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 27 Nov 2013 02:44:55 +0000 Subject: add tokenize_properties --- eo_tokenizer.rl | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/eo_tokenizer.rl b/eo_tokenizer.rl index 50200bc..9281126 100644 --- a/eo_tokenizer.rl +++ b/eo_tokenizer.rl @@ -46,6 +46,17 @@ _eo_tokenizer_class_get(Eo_Tokenizer *toknz, char *p) return kls; } +static Eo_Property_Def* +_eo_tokenizer_property_get(Eo_Tokenizer *toknz, char *p) +{ + Eo_Property_Def *prop = calloc(1, sizeof(Eo_Property_Def)); + if (prop == NULL) ABORT(toknz, "calloc Eo_Property_Def failure"); + + prop->name = _eo_tokenizer_token_get(toknz, p); + + return prop; +} + %%{ machine common; @@ -125,6 +136,41 @@ _eo_tokenizer_class_get(Eo_Tokenizer *toknz, char *p) write data; +###### TOKENIZE PROPERTIES + + action end_prop_name { + Eo_Property_Def *prop = _eo_tokenizer_property_get(toknz); + prop->name = _eo_tokenizer_token_get(toknz, fpc-1); + } + + action begin_property { + INF(" %s {", toknz->tmp.prop->name); + toknz->current_nesting++; + #fgoto tokenize_property; + } + + action end_property_name { + if (toknz->tmp.prop != NULL) + ABORT(toknz, "there is a pending property definition %s", toknz->tmp.prop->name); + toknz->tmp.prop = _eo_tokenizer_property_get(toknz, fpc); + } + + action end_properties { + INF(" }"); + toknz->current_nesting--; + fgoto tokenize_class; + } + + begin_property = ident %end_property_name ignore* begin_def; + + tokenize_properties := |* + ignore+; #=> show_ignore; + comment => show_comment; + begin_property => begin_property; + end_def => end_properties; + any => show_error; + *|; + ###### TOKENIZE CLASS action end_class_comment { @@ -139,9 +185,9 @@ _eo_tokenizer_class_get(Eo_Tokenizer *toknz, char *p) } action begin_properties { - INF(" begin properties"); + INF(" properties {"); toknz->current_nesting++; - /* fgoto tokenize_properties; */ + fgoto tokenize_properties; } action begin_methods { -- cgit v1.1-2-g2b99