Disallow empty bodies in control flow statements, added 'pass' keyword

Fixed #170
This commit is contained in:
2025-01-09 11:03:03 +11:00
parent 9de9c85bea
commit 90ffe9b40e
4 changed files with 28 additions and 17 deletions

View File

@@ -44,6 +44,7 @@ const Toy_KeywordTypeTuple keywordTuples[] = {
{TOY_TOKEN_KEYWORD_IMPORT, "import"},
{TOY_TOKEN_KEYWORD_IN, "in"},
{TOY_TOKEN_KEYWORD_OF, "of"},
{TOY_TOKEN_KEYWORD_PASS, "pass"},
{TOY_TOKEN_KEYWORD_PRINT, "print"},
{TOY_TOKEN_KEYWORD_RETURN, "return"},
{TOY_TOKEN_KEYWORD_TYPEAS, "typeas"},
@@ -404,12 +405,6 @@ void Toy_private_printToken(Toy_Token* token) {
return;
}
//read pass token, even though it isn't generated
if (token->type == TOY_TOKEN_PASS) {
printf(TOY_CC_NOTICE "PASS: \t%d\t%.*s\n" TOY_CC_RESET, (int)token->line, (int)token->length, token->lexeme);
return;
}
//print the line number
printf("\t%d\t%d\t", token->type, (int)token->line);