summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-07-18 11:48:40 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2014-08-04 16:35:08 +0100
commit59f94a0e3632680abf5c269f9b005aab057d8b88 (patch)
tree4be59950ec23e25d820c6d68480be9f14f045967
parent79e309f2591f59890603e41bbceaf154ce7ed9d9 (diff)
downloadefl-59f94a0e3632680abf5c269f9b005aab057d8b88.tar.gz
eolian: lexing of multichar binary operators
-rw-r--r--src/lib/eolian/eo_lexer.c52
-rw-r--r--src/lib/eolian/eo_lexer.h2
-rw-r--r--src/lib/eolian/eo_parser.c4
3 files changed, 52 insertions, 6 deletions
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 80ee15a3c3..74b5ac093e 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -44,7 +44,7 @@ next_char(Eo_Lexer *ls)
static const char * const tokens[] =
{
- "==", "!=", ">", "<", ">=", "<=", "&&", "||", "<<", ">>",
+ "==", "!=", ">=", "<=", "&&", "||", "<<", ">>",
"<comment>", "<string>", "<number>", "<value>",
@@ -106,7 +106,7 @@ init_hash(void)
unsigned int i, u;
if (keyword_map) return;
keyword_map = eina_hash_string_superfast_new(NULL);
- for (i = u = 14; i < (sizeof(tokens) / sizeof(const char*)); ++i)
+ for (i = u = 12; i < (sizeof(tokens) / sizeof(const char*)); ++i)
{
eina_hash_add(keyword_map, tokens[i], (void*)(size_t)(i - u + 1));
}
@@ -484,6 +484,52 @@ lex(Eo_Lexer *ls, Eo_Token *tok)
continue;
case '\0':
return -1;
+ case '=':
+ next_char(ls);
+ if (ls->current != '=') return '=';
+ next_char(ls);
+ return TOK_EQ;
+ case '!':
+ next_char(ls);
+ if (ls->current != '=') return '!';
+ next_char(ls);
+ return TOK_NQ;
+ case '>':
+ next_char(ls);
+ if (ls->current == '=')
+ {
+ next_char(ls);
+ return TOK_GE;
+ }
+ else if (ls->current == '>')
+ {
+ next_char(ls);
+ return TOK_RSH;
+ }
+ return '>';
+ case '<':
+ next_char(ls);
+ if (ls->current == '=')
+ {
+ next_char(ls);
+ return TOK_LE;
+ }
+ else if (ls->current == '<')
+ {
+ next_char(ls);
+ return TOK_LSH;
+ }
+ return '<';
+ case '&':
+ next_char(ls);
+ if (ls->current != '&') return '&';
+ next_char(ls);
+ return TOK_AND;
+ case '|':
+ next_char(ls);
+ if (ls->current != '|') return '|';
+ next_char(ls);
+ return TOK_OR;
case '"': case '\'':
read_string(ls, tok);
return TOK_STRING;
@@ -716,7 +762,7 @@ eo_lexer_token_to_str(int token, char *buf)
const char *
eo_lexer_keyword_str_get(int kw)
{
- return tokens[kw + 13];
+ return tokens[kw + 11];
}
Eina_Bool
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index 95abb90b2f..67ea76f11e 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -13,7 +13,7 @@
enum Tokens
{
- TOK_EQ = START_CUSTOM, TOK_NQ, TOK_GT, TOK_LT, TOK_GE, TOK_LE,
+ TOK_EQ = START_CUSTOM, TOK_NQ, TOK_GE, TOK_LE,
TOK_AND, TOK_OR, TOK_LSH, TOK_RSH,
TOK_COMMENT, TOK_STRING, TOK_NUMBER, TOK_VALUE
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index f5422c1e09..ecb6d86480 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -250,8 +250,8 @@ get_binop_id(int tok)
case TOK_EQ: return EOLIAN_BINOP_EQ;
case TOK_NQ: return EOLIAN_BINOP_NQ;
- case TOK_GT: return EOLIAN_BINOP_GT;
- case TOK_LT: return EOLIAN_BINOP_LT;
+ case '>' : return EOLIAN_BINOP_GT;
+ case '<' : return EOLIAN_BINOP_LT;
case TOK_GE: return EOLIAN_BINOP_GE;
case TOK_LE: return EOLIAN_BINOP_LE;