-
Notifications
You must be signed in to change notification settings - Fork 404
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
示例代码输出结果,对分号的处理不解 #9
Comments
疑惑+1
log输出了;分号 和预期不一样。 |
分号问题 正在寻求解决方案,由于ast中没有分号相关的属性设置,所以不太好解决,请耐心等待~ |
代码中多余的分号分被解析成 从ast转文本代码理论上generator可决定要不要添加分号,或者在什么情况下必须添加分号。不过 为了保持原格式,会引入新的问题,比如对 const from = `
import a from 'a';
console.log('get A');
var b = console.log();
console.log.bind();
var c = console.log;console.log = func;
`; 我把倒数第1行和倒数第2行人工合并到一行上,有分号,代码正常。经过 import a from 'a';
;
var b = void 0
console.log.bind();
var c = function(){}console.log = func; 按前面人的测试,这就不对了。 如果改成 import a from "a";
;
var b = void 0;
console.log.bind();
var c = function() {};
console.log = func;
如果按最大格式的保持原有格式输出,那就需要对用户传入的 先插入替换,最后删除多余分号。 |
对于文件/gogocode/packages/gogocode-starter/src/start.js
输入内容为:
执行后实际输出结果:
而start.js文件中描述的期望结果是:
以上两个结果,可以明显看出,
第二行剩下分号,期望结果是没有输出,
倒数第二行结尾没有分号,期望结果是有分号,
那么,假如把输入压缩成一行,结果会出问题:
改为输入:
输出结果:
可以看到,由于丢失分号,输出结果是执行不了的。
The text was updated successfully, but these errors were encountered: