Home > Enterprise >  How to get comments and string in regex?
How to get comments and string in regex?

Time:07-25

i have create a programming language KAGSA, and i have to create a syntax highlighter i start with VSCode highlighter i write every thing well but i have problem with regex of strings (more than one line) and comments (more than one line) this is the code : Match is the code: Comments :

"comments": {
            "patterns": [{
                "name": "comment.line.shebang.kagsa",
                "match": "//..*|/\\*(.*?|\n)*\\*/|//|/\\**\\*"
            }]
        },

The problem is wit the /*Comment*/ comment. and string code :

"strings": {
            "name": "string.quoted.double.kagsa",
            "patterns": [{
                "name": "string.quoted.double.kagsa",
                "match": "'(.*?)'|\"(.*?)\"|``(.*?|\n)*``"
            }]
        },

my problem is with ``String`` and the Color i get :

[the output color][https://i.stack.imgur.com/NPbS0.png]

CodePudding user response:

You have this issue because match doesn't work for multiline string literals. I found a similar problem. As said by Gama11 in his answer:

Try to use a begin / end pattern instead of a simple match.

  • Related