Remove 'export' keyword

This commit is contained in:
K. Lange 2021-01-07 11:15:57 +09:00
parent 8a1de6c4d2
commit 11e6b79e49
4 changed files with 4 additions and 22 deletions

View File

@ -1332,7 +1332,7 @@ static void fromImportStatement() {
consume(TOKEN_IDENTIFIER, "Expected module name after 'from'");
size_t ind = identifierConstant(&parser.previous);
EMIT_CONSTANT_OP(OP_IMPORT, ind);
consume(TOKEN_IMPORT, "Exported 'import' after module name");
consume(TOKEN_IMPORT, "Expected 'import' after module name");
do {
consume(TOKEN_IDENTIFIER, "Expected member name");
size_t member = identifierConstant(&parser.previous);
@ -1356,18 +1356,6 @@ static void fromImportStatement() {
emitByte(OP_POP); /* Pop the remaining copy of the module. */
}
static void exportStatement() {
do {
consume(TOKEN_IDENTIFIER, "only named variable may be exported to the global namespace");
namedVariable(parser.previous, 0);
namedVariable(parser.previous, 0);
size_t ind = identifierConstant(&parser.previous);
EMIT_CONSTANT_OP(OP_DEFINE_GLOBAL, ind);
EMIT_CONSTANT_OP(OP_SET_GLOBAL, ind);
emitByte(OP_POP);
} while (match(TOKEN_COMMA));
}
static void statement() {
if (match(TOKEN_EOL) || match(TOKEN_EOF)) {
return; /* Meaningless blank line */
@ -1382,9 +1370,7 @@ static void statement() {
} else if (check(TOKEN_TRY)) {
tryStatement();
} else {
if (match(TOKEN_EXPORT)) {
exportStatement();
} else if (match(TOKEN_RAISE)) {
if (match(TOKEN_RAISE)) {
raiseStatement();
} else if (match(TOKEN_RETURN)) {
returnStatement();

View File

@ -519,7 +519,7 @@ void paint_krk_string(struct syntax_state * state, int type) {
}
char * syn_krk_keywords[] = {
"and","class","def","else","export","for","if","in","import",
"and","class","def","else","for","if","in","import",
"let","not","or","return","while","try","except","raise",
"continue","break","as","from","elif","lambda",
NULL

View File

@ -206,10 +206,7 @@ static KrkTokenType identifierType() {
case 's': return checkKeyword(3,"e", TOKEN_ELSE);
case 'i': return checkKeyword(3,"f", TOKEN_ELIF);
} break;
case 'x': if MORE(2) switch(scanner.start[2]) {
case 'p': return checkKeyword(3, "ort", TOKEN_EXPORT);
case 'c': return checkKeyword(3, "ept", TOKEN_EXCEPT);
} break;
case 'x': return checkKeyword(2, "cept", TOKEN_EXCEPT);
} break;
case 'f': if (MORE(1)) switch(scanner.start[1]) {
case 'o': return checkKeyword(2, "r", TOKEN_FOR);

View File

@ -43,7 +43,6 @@ typedef enum {
TOKEN_RETRY, /* 46 */
TOKEN_EOL, /* 47 */
TOKEN_EXPORT, /* 48 */
TOKEN_MODULO,
TOKEN_TRY, TOKEN_EXCEPT, TOKEN_RAISE,
TOKEN_BREAK, TOKEN_CONTINUE,