Git Product home page Git Product logo

shift-java's People

Contributors

alippai avatar bakkot avatar ikarienator avatar jsoverson avatar l-zharmukhametova avatar michaelficarra avatar protryon avatar shilpi3 avatar steindani avatar tntim96 avatar yaylinda avatar yinwang0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shift-java's Issues

Complex rest parameters fail to parse

e.g.

var x = 'outside';
var probeParam, probeBody;

({
  *m(
    ...[_ = (eval('var x = "inside";'), probeParam = function() { return x; })]
  ) {
    probeBody = function() { return x; }
  }
}.m().next());

replace ScopeAnalyzer.functionHelper isArrowFn boolean parameter with Scope.Type parameter

private State functionHelper(@NotNull Node fnNode, @NotNull State params, @NotNull State body, boolean isArrowFn) {

The Scope.Type should be passed into this function, not a boolean. Additionally, we could probably create a wrapper for this function that passes the appropriate Scope.Type given the type of the first parameter.

Tolerant parsing mode

Provide a new mode of parsing that Instead of throwing an exception and aborting parsing on the first JS error encoutered, parser attempts to continue parsing and provides collections of all the syntax errors.

Complex for-of LHSes are incorrectly rejected

e.g. https://github.com/tc39/test262/blob/master/test/language/statements/for-of/scope-body-lex-open.js etc

var probeBefore = function() { return x; };
let x = 'outside';
var probeExpr, probeDecl, probeBody;

for (
    let [x, _, __ = probeDecl = function() { return x; }]
    of
    [['inside', probeExpr = function() { typeof x; }]]
  )
  probeBody = function() { return x; };

assert.sameValue(probeBefore(), 'outside');
assert.throws(ReferenceError, probeExpr);
assert.sameValue(probeDecl(), 'inside', 'reference from ForDeclaration');
assert.sameValue(probeBody(), 'inside', 'reference from statement body');

Shall we stop caching the result of `Monoid.identity()` in the `MonoidalReducer`?

The way the current ReducerP is constructed is that all the state will have only one reference globally unless the user intentionally save it somewhere. It shows the possibility to treat the states linear typed and it will be a natural optimization to allow mutation in the object. But MonoidalReducer is caching the same empty object and using it everywhere. It prevent people to write bug-resistant mutational code and degrades performance.

Type safety in the reducer

Currently the reducer has methods which look like

public State reduceClassDeclaration(
  ClassDeclaration node,
  State name,
  Maybe<State> _super,
  ImmutableList<State> elements
)

where of course ClassDeclaration is shaped like

class ClassDeclaration(
  BindingIdentifier name,
  Maybe<Expression> _super,
  ImmutableList<ClassElement> elements
)

There is a guarantee provided by the director, but not the type system, that the fields of the node and the noninitial arguments of the method line up, in the sense that node._super.isJust() == _super.isJust(), node.elements.length == elements.length, etc.

The fact that this isn't enforced by the type system leads to a lot of unchecked .fromJust()s. We could avoid this by defining, for each node type, a node-with-associated-data type along the lines of

<T> class ClassDeclarationWithT(
  Pair<BindingIdentifierWith, T> name,
  Maybe<Pair<Expression, T>> _super,
  ImmutableList<Pair<ClassElementWith, T>> elements
)

and then making the signature of methods in Reducer<State> be

public State reduceClassDeclaration(
  ClassDeclarationWithT<State> state
)

This does have the downside that you don't get a reference to the original node, which the LazyCloneReducer among other interfaces wast - for example, you need the original node to look up its location in the data structure provided by ParserWithLocation. I suppose it could always be passed as a second argument for those cases.

You can of course automatically convert between reducers of this type and reducers of the existing type, though going from reducers of the existing type to reducers of this type requires having all those unchecked .fromJust()s.

RemoveSingleStatementBlocks causes parsing error in IE8

IE8 has problem with parsing code with single statement without braces, so the minifier can't safely have all single-statement blocks removed. For example:

if (false) do while (a) do this; while (b); while (c);

has trouble with IE8 but fine with other browsers. Putting braces around the outermost do-while statement and the problem will be gone.

if (false) do {while (a) do this; while (b); } while (c);

Suggestion is not to remove single-statement blocks.

A few of the attributes are not compliant to their lexical order

When I'm trying to parse ES5 with parser combinator, the inversed order is really annoying.
For example, when I parse ObjectProperty, I will first parse propertyName before I parse the expression, but DataProperty put the expression before the name.

It is useless to particularly define the order in an unnatural order, please fix it.

Comments

Provide a way to optionally parse comments

Add support for source location

SourceLocation is part of the shift-ast specification but it is not implemented for the Node interface. Implementation probably requires Node interface to become an abstract class implementation but since Node interface is referenced from all the AST model classes, it is best to build this change to model generator.

Node locations are not saved

#102 introduced a bug: the locations were calculated, but not stored.

Since com.shapesecurity.shift.parser.ParserWithLocation#locations was not replaced with the result of locations.put and also it was marked as final, the locations collection was not growing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.