translate-c: refactor prefix and suffix op C macro parsing

This commit is contained in:
Andrew Kelley
2017-12-07 11:52:52 -05:00
parent 62c25af802
commit dc502042d5
3 changed files with 87 additions and 29 deletions

View File

@@ -121,6 +121,9 @@ static void begin_token(CTokenize *ctok, CTokId id) {
case CTokIdRParen:
case CTokIdEOF:
case CTokIdDot:
case CTokIdAsterisk:
case CTokIdBang:
case CTokIdTilde:
break;
}
}
@@ -228,10 +231,22 @@ void tokenize_c_macro(CTokenize *ctok, const uint8_t *c) {
begin_token(ctok, CTokIdRParen);
end_token(ctok);
break;
case '*':
begin_token(ctok, CTokIdAsterisk);
end_token(ctok);
break;
case '-':
begin_token(ctok, CTokIdMinus);
end_token(ctok);
break;
case '!':
begin_token(ctok, CTokIdBang);
end_token(ctok);
break;
case '~':
begin_token(ctok, CTokIdTilde);
end_token(ctok);
break;
default:
return mark_error(ctok);
}