Coder Social home page Coder Social logo

Comments (3)

blake-regalia avatar blake-regalia commented on May 23, 2024

I just successfully implemented this, but unfortunately the embed feature is not as great as I'd hoped. The issue is that we want to interpolate strings inside of nested syntaxes, but every time there is an interpolation with embed, the only option is to completely pop out of the nested syntax which causes it to lose the current context. So once the interpolation ends and we're back in the string again, the nested syntax starts over at the root context and usually thinks everything after that is invalid. Here's an example:

screen shot 2018-05-09 at 12 28 23 am

Notice how everything goes to crap after the interpolation ends. The way we are currently doing it with set works because we can push a new Ecmascript context when we encounter the interpolation token under with_prototype (which only works with set/push). If embed also allowed with_prototype, then this wouldn't be an issue :(

#51

from ecmascript-sublime.

bathos avatar bathos commented on May 23, 2024

I’m not sure there’s any way around this — even if the nested context could be retained after leaving the interpolated sequence, it could easily be invalid on account of whatever got "black boxed" by the interpolation. That is, if I have a grammar that expects X Y Z, but considers X Z unintelligible, and the interpolation is like X ${ 'Y' } Z, there would be no recovery regardless of context.

I ran into this when I did the StyledJSX stuff: the built-in CSS syntax definition freaked out every time a property value was interpolated. To deal with it I ended up implementing a light, purely (or nearly purely) lexical grammar for CSS within ES Sublime:

https://github.com/bathos/Ecmascript-Sublime/blob/master/ecmascript.sublime-syntax#L5379-L5480

This approach happened to work well with CSS because it’s easy to reduce to small lexical constructs and its structure has little impact on producing good highlighting. It likely wouldn’t be as effective with most languages, which would end up loosing detail/correctness in more noticeable ways.

from ecmascript-sublime.

blake-regalia avatar blake-regalia commented on May 23, 2024

'Fixed' in 646e0e4

from ecmascript-sublime.

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.