Comments (7)
Please also consider making locations
public.
In my usecase I don't want to use the parser more than once. I had problems with separate source codes with matching BindingIdentifier
s resulting in the same Java Object
and this was not an expected result. So I wouldn't mind if I did not have to pass the whole parser object forward, only the location information.
from shift-java.
Haha yeah, I expected this to be horribly broken right now. I will be adding location tests soon. Go ahead and send a PR to make the locations table public, but I'm not sure yet how I feel about that.
from shift-java.
@steindani, if we don't end up making it public (or in the meantime), you can always just subclass ParserWithLocation
; something like:
public class ParserExposingLocationTable extends ParserWithLocation {
public HashTable<Node, SourceSpan> getLocationTable() {
return locations;
}
}
from shift-java.
Thanks!
– Right now I'm fine with passing the parser, but this might need a better solution. It's not a burning problem. (Maybe a getter, since this way the variable couldn't be set from the outside, but the current "structure" could be acquired?)
– Is it the expected behaviour from the parser to result in the same Java Object for the same BindingIdentifier
after using the same parser on two different sources? Is there some kind of caching?
– I did not have time yet to test it out, but the locations might have a one-off error. I've noticed it with the FunctionDeclaration
s, the start location is always marking the previous (empty) line. The end location seems to be fine.
from shift-java.
Oh, right. Thanks, @bakkot!
from shift-java.
They shouldn't be giving you the same object, but we've overridden equality on nodes. So if you're comparing using .equals
, two nodes with identical properties will compare appear as equal.
The locations table is actually using equality instead of identity, which is a bug; I've fixed it in #106.
from shift-java.
Yeah, I've made the same mistake, instead of using IdentityHashMap
I've
used HashMap
in my code while converting the AST. Thanks for pointing
out!
On Mar 25, 2016 00:16, "Kevin Gibbons" [email protected] wrote:
They shouldn't be giving you the same object, but we've overridden
equality on nodes. So if you're comparing using .equals, two nodes with
identical properties will compare appear as equal.The locations table is actually using equality instead of identity, which
is a bug; I've fixed it in #106
#106.—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#104 (comment)
from shift-java.
Related Issues (20)
- Var/let redeclaration early error not fired HOT 1
- Move generated sources to appropriate directory HOT 1
- Yield is a reserved keyword in generator functions
- ScopeAnalysis does not properly handle namespace imports
- CodeGen does not string escape "default" keyword in static property names. HOT 2
- Legacy non-octal escape sequence in strict mode
- Contextual Keyword Escapes HOT 1
- Invalid codegen output for LiteralNumericExpressions > 2^63.
- ClassName declarations are considered block scoped, when they are function scoped. HOT 4
- Failure to parse AwaitExpression within Expression
- Fix let identifiers in for-of statements HOT 1
- Gradle support for es2018? HOT 2
- How do I search for a node in AST in Java? HOT 1
- Add source offsets HOT 1
- scope analyzer: B.3.3 function declarations do not contribute appropriate references
- Incorrect codegen output for ForOfStatement with BinaryExpression. HOT 1
- lenses: support setting
- Thunked class does not use second type parameter
- Handling Optional Chaining operator HOT 1
- support for latest ECMASCRIPT features
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 shift-java.