From 1842e06a081bbd8ace5b0398656371ab9597bb0c Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Wed, 2 Oct 2024 20:16:12 +0900 Subject: [PATCH] Add expression underlining for import statements --- src/compiler.c | 2 ++ test/testExpressionUnderlining.krk.expect | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/compiler.c b/src/compiler.c index 697b657a..f1ed4ac1 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -2556,10 +2556,12 @@ static size_t importModule(struct GlobalState * state, KrkToken * startOfName, i } static void importStatement(struct GlobalState * state) { + KrkToken left = state->parser.previous; do { KrkToken firstName = state->parser.current; KrkToken startOfName = {0}; size_t ind = importModule(state, &startOfName, 0); + writeExpressionLocation(&left,&state->parser.current,&firstName,state); if (match(TOKEN_AS)) { consume(TOKEN_IDENTIFIER, "Expected identifier after 'as'."); ind = identifierConstant(state, &state->parser.previous); diff --git a/test/testExpressionUnderlining.krk.expect b/test/testExpressionUnderlining.krk.expect index 8b63ff35..8b94cefb 100644 --- a/test/testExpressionUnderlining.krk.expect +++ b/test/testExpressionUnderlining.krk.expect @@ -16,6 +16,8 @@ print(foo['bar']['baz']['qux']['etc']) ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ print(foo['bar']['baz']['qux']['etc']) ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +import os +~~~~~~~^^ os.system(42) ~~^~~~~~~ os.system(42)