@@ -1199,8 +1199,9 @@ static void parseModule (lexerState *lexer, vString *scope, int parent_kind)
1199
1199
//advanceToken(lexer, true);
1200
1200
//parseExpr(lexer, true, K_MODULE, scope);
1201
1201
}
1202
+
1202
1203
/*
1203
- * Parse a token in import/using expression that may have a dot in it.
1204
+ * Parse a token in import expression that may have a dot in it.
1204
1205
*/
1205
1206
static void parseImportToken (lexerState * lexer , vString * scope , int module_role , int unknown_role , vString * module_name )
1206
1207
{
@@ -1228,33 +1229,50 @@ static void parseImport (lexerState *lexer, vString *scope, int token_type)
1228
1229
vString * name = vStringNew ();
1229
1230
int module_role ;
1230
1231
int unknown_role ;
1232
+ /* capture the imported name */
1233
+ advanceToken (lexer , true);
1234
+ vStringCopy (name , lexer -> token_str );
1231
1235
if (token_type == TOKEN_IMPORT )
1232
1236
{
1233
1237
module_role = JULIA_MODULE_IMPORTED ;
1234
1238
unknown_role = JULIA_UNKNOWN_IMPORTED ;
1239
+ /* The import expression may look like "import Mod" or "import
1240
+ * Mod.symbol", we have to deal with these 2 possibilities. */
1241
+ parseImportToken (lexer , scope , module_role , unknown_role , name );
1235
1242
}
1236
1243
else /* if (token_type) == TOKEN_USING */
1237
1244
{
1238
1245
module_role = JULIA_MODULE_USING ;
1239
1246
unknown_role = JULIA_UNKNOWN_USING ;
1247
+ /* The using expression always look like "using Mod", so we can tag it
1248
+ * easily. */
1249
+ addReferenceTag (lexer -> token_str , K_MODULE , module_role , lexer -> line , lexer -> pos , NULL );
1240
1250
}
1241
- /* capture the imported name */
1242
- advanceToken (lexer , true);
1243
- vStringCopy (name , lexer -> token_str );
1244
- parseImportToken (lexer , scope , module_role , unknown_role , name );
1245
1251
if (lexer -> cur_c == ':' || lexer -> cur_c == ',' )
1246
1252
{
1247
1253
char delimiter = lexer -> cur_c ;
1248
1254
advanceChar (lexer );
1249
1255
advanceToken (lexer , true);
1256
+ if (lexer -> cur_token == TOKEN_NEWLINE )
1257
+ {
1258
+ advanceToken (lexer , true);
1259
+ }
1250
1260
while (lexer -> cur_token == TOKEN_IDENTIFIER || lexer -> cur_token == TOKEN_MACROCALL )
1251
1261
{
1252
- if (delimiter == ',' )
1262
+ if (token_type == TOKEN_IMPORT && delimiter == ',' )
1253
1263
{
1264
+ /* import Mod1.symbol1, Mod2.symbol2, Mod3 */
1254
1265
parseImportToken (lexer , scope , module_role , unknown_role , name );
1255
1266
}
1267
+ else if (token_type == TOKEN_USING && delimiter == ',' )
1268
+ {
1269
+ /* using Mod1, Mod2 */
1270
+ addReferenceTag (lexer -> token_str , K_MODULE , module_role , lexer -> line , lexer -> pos , NULL );
1271
+ }
1256
1272
else /* if (delimiter == ':') */
1257
1273
{
1274
+ /* import Mod1: symbol1, symbol2 */
1275
+ /* using Mod1: symbol1, symbol2 */
1258
1276
addReferenceTag (lexer -> token_str , K_UNKNOWN , unknown_role , lexer -> line , lexer -> pos , name );
1259
1277
}
1260
1278
skipWhitespace (lexer , false);
0 commit comments