Comments (6)
I'm looking into this issue, for now the following workaround should work:
a = {"ke":\
"looooooong string"
}
from rapydscript.
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.
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.
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.
Yeah functions as dictionary values are the reason the hack becomes necessary in the first place :)
from rapydscript.
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)
- append method does not compile to js push method HOT 1
- VSCode extension for syntax highlighting HOT 4
- cannot compare string HOT 3
- Typescript has problem compile RS --es6 output at class attributes HOT 2
- Why not support in-browser compiler? HOT 2
- enhancement: check for already reserved words like: enum HOT 18
- Cannot resolve python imports HOT 8
- Is that possible to parse python code to js AST? HOT 1
- fstring support. HOT 1
- How to keep all comments HOT 8
- Can't find python module that is installed and available? HOT 1
- Cannot catch ImportError HOT 2
- Cannot import from custom module in different directory HOT 5
- How to use RapydScript with JavaScript MutationObserver HOT 1
- Question about feasibility: option to use JS function syntax for nested functions, especially inside dicts/object-literals HOT 7
- How to run code snippets from tutorials on old Android? HOT 1
- Computed and negative slices
- parenthesized syntax HOT 2
- TypeError: undefined is not a function HOT 1
- Compiler issues HOT 1
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 rapydscript.