Skip to content

Commit

Permalink
Merge pull request #2973 from yebblies/lexermangle
Browse files Browse the repository at this point in the history
[DDMD] Expand SINGLE and DOUPLE macros in lexer.c
  • Loading branch information
AndrejMitrovic committed Dec 16, 2013
2 parents b6290ae + 12e24bb commit 28f17f6
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions src/lexer.c
Expand Up @@ -1089,36 +1089,37 @@ void Lexer::scan(Token *t)
t->value = TOKxor; // ^
return;

#define SINGLE(c,tok) case c: p++; t->value = tok; return;

SINGLE('(', TOKlparen)
SINGLE(')', TOKrparen)
SINGLE('[', TOKlbracket)
SINGLE(']', TOKrbracket)
SINGLE('{', TOKlcurly)
SINGLE('}', TOKrcurly)
SINGLE('?', TOKquestion)
SINGLE(',', TOKcomma)
SINGLE(';', TOKsemicolon)
SINGLE(':', TOKcolon)
SINGLE('$', TOKdollar)
SINGLE('@', TOKat)
#undef SINGLE

#define DOUBLE(c1,tok1,c2,tok2) \
case c1: \
p++; \
if (*p == c2) \
{ p++; \
t->value = tok2; \
} \
else \
t->value = tok1; \
return;
case '(': p++; t->value = TOKlparen; return;
case ')': p++; t->value = TOKrparen; return;
case '[': p++; t->value = TOKlbracket; return;
case ']': p++; t->value = TOKrbracket; return;
case '{': p++; t->value = TOKlcurly; return;
case '}': p++; t->value = TOKrcurly; return;
case '?': p++; t->value = TOKquestion; return;
case ',': p++; t->value = TOKcomma; return;
case ';': p++; t->value = TOKsemicolon; return;
case ':': p++; t->value = TOKcolon; return;
case '$': p++; t->value = TOKdollar; return;
case '@': p++; t->value = TOKat; return;

DOUBLE('*', TOKmul, '=', TOKmulass)
DOUBLE('%', TOKmod, '=', TOKmodass)
#undef DOUBLE
case '*':
p++;
if (*p == '=')
{ p++;
t->value = TOKmulass;
}
else
t->value = TOKmul;
return;
case '%':
p++;
if (*p == '=')
{ p++;
t->value = TOKmodass;
}
else
t->value = TOKmod;
return;

case '#':
{
Expand Down

0 comments on commit 28f17f6

Please sign in to comment.