summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-11-25 11:39:58 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2013-11-25 11:39:58 +0100
commitc523229976f8fcddd5cd2f4d325a54ae9faa7d7d (patch)
tree83454b0a820ac593f503b96a9b7098ace2a2ae2f
parent3fb65bfe9c03d2adf098435fe6be559aaaeb1d4f (diff)
downloadeo_tokenizer-c523229976f8fcddd5cd2f4d325a54ae9faa7d7d.zip
eo_tokenizer-c523229976f8fcddd5cd2f4d325a54ae9faa7d7d.tar.gz
start class support
-rw-r--r--eo_tokenizer.rl53
1 files 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)
{