eolian: stricten the allowed characters in values, and values starting with @ must be keywords - we no longer need all the arbitrary characters beacuse of lex_balanced and lex_until

This commit is contained in:
Daniel Kolesa 2014-06-19 15:17:56 +01:00
parent ee053aa840
commit 78c1e92722
2 changed files with 11 additions and 9 deletions

View File

@ -177,8 +177,10 @@ lex(Eo_Lexer *ls, const char **value, int *kwid, const char *chars)
next_char(ls);
continue;
}
if (isalnum(ls->current) || strchr(chars, ls->current))
if (isalnum(ls->current) || ls->current == '@'
|| strchr(chars, ls->current))
{
Eina_Bool at_kw = (ls->current == '@');
const char *str;
eina_strbuf_reset(ls->buff);
do
@ -189,6 +191,8 @@ lex(Eo_Lexer *ls, const char **value, int *kwid, const char *chars)
|| strchr(chars, ls->current));
str = eina_strbuf_string_get(ls->buff);
*kwid = (long)eina_hash_find(keyword_map, str);
if (at_kw && *kwid == 0)
eo_lexer_syntax_error(ls, "invalid keyword");
*value = str;
return TOK_VALUE;
}
@ -315,13 +319,13 @@ eo_lexer_get_until(Eo_Lexer *ls, char end)
int
eo_lexer_get(Eo_Lexer *ls)
{
return eo_lexer_get_ident(ls, "@_.+-/\\='\"?!%");
return eo_lexer_get_ident(ls, "_");
}
int
eo_lexer_lookahead(Eo_Lexer *ls)
{
return eo_lexer_lookahead_ident(ls, "@_.+-/\\='\"?!%");
return eo_lexer_lookahead_ident(ls, "_");
}
int

View File

@ -4,8 +4,6 @@
#define FUNC_PUBLIC 0
#define FUNC_PROTECTED 1
#define eo_lexer_get_event_name(ls) eo_lexer_get_ident(ls, "@_.+-/\\='\"?!%,")
static void
error_expected(Eo_Lexer *ls, int token)
{
@ -713,7 +711,7 @@ parse_event(Eo_Lexer *ls)
/* code path not in use yet
if (ls->t.kw == KW_private)
{
eo_lexer_get_event_name(ls);
eo_lexer_get_ident(ls, "_,");
}*/
check(ls, TOK_VALUE);
ev->name = eina_stringshare_add(ls->t.value);
@ -727,11 +725,11 @@ parse_event(Eo_Lexer *ls)
check_match(ls, ')', '(', line);
}
check(ls, ';');
eo_lexer_get_event_name(ls);
eo_lexer_get_ident(ls, "_,");
if (ls->t.token == TOK_COMMENT)
{
ev->comment = eina_stringshare_add(ls->t.value);
eo_lexer_get_event_name(ls);
eo_lexer_get_ident(ls, "_,");
}
}
@ -810,7 +808,7 @@ parse_events(Eo_Lexer *ls)
eo_lexer_get(ls);
line = ls->line_number;
check(ls, '{');
eo_lexer_get_event_name(ls);
eo_lexer_get_ident(ls, "_,");
while (ls->t.token != '}')
{
parse_event(ls);