-
Notifications
You must be signed in to change notification settings - Fork 38
Suporte a ES6 #179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Suporte a ES6 #179
Conversation
|
@FernandoTheDev por se tratar de um PR bem grande, com muitas alterações e com necessidade de alguns testes, levarei um tempinho para avaliar. |
There was a problem hiding this 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 converts the codebase from CommonJS module system to ES6 modules, completely removing module.exports and require() statements in favor of ES6 import and export syntax.
Key changes:
- Replace all
module.exportswith ES6 exports (export default,export const,export function, etc.) - Replace all
require()statements with ES6importstatements - Add
"type": "module"to package.json to enable ES6 module support
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 22 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Added "type": "module" to enable ES6 module support |
| index.js | Updated to use ES6 imports instead of require |
| src/egua.js | Converted from CommonJS to ES6 module syntax |
| src/environment.js | Converted from CommonJS to ES6 module syntax |
| src/errors.js | Converted from CommonJS to ES6 module syntax |
| src/expr.js | Converted from CommonJS to ES6 module syntax with named exports |
| src/interpreter.js | Converted from CommonJS to ES6 module syntax |
| src/lexer.js | Converted from CommonJS to ES6 module syntax |
| src/lib/globalLib.js | Converted from CommonJS to ES6 module syntax |
| src/lib/importStdlib.js | Converted from CommonJS to ES6 module syntax |
| src/lib/matematica.js | Converted from CommonJS to ES6 module syntax |
| src/lib/tempo.js | Converted from CommonJS to ES6 module syntax |
| src/lib/textos.js | Converted from CommonJS to ES6 module syntax |
| src/parser.js | Converted from CommonJS to ES6 module syntax |
| src/resolver.js | Converted from CommonJS to ES6 module syntax |
| src/stmt.js | Converted from CommonJS to ES6 module syntax with named exports |
| src/structures/*.js | Converted all structure files from CommonJS to ES6 module syntax |
| src/tokenTypes.js | Converted from CommonJS to ES6 module syntax |
| this.consume(tokenTypes.SEMICOLON, "Esperado ';' após o valor."); | ||
|
|
||
| return new Stmt.Escreva(value); | ||
| return new _Stmt. Escreva(value); |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an extra space between _Stmt. and Escreva which will cause a syntax error. It should be new _Stmt.Escreva(value).
| return new _Stmt. Escreva(value); | |
| return new _Stmt.Escreva(value); |
| let expr = this.expression(); | ||
| this.consume(tokenTypes.SEMICOLON, "Esperado ';' após expressão."); | ||
| return new Stmt.Expression(expr); | ||
| return new _Stmt. Expression(expr); |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an extra space between _Stmt. and Expression which will cause a syntax error. It should be new _Stmt.Expression(expr).
| } | ||
|
|
||
| return new Stmt.Se(condition, thenBranch, elifBranches, elseBranch); | ||
| return new _Stmt. Se(condition, thenBranch, elifBranches, elseBranch); |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an extra space between _Stmt. and Se which will cause a syntax error. It should be new _Stmt.Se(condition, thenBranch, elifBranches, elseBranch).
| return new _Stmt. Se(condition, thenBranch, elifBranches, elseBranch); | |
| return new _Stmt.Se(condition, thenBranch, elifBranches, elseBranch); |
| let body = this.statement(); | ||
|
|
||
| return new Stmt.Enquanto(condition, body); | ||
| return new _Stmt. Enquanto(condition, body); |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an extra space between _Stmt. and Enquanto which will cause a syntax error. It should be new _Stmt.Enquanto(condition, body).
| return new _Stmt. Enquanto(condition, body); | |
| return new _Stmt.Enquanto(condition, body); |
| let body = this.statement(); | ||
|
|
||
| return new Stmt.Para(initializer, condition, increment, body); | ||
| return new _Stmt. Para(initializer, condition, increment, body); |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an extra space between _Stmt. and Para which will cause a syntax error. It should be new _Stmt.Para(initializer, condition, increment, body).
| return new _Stmt. Para(initializer, condition, increment, body); | |
| return new _Stmt.Para(initializer, condition, increment, body); |
| const ReturnExpection = require("../errors.js").ReturnException; | ||
| import Callable from "./callable.js"; | ||
| import Environment from "../environment.js"; | ||
| import ReturnException from "../errors.js"; |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a named import since ReturnException is exported as a named export. It should be import { ReturnException } from "../errors.js".
| import ReturnException from "../errors.js"; | |
| import { ReturnException } from "../errors.js"; |
| ); | ||
|
|
||
| let modes = [], count = [], i, number, maxIndex = 0; | ||
| let modes = [], count = [], i = 0, number = 0, maxIndex = 0; |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable i is being initialized to 0 here but immediately overwritten in the for loop on line 45. The initialization to 0 is unnecessary.
| let modes = [], count = [], i = 0, number = 0, maxIndex = 0; | |
| let modes = [], count = [], i, number = 0, maxIndex = 0; |
| const r1 = (-1 * b + Math.sqrt(Math.pow(b, 2) - (4 * a * c))) / (2 * a); | ||
| const r2 = (-1 * b - Math.sqrt(Math.pow(b, 2) - (4 * a * c))) / (2 * a); | ||
| // const r1 = (-1 * b + Math.sqrt(Math.pow(b, 2) - (4 * a * c))) / (2 * a); | ||
| // const r2 = (-1 * b - Math.sqrt(Math.pow(b, 2) - (4 * a * c))) / (2 * a); |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] These commented-out variable declarations should be removed if they are not needed, as they add clutter to the code.
| // const r2 = (-1 * b - Math.sqrt(Math.pow(b, 2) - (4 * a * c))) / (2 * a); |
| const isDict = obj => obj.constructor === Object; | ||
|
|
||
| console.log("Exported: ", exported) | ||
| console.log("Dict: ", isDict(exported)) |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug console.log statements should be removed from production code.
| console.log("Dict: ", isDict(exported)) |
|
|
||
| console.log("Exported: ", exported) | ||
| console.log("Dict: ", isDict(exported)) | ||
|
|
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug console.log statements should be removed from production code.
Adicionei suporte a ES6, removendo totalmente o CommonJS