Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 99331

how can I match a string that is followed by a colon in a textmate grammar

$
0
0

I have a textmate grammar with just strings and colons. Is it possible to have a pattern that matches the strings that are followed by a colon with a different name than the strings that are not followed by a colon?

example:

"a""b""this one should be different": "c""d"

my current source:

{
    "name": "mylang",
    "scopeName": "source.mylang",
    "patterns": [
        {
            "match": ":",
            "name": "punctuation.definition.colon.mylang"
        },
        {
            "include": "#string"
        }
    ],
    "repository": {
        "string": {
            "begin": "\"",
            "beginCaptures": {
                "0": {
                    "name": "punctuation.definition.string.quote.begin.mylang"
                }
            },
            "end": "\"",
            "endCaptures": {
                "0": {
                    "name": "punctuation.definition.string.quote.end.mylang"
                }
            },
            "name": "string.quoted.double.mylang",
            "patterns": [
                {
                    "include": "#stringcontent"
                }
            ]
        },
        "stringcontent": {
            "patterns": [
                {
                    "match": "(?x)                # turn on extended mode\n  \\\\                # a literal backslash\n  (?:               # ...followed by...\n    [\"\\\\/bfnrt]     # one of these characters\n    |               # ...or...\n    u               # a u\n    [0-9a-fA-F]{4}) # and four hex digits",
                    "name": "constant.character.escape.mylang"
                },
                {
                    "match": "\\\\.",
                    "name": "invalid.illegal.unrecognized-string-escape.mylang"
                }
            ]
        }
    }
}

Viewing all articles
Browse latest Browse all 99331

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>