Fix parsing of nested ternary

This commit is contained in:
K. Lange 2021-02-22 13:51:45 +09:00
parent 3c8855ddcf
commit 6fee62f341
3 changed files with 10 additions and 1 deletions

View File

@ -2394,7 +2394,7 @@ static void actualTernary(size_t count, KrkScanner oldScanner, Parser oldParser)
emitByte(OP_POP); /* Pop the condition */ emitByte(OP_POP); /* Pop the condition */
consume(TOKEN_ELSE, "Expected 'else' after ternary condition"); consume(TOKEN_ELSE, "Expected 'else' after ternary condition");
parsePrecedence(PREC_OR); parsePrecedence(PREC_TERNARY);
KrkScanner outScanner = krk_tellScanner(); KrkScanner outScanner = krk_tellScanner();
Parser outParser = parser; Parser outParser = parser;

View File

@ -0,0 +1,5 @@
print('a' if False else 'b' if False else 'c')
print('a' if False else 'b' if True else 'c')
print('a' if True else 'b' if False else 'c')
print('a' if True else 'b' if True else 'c')

View File

@ -0,0 +1,4 @@
c
b
a
a