allow 'elif' for Python compatibility
This commit is contained in:
parent
3415fd4e73
commit
132542c6ab
@ -1015,8 +1015,8 @@ static void ifStatement() {
|
||||
previous = parser.previous;
|
||||
advance();
|
||||
}
|
||||
if (match(TOKEN_ELSE)) {
|
||||
if (check(TOKEN_IF)) {
|
||||
if (match(TOKEN_ELSE) || check(TOKEN_ELIF)) {
|
||||
if (parser.current.type == TOKEN_ELIF || check(TOKEN_IF)) {
|
||||
parser.previous = myPrevious;
|
||||
ifStatement(); /* Keep nesting */
|
||||
} else {
|
||||
|
2
rline.c
2
rline.c
@ -521,7 +521,7 @@ void paint_krk_string(struct syntax_state * state, int type) {
|
||||
char * syn_krk_keywords[] = {
|
||||
"and","class","def","else","export","for","if","in","import",
|
||||
"let","not","or","print","return","while","try","except","raise",
|
||||
"continue","break","as","from",
|
||||
"continue","break","as","from","elif",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -202,7 +202,10 @@ static KrkTokenType identifierType() {
|
||||
} break;
|
||||
case 'd': return checkKeyword(1, "ef", TOKEN_DEF);
|
||||
case 'e': if (MORE(1)) switch(scanner.start[1]) {
|
||||
case 'l': return checkKeyword(2, "se", TOKEN_ELSE);
|
||||
case 'l': if (MORE(2)) switch(scanner.start[2]) {
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user