q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=9b2680ad6fe4b76112457476cb7a7a0f7b6c031a

commit 9b2680ad6fe4b76112457476cb7a7a0f7b6c031a
Author: Daniel Kolesa <[email protected]>
Date:   Wed Jul 16 14:46:38 2014 +0100

    eolian: simplify the lexer (remove custom ident chars)
---
 src/lib/eolian/eo_lexer.c | 37 ++++++++++++-------------------------
 src/lib/eolian/eo_lexer.h |  4 ----
 2 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 719ebc9..aae2aaa 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -197,7 +197,7 @@ read_long_comment(Eo_Lexer *ls, const char **value)
 }
 
 static int
-lex(Eo_Lexer *ls, const char **value, int *kwid, const char *chars)
+lex(Eo_Lexer *ls, const char **value, int *kwid)
 {
    eina_strbuf_reset(ls->buff);
    for (;;) switch (ls->current)
@@ -235,8 +235,7 @@ lex(Eo_Lexer *ls, const char **value, int *kwid, const char 
*chars)
                 continue;
              }
            if (ls->current && (isalnum(ls->current)
-               || ls->current == '@'
-               || strchr(chars, ls->current)))
+               || ls->current == '@' || ls->current == '_'))
              {
                 int col = ls->column;
                 Eina_Bool at_kw = (ls->current == '@');
@@ -248,7 +247,7 @@ lex(Eo_Lexer *ls, const char **value, int *kwid, const char 
*chars)
                      next_char(ls);
                   }
                 while (ls->current && (isalnum(ls->current)
-                              || strchr(chars, ls->current)));
+                       || ls->current == '_'));
                 str    = eina_strbuf_string_get(ls->buff);
                 *kwid  = (int)(uintptr_t)eina_hash_find(keyword_map,
                                                         str);
@@ -406,35 +405,23 @@ eo_lexer_get_until(Eo_Lexer *ls, char end)
 int
 eo_lexer_get(Eo_Lexer *ls)
 {
-   return eo_lexer_get_ident(ls, "_");
+   if (ls->lookahead.token != TOK_EOF)
+     {
+        ls->t               = ls->lookahead;
+        ls->lookahead.token = TOK_EOF;
+        return ls->t.token;
+     }
+   ls->t.kw = 0;
+   return (ls->t.token = lex(ls, &ls->t.value, &ls->t.kw));
 }
 
 int
 eo_lexer_lookahead(Eo_Lexer *ls)
 {
-   return eo_lexer_lookahead_ident(ls, "_");
-}
-
-int
-eo_lexer_lookahead_ident(Eo_Lexer *ls, const char *chars)
-{
    assert (ls->lookahead.token == TOK_EOF);
    ls->lookahead.kw = 0;
    return (ls->lookahead.token = lex(ls, &ls->lookahead.value,
-          &ls->lookahead.kw, chars));
-}
-
-int
-eo_lexer_get_ident(Eo_Lexer *ls, const char *chars)
-{
-   if (ls->lookahead.token != TOK_EOF)
-     {
-        ls->t               = ls->lookahead;
-        ls->lookahead.token = TOK_EOF;
-        return ls->t.token;
-     }
-   ls->t.kw = 0;
-   return (ls->t.token = lex(ls, &ls->t.value, &ls->t.kw, chars));
+          &ls->lookahead.kw));
 }
 
 void
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index 619aa89..117ac0b 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -148,12 +148,8 @@ int         eo_lexer_get_balanced   (Eo_Lexer *ls, char 
beg, char end);
 int         eo_lexer_get_until      (Eo_Lexer *ls, char end);
 /* gets a regular token, singlechar or one of TOK_something */
 int         eo_lexer_get            (Eo_Lexer *ls);
-/* like above, but allows you to specify a list of custom characters that can
- * be used as part of identifiers */
-int         eo_lexer_get_ident      (Eo_Lexer *ls, const char *chars);
 /* lookahead token - see Eo_Lexer */
 int         eo_lexer_lookahead      (Eo_Lexer *ls);
-int         eo_lexer_lookahead_ident(Eo_Lexer *ls, const char *chars);
 /* "throws" an error, with a custom message and custom token */
 void        eo_lexer_lex_error      (Eo_Lexer *ls, const char *msg, int token);
 /* like above, but uses the lexstate->t.token, aka current token */

-- 


Reply via email to