Giter Site home page Giter Site logo

Comments (10)

michaelficarra avatar michaelficarra commented on May 19, 2024

Nice catch. So the AST is too permissive. Maybe @dherman would be interested in modifying the mozilla parser API so that this impossible construct cannot be represented.

from escodegen.

Constellation avatar Constellation commented on May 19, 2024

Thanks.

#36 is related issue.
I think creating another project, something like esverify to verify AST is valid form (check node stat and types) and escodegen assumes that given AST is valid is good.
What do you think about this?

from escodegen.

michaelficarra avatar michaelficarra commented on May 19, 2024

Yes, #36 is related. I'm not sure about the esverify project, as that would make the input format for escodegen a moving target. It'd be ideal if we could structure the parser API in such a way that it allows nothing but valid constructs. Unfortunately, I don't think Mozilla will be too flexible there.

I'd be interested in what @dherman thinks.

from escodegen.

Constellation avatar Constellation commented on May 19, 2024

I'm not sure about the esverify project

Oops, sorry for misleading. This is an example of new project name, not existing project.

I'd be interested in what @dherman thinks.

Yes, me too.

from escodegen.

michaelficarra avatar michaelficarra commented on May 19, 2024

Oops, sorry for misleading.

No, no. I think there was a miscommunication. What I'm not sure about is whether it is a good idea.

Also, @ariya may want to be involved in this.

from escodegen.

Constellation avatar Constellation commented on May 19, 2024

miscommunication.

Oops, I misunderstood.

from escodegen.

ariya avatar ariya commented on May 19, 2024

I'm fine either way. If the AST format permits something non-sensible, the consuming tool should understand that case. IMO it's not worth the effort to produce a format which is guaranteed to be associated with a valid syntax.

from escodegen.

michaelficarra avatar michaelficarra commented on May 19, 2024

Similarly, a TryStatement with an empty handlers list and a null finalizer property is a valid parser API construct, yet cannot be represented in JS syntax.

from escodegen.

michaelficarra avatar michaelficarra commented on May 19, 2024

Same goes for a BlockStatement whose first statement is an ExpressionStatement whose expression is a Literal whose value is a string. These will be parsed as DirectiveStatements, not strings.

from escodegen.

michaelficarra avatar michaelficarra commented on May 19, 2024

Also, to guarantee that parse(generate(tree)) == tree, we need to check that only valid operators are allowed in BinaryExpressions and LogicalExpressions.

from escodegen.

Related Issues (20)

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.