From dfbffadbb973469a22d4cd05694edd73ebf5fca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sat, 23 Nov 2013 16:52:38 +0000 Subject: cleanup/add actions and struct to save line and token start ptr --- eo_tokenizer.h | 5 ++++- 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; } -- cgit v1.1-2-g2b99