Comments (4)
Could you give an example of what you're parsing and what you're expecting? Note that comments properties are 'raised' to the most outer node that they occur next to.
from acorn.
yes, of course. sorry, i should have done this with my initial comment:
console.log(JSON.stringify(require('acorn').parse('1+1; //this is a comment\n',{trackComments:true})));
the output i get from the above example is this:
{"type":"Program","start":0,"body":[{"type":"ExpressionStatement","start":0,"expression":{"type":"BinaryExpression","start":0,"left":{"type":"Literal","start":0,"value":1,"end":1},"operator":"+","right":{"type":"Literal","start":2,"value":1,"end":3},"end":3},"end":4,"commentsAfter":null}],"end":4,"commentsAfter":null}
the comment in the code does not show in the ast. thanks.
from acorn.
Try updating to the latest git version. This is what it outputs for me:
{"type":"Program","start":0,"end":4,"body":[{"type":"ExpressionStatement","start":0,"end":4,"expression":{"type":"BinaryExpression","start":0,"left":{"type":"Literal","start":0,"end":1,"value":1,"raw":"1"},"operator":"+","right":{"type":"Literal","start":2,"end":3,"value":1,"raw":"1","commentsAfter":null},"end":3,"commentsAfter":["//this is a comment"]}}]}
from acorn.
yes, updating solved the problem. thanks.
from acorn.
Related Issues (20)
- AggregateType is incomplete in latest acorn-walk published version: 8.3.0 HOT 1
- some loc.start was undefined in acorn v8.11.2 HOT 1
- `import()` was parsed to Identifier HOT 1
- Token registration across plugins [WFC] HOT 2
- Unexpected parsing behavior after upgrading Acorn from v8.9.0 to v8.11.3 HOT 1
- Acorn fails with nullish coalescing HOT 5
- Incorrect line calculation after invalid escape sequence in tagged template HOT 3
- Strict mode detection logic
- SKG HOT 4
- How does it compare to the speed of vanilla JavaScript? HOT 1
- TypeScript complains when extending Parser HOT 1
- Justin Durand
- [acorn] Missing `value` property in `Token` (TypeScript) HOT 3
- Only fans.com
- Unsupported platform for [email protected] HOT 1
- Import Attributes
- Feature Request: ES2025 RegExp Duplicate named capturing groups HOT 6
- Acorn rejects call expression on the lhs of assignment. HOT 8
- [acorn-walk] Type error when using VariableDeclarator with walk.simple HOT 1
- Property and AssignmentProperty have the same type HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acorn.