summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-11-27 03:44:55 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2013-11-27 03:44:55 +0100
commit769c864c07a3e89fce73ab4d98be58479181db80 (patch)
treef9adeaaa19c7cdf4c224680444c24924d2ffca4c
parent43c3b86cec8a5bf043deae503027234a56d61071 (diff)
downloadeo_tokenizer-769c864c07a3e89fce73ab4d98be58479181db80.zip
eo_tokenizer-769c864c07a3e89fce73ab4d98be58479181db80.tar.gz
add tokenize_properties
-rw-r--r--eo_tokenizer.rl50
1 files 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 {