Code Monkey home page Code Monkey logo

Comments (6)

atsepkov avatar atsepkov commented on July 20, 2024

I'm looking into this issue, for now the following workaround should work:

a = {"ke":\
    "looooooong string"
}

from rapydscript.

kovidgoyal avatar kovidgoyal commented on July 20, 2024

This is fundamentally unfixable with the current design of the compiler. The problem is that the the ':' character is used both to denote the start of a new block and to delineate keys from values. Indentation checking currently happens in the tokenizer and not the parser. The tokenizer has no reliable way to know if ':' mean a new block or end of key. This is the case because object literals can have function as values.

To fix this would mean moving the whitespace checking into the parser. But that is a pretty invasive change.

from rapydscript.

kovidgoyal avatar kovidgoyal commented on July 20, 2024

Actually, I figured this can be done fairly simply by having the parser modify the internal state of the tokenizer. This is not a clean solution, but it works, and is, as far as I can see the ebst that can be done with the current compiler design.

kovidgoyal/rapydscript-ng@880e38f

from rapydscript.

atsepkov avatar atsepkov commented on July 20, 2024

If I remember correctly, I already used a similar hack elsewhere - it was also to treat the state within a dictionary differently than within a regular block (although this may have been in original version of RapydScript). Also, you may have already addressed this (I haven't had a chance to look at your code), but beware of functions nested within the dictionary:

def():
    # normal indentation rules apply
    a = {
        # special indention rules
        "b":
            def():
                # normal indention rules again
                ...
        # special indentation rules
    }

from rapydscript.

kovidgoyal avatar kovidgoyal commented on July 20, 2024

Yeah functions as dictionary values are the reason the hack becomes necessary in the first place :)

from rapydscript.

atsepkov avatar atsepkov commented on July 20, 2024

This is now partially fixed, only the first key now throws this error. Don't remember which commit addressed it, but the code is now using a similar trick to Kovid's version - so I'm confused why it doesn't work when the split key appears in hash first.

from rapydscript.

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.