You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When 'un-parsing' the ast, it would be nice to know whether comments begin on a new line or not. Right not it is not possible to tell. The following code:
var acorn = require('acorn');
var code1 = 'funcall();//comment same line\n';
var code2 = 'funcall();\n//comment next line\n';
var ast1 = acorn.parse(code1,{trackComments:true});
var ast2 = acorn.parse(code2,{trackComments:true});
console.log(JSON.stringify(ast1));
console.log(JSON.stringify(ast2));
outputs:
{"type":"Program","start":0,"end":10,"body":[{"type":"ExpressionStatement","start":0,"end":10,"expression":{"type":"CallExpression","start":0,"callee":{"type":"Identifier","start":0,"end":7,"name":"funcall"},"arguments":[],"end":9,"commentsAfter":["//comment same line"]}}]}
{"type":"Program","start":0,"end":10,"body":[{"type":"ExpressionStatement","start":0,"end":10,"expression":{"type":"CallExpression","start":0,"callee":{"type":"Identifier","start":0,"end":7,"name":"funcall"},"arguments":[],"end":9,"commentsAfter":["//comment next line"]}}]}
The text was updated successfully, but these errors were encountered:
When 'un-parsing' the ast, it would be nice to know whether comments begin on a new line or not. Right not it is not possible to tell. The following code:
var acorn = require('acorn');
var code1 = 'funcall();//comment same line\n';
var code2 = 'funcall();\n//comment next line\n';
var ast1 = acorn.parse(code1,{trackComments:true});
var ast2 = acorn.parse(code2,{trackComments:true});
console.log(JSON.stringify(ast1));
console.log(JSON.stringify(ast2));
outputs:
{"type":"Program","start":0,"end":10,"body":[{"type":"ExpressionStatement","start":0,"end":10,"expression":{"type":"CallExpression","start":0,"callee":{"type":"Identifier","start":0,"end":7,"name":"funcall"},"arguments":[],"end":9,"commentsAfter":["//comment same line"]}}]}
{"type":"Program","start":0,"end":10,"body":[{"type":"ExpressionStatement","start":0,"end":10,"expression":{"type":"CallExpression","start":0,"callee":{"type":"Identifier","start":0,"end":7,"name":"funcall"},"arguments":[],"end":9,"commentsAfter":["//comment next line"]}}]}
The text was updated successfully, but these errors were encountered: