Comments (6)
This might be a place where pulling in functionality from rsense will help. In order to do its type inference work, rsense tracks scope, context and , of course, type, in a sort of shadow-grid alongside the AST it gets from jruby-parser. If we bring this into jruby-parser, and make the AST aware of the additional information, it seems like it ought to be easy enough to create an API for passing in a scope... I have only thought about doing this in a pretty abstract way so far, but I was reading this paper , which was an inspiration for rsense, which seems to suggest some possibilities.
from jruby-parser.
jruby-parser already has everything it needs to track the local variables, as it does it fine for variables it can see being assigned, so we shouldn't need any new functionality or data structures. All we need is an API to pass in an initial set of local variables.
Everything we need is here: https://github.com/jruby/jruby-parser/blob/master/src/org/jrubyparser/StaticScope.java. we just need to be able to pass one of these in at the start of parsing.
from jruby-parser.
For satisying this bug it is true we only need to add staticscope, but Eric is also looking at adding similar functionality to what rsense has to jruby-parser, so he has an eye towards a bigger fish. I suspect adding staticscope will be compatible with the work he is doing so we can add all this stuff piecemeal.
from jruby-parser.
yeah sorry, that probably seemed really random...
from jruby-parser.
Fixed in commit 60730a2. @chrisseaton you can look at spec/helpers/parser_helpers.rb to see how I set up local scope. You will need to work back to Java syntax but I don't think that is so difficult. Secondly, I test this from spec/jruby-parser/parse_spec.rb.
@edubkendo I believe rsense must use dynamicscope and not staticscope since that is what mainline jruby uses. This may complicate things a little for rsense if they are using dynamicscope to hold live values (dynamic scope is the value and static scope is the name). If so then we will need to talk about how to address that. I personally think static scope fits better since this is not a live runtime.
from jruby-parser.
@enebo well, it actually tracks both, in a hashmap: https://github.com/edubkendo/rsense/blob/master/src/org/cx4a/rsense/ruby/LocalScope.java and then there is a class extending LocalScope, called DynamicScope which is focused on testing equality. Most usages within rsense are of LocalScope, with the DynamicScope class being used in one method. I would have to look more closely to see how its using the values it stores, but I'm sure we can find a way around it.
from jruby-parser.
Related Issues (20)
- Next, Break, Rescue, RescueBody, Module have inconsistent asserts HOT 1
- `not` is parsed as an operator HOT 5
- Implement stubby lambda node (1.9) HOT 1
- Misses empty expressions in literal array HOT 5
- Doesn't parse hash literal with = at end of key name HOT 1
- 2.0 parser doesn't give call with block nodes the entire source position
- 2.0 parser sometimes reports iters as args HOT 1
- Invoke the 1.8 or 1.9 parser HOT 5
- IndexOutOfBoundsException while rewriting HOT 1
- Parsing rescue statements is wrong for lexical representation
- IndexOutOfBounds with an array node HOT 3
- Push a gem release?
- Parser duplicating nodes HOT 5
- ReWriteVisitor malforms code for argument nodes and symbols HOT 1
- Ruby 2.0 parser fails to parse lambda arrow syntax with space HOT 3
- Fails in lexer with a file using the unicode characters HOT 2
- Parser error with required keyword arguments HOT 1
- mvn package fails with compilation error.
- Beginners question
- Rewrite code case HOT 3
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 jruby-parser.