Remove 'export' keyword
This commit is contained in:
parent
8a1de6c4d2
commit
11e6b79e49
18
compiler.c
18
compiler.c
@ -1332,7 +1332,7 @@ static void fromImportStatement() {
|
|||||||
consume(TOKEN_IDENTIFIER, "Expected module name after 'from'");
|
consume(TOKEN_IDENTIFIER, "Expected module name after 'from'");
|
||||||
size_t ind = identifierConstant(&parser.previous);
|
size_t ind = identifierConstant(&parser.previous);
|
||||||
EMIT_CONSTANT_OP(OP_IMPORT, ind);
|
EMIT_CONSTANT_OP(OP_IMPORT, ind);
|
||||||
consume(TOKEN_IMPORT, "Exported 'import' after module name");
|
consume(TOKEN_IMPORT, "Expected 'import' after module name");
|
||||||
do {
|
do {
|
||||||
consume(TOKEN_IDENTIFIER, "Expected member name");
|
consume(TOKEN_IDENTIFIER, "Expected member name");
|
||||||
size_t member = identifierConstant(&parser.previous);
|
size_t member = identifierConstant(&parser.previous);
|
||||||
@ -1356,18 +1356,6 @@ static void fromImportStatement() {
|
|||||||
emitByte(OP_POP); /* Pop the remaining copy of the module. */
|
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() {
|
static void statement() {
|
||||||
if (match(TOKEN_EOL) || match(TOKEN_EOF)) {
|
if (match(TOKEN_EOL) || match(TOKEN_EOF)) {
|
||||||
return; /* Meaningless blank line */
|
return; /* Meaningless blank line */
|
||||||
@ -1382,9 +1370,7 @@ static void statement() {
|
|||||||
} else if (check(TOKEN_TRY)) {
|
} else if (check(TOKEN_TRY)) {
|
||||||
tryStatement();
|
tryStatement();
|
||||||
} else {
|
} else {
|
||||||
if (match(TOKEN_EXPORT)) {
|
if (match(TOKEN_RAISE)) {
|
||||||
exportStatement();
|
|
||||||
} else if (match(TOKEN_RAISE)) {
|
|
||||||
raiseStatement();
|
raiseStatement();
|
||||||
} else if (match(TOKEN_RETURN)) {
|
} else if (match(TOKEN_RETURN)) {
|
||||||
returnStatement();
|
returnStatement();
|
||||||
|
2
rline.c
2
rline.c
@ -519,7 +519,7 @@ void paint_krk_string(struct syntax_state * state, int type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char * syn_krk_keywords[] = {
|
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",
|
"let","not","or","return","while","try","except","raise",
|
||||||
"continue","break","as","from","elif","lambda",
|
"continue","break","as","from","elif","lambda",
|
||||||
NULL
|
NULL
|
||||||
|
@ -206,10 +206,7 @@ static KrkTokenType identifierType() {
|
|||||||
case 's': return checkKeyword(3,"e", TOKEN_ELSE);
|
case 's': return checkKeyword(3,"e", TOKEN_ELSE);
|
||||||
case 'i': return checkKeyword(3,"f", TOKEN_ELIF);
|
case 'i': return checkKeyword(3,"f", TOKEN_ELIF);
|
||||||
} break;
|
} break;
|
||||||
case 'x': if MORE(2) switch(scanner.start[2]) {
|
case 'x': return checkKeyword(2, "cept", TOKEN_EXCEPT);
|
||||||
case 'p': return checkKeyword(3, "ort", TOKEN_EXPORT);
|
|
||||||
case 'c': return checkKeyword(3, "ept", TOKEN_EXCEPT);
|
|
||||||
} break;
|
|
||||||
} break;
|
} break;
|
||||||
case 'f': if (MORE(1)) switch(scanner.start[1]) {
|
case 'f': if (MORE(1)) switch(scanner.start[1]) {
|
||||||
case 'o': return checkKeyword(2, "r", TOKEN_FOR);
|
case 'o': return checkKeyword(2, "r", TOKEN_FOR);
|
||||||
|
@ -43,7 +43,6 @@ typedef enum {
|
|||||||
TOKEN_RETRY, /* 46 */
|
TOKEN_RETRY, /* 46 */
|
||||||
TOKEN_EOL, /* 47 */
|
TOKEN_EOL, /* 47 */
|
||||||
|
|
||||||
TOKEN_EXPORT, /* 48 */
|
|
||||||
TOKEN_MODULO,
|
TOKEN_MODULO,
|
||||||
TOKEN_TRY, TOKEN_EXCEPT, TOKEN_RAISE,
|
TOKEN_TRY, TOKEN_EXCEPT, TOKEN_RAISE,
|
||||||
TOKEN_BREAK, TOKEN_CONTINUE,
|
TOKEN_BREAK, TOKEN_CONTINUE,
|
||||||
|
Loading…
Reference in New Issue
Block a user