Skip to content

Commit

Permalink
Add expression underlining for import statements
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Oct 2, 2024
1 parent d672e96 commit 1842e06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions test/testExpressionUnderlining.krk.expect
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ print(foo['bar']['baz']['qux']['etc'])
~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
print(foo['bar']['baz']['qux']['etc'])
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import os
~~~~~~~^^
os.system(42)
~~^~~~~~~
os.system(42)
Expand Down

0 comments on commit 1842e06

Please sign in to comment.