Skip to content

Conversation

@masatake
Copy link
Member

Extract local variables, too.

@masatake masatake requested a review from Copilot October 14, 2025 07:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR extracts tags related to import and export statements in JavaScript, enhancing the parser to handle ES6 module syntax. It introduces new tag kinds and roles for tracking imported/exported modules and identifiers.

  • Adds new JavaScript tag kinds: module and unknown with associated roles for import/export handling
  • Implements parsing functions for import and export statements with destructuring support
  • Updates parsing logic to extract local variables at non-global scopes

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
parsers/x-jscript.h Adds JSTAG_MODULE and JSTAG_UNKNOWN enum values
parsers/jscript.c Main implementation with new keywords, roles, parsing functions for import/export
Units/parser-javascript.r/es-export.d/input.mjs Test file with various export statement examples
Tmain/list-roles.d/stdout-expected.txt Updates expected output to include new module and unknown roles

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

*
* import * as Y from "X";
* X = (kind:module, role:imported)
* Y = (kind:unknown?, nameref:*?, module:X)
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'Y = (kind:unknown?, nameref:*?, module:X)' - question marks should be removed as they appear to be placeholder notation.

Copilot uses AI. Check for mistakes.
* import Y, * as Z from "X";
* X = (kind:module, role:imported)
* Y = (kind:unknown, role:importedAsDefault, module:X)
* Z = (kind:unknown?, nameref:*?)
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'Z = (kind:unknown?, nameref:*?)' - question marks should be removed as they appear to be placeholder notation.

Copilot uses AI. Check for mistakes.
Comment on lines +3092 to +3093
else if (! isType (token, TOKEN_KEYWORD) && true
/* token->nestLevel == 0 && state->isGlobal */)
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace hardcoded true with a meaningful condition or variable. The commented-out condition suggests this change may be temporary for testing purposes.

Suggested change
else if (! isType (token, TOKEN_KEYWORD) && true
/* token->nestLevel == 0 && state->isGlobal */)
else if (! isType (token, TOKEN_KEYWORD) && token->nestLevel == 0 && state->isGlobal)

Copilot uses AI. Check for mistakes.
readToken(token);

if (state.isGlobal)
if (state.isGlobal || 1)
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace hardcoded 1 with a meaningful condition or boolean variable. This appears to be a temporary change that makes the condition always true.

Suggested change
if (state.isGlobal || 1)
if (state.isGlobal)

Copilot uses AI. Check for mistakes.
m = makeSimpleRefTag (token->string, JSTAG_MODULE, JS_MODULE_AGGREGATED);
readToken (token);
}
/* TODO: put m to fileds of tags in us. */
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'fileds' to 'fields'.

Copilot uses AI. Check for mistakes.
m = makeSimpleRefTag (token->string, JSTAG_MODULE, JS_MODULE_AGGREGATED);
readToken (token);
}
/* TODO: put m to fileds of u. */
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'fileds' to 'fields'.

Suggested change
/* TODO: put m to fileds of u. */
/* TODO: put m to fields of u. */

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,32 @@
// Derrived from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'Derrived' to 'Derived'.

Suggested change
// Derrived from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
// Derived from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export

Copilot uses AI. Check for mistakes.
@masatake masatake modified the milestones: 6.3, 6.4 Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant