bevry / cson

CoffeeScript-Object-Notation. Same as JSON but for CoffeeScript objects.
Other
1.34k stars 55 forks source link

JSON 2 CSON conversion fails to escape '#{' pattern #91

Closed msftrncs closed 5 years ago

msftrncs commented 5 years ago

trying to convert a JSON tmLanguage file to a CSON format, I ran in to a issue where the tmLanguage parser in Atom didn't like the file. Turns out there must be some kind of construct using a #{…} (or maybe its #{(…)}) notation (subexpression?) and my tmLanguage file happens to have 5 such patterns in it. I'm showing the entire section below, but the issue is towards the middle of the begin property.

{
    beginCaptures:
        "1":
            name: "constant.numeric.hex.powershell"
        "2":
            name: "constant.language.powershell"
    begin: "(?>([+\\x{2013}-\\x{2015}-]?0(?i:x[0-9a-f_]+l?))((?i:[kmgtp]b)?))(?![^\\s#{(,;|)}<>.!+%*/=\\x{2013}-\\x{2015}-])"
    end: "$|(?![\\s#.+\\x{2013}-\\x{2015}-]|<#)"
    patterns: [
        {
            begin: "\\G(?=\\.(?!\\.)|::|\\[)"
            end: "(?=[^\\s\\p{L}]|\\n)"
            applyEndPatternLast: true
            patterns: [
                {
                    include: "#accessors"
                }
                {
                    match: "[^\\s\\W]+"
                }
            ]
        }
        {
            include: "#operators"
        }
        {
            include: "#commentBlock"
        }
        {
            include: "#commentLine"
        }
    ]
}

The value of the property is perfectly fine in JSON, but it needs the # (or the { following it) escaped in CSON in order to be acceptable to Atom.

balupton commented 5 years ago

Please cross post here https://github.com/groupon/cson-parser as this is a bug for the parser