diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2013-11-23 17:52:38 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2013-11-23 17:52:38 +0100 |
commit | dfbffadbb973469a22d4cd05694edd73ebf5fca1 (patch) | |
tree | d44762c25a12f14c3869ac5389e9211c248d2e7f | |
parent | 80f6f356a4618a8c2eb1416f48406a192f5608a6 (diff) | |
download | eo_tokenizer-dfbffadbb973469a22d4cd05694edd73ebf5fca1.zip eo_tokenizer-dfbffadbb973469a22d4cd05694edd73ebf5fca1.tar.gz |
cleanup/add actions and struct to save line and token start ptr
-rw-r--r-- | eo_tokenizer.h | 5 | ||||
-rw-r--r-- | eo_tokenizer.rl | 21 |
2 files changed, 18 insertions, 8 deletions
diff --git a/eo_tokenizer.h b/eo_tokenizer.h index 0f331f7..a264c2d 100644 --- a/eo_tokenizer.h +++ b/eo_tokenizer.h @@ -116,8 +116,11 @@ typedef struct _eo_tokenizer int current_line; int current_nesting; int max_nesting; - int token_start_line; char buf[BUFSIZE]; + struct { + char *tok; + int line; + } saved; Eina_List *classes; } Eo_Tokenizer; diff --git a/eo_tokenizer.rl b/eo_tokenizer.rl index f2ffddb..8a1f57a 100644 --- a/eo_tokenizer.rl +++ b/eo_tokenizer.rl @@ -23,17 +23,22 @@ _eo_tokenizer_abort(Eo_Tokenizer *toknz, variable eof toknz->eof; action inc_line { - /* DBG("inc[%d]", toknz->cs); */ toknz->current_line += 1; + DBG("inc[%d] %d", toknz->cs, toknz->current_line); } - action save_start_line { - /* DBG("save[%d] %d", toknz->cs, toknz->current_line); */ - toknz->token_start_line = toknz->current_line; + action save_line { + toknz->saved.line = toknz->current_line; + DBG("save[%d] %d", toknz->cs, toknz->current_line); + } + + action save_fpc { + toknz->saved.tok = fpc; + DBG("save[%d] %d", toknz->cs, fpc); } action show_comment { - DBG("comment[%d] %03d:%03d", toknz->cs, toknz->token_start_line, toknz->current_line); + DBG("comment[%d] %03d:%03d", toknz->cs, toknz->saved.line, toknz->current_line); } action show_ignore { @@ -63,7 +68,7 @@ _eo_tokenizer_abort(Eo_Tokenizer *toknz, c_comment = "/*" ( any | '\n' @inc_line )* :>> "*/"; cpp_comment = "//" (any - cr)* newline; - comment = ( c_comment | cpp_comment ) > save_start_line; + comment = ( c_comment | cpp_comment ) > save_line; }%% @@ -163,7 +168,9 @@ eo_tokenizer_get() toknz->max_nesting = 10; toknz->current_line = 1; toknz->current_nesting = 0; - toknz->token_start_line = 0; + toknz->saved.tok = NULL; + toknz->saved.line = 0; + toknz->classes = NULL; return toknz; } |