PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, December 14, 2022

[FIXED] How to get comments and string in regex?

 December 14, 2022     regex, syntax, syntax-highlighting, visual-studio-code     No comments   

Issue

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]


Solution

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.



Answered By - Tim Shidlovskii
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing