Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Syntax Edit
  New Posts New Posts RSS Feed - lex class definition for "C language" string
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

lex class definition for "C language" string

 Post Reply Post Reply
Author
Message
popek_777 View Drop Down
Newbie
Newbie


Joined: 01 June 2014
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote popek_777 Quote  Post ReplyReply Direct Link To This Post Topic: lex class definition for "C language" string
    Posted: 01 June 2014 at 2:25pm
I'm trying to define lex class definition for C strings. First step was to take a class definition 
from one already defined in codejock samples. It looks like below (taken from file _cpp.schclass):

lexClass:
name = c_String
parent:dyn = c_CPP, c_CPPCodeBlock
children = c_URL
start:Tag = '"'
skip:Tag = '\\"', '\\\r\n', '\\\n\r', '\\\n', '\\\r'
end:Tag = '"', @eol
txt:colorFG = 0xE00000
DisplayName = 'String (Double Quotes)'

Class above does not cope well with text like one below:

"c:\\fdsasdf\\" + 333.3

result:
whole line is colored like text

expected:
only text between quotes is colored like text

To fix this issue I thought that when I additionally skip '\\' it will to the job but this didn't help.

Does anyone have an idea how to define C like string lex class to cope well with scenario described above?


Back to Top
flashermail View Drop Down
Newbie
Newbie


Joined: 01 July 2014
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote flashermail Quote  Post ReplyReply Direct Link To This Post Posted: 29 July 2014 at 4:36am
you have to change the skip:tag section, so that it looks like that:

lexClass:
name    = c_String   
parent:dyn    = c_CPP, c_CPPCodeBlock
children    = c_URL
start:Tag    = '"'
skip:Tag    = '\\\r\n', '\\\n\r', '\\\n', '\\\r'
end:Tag    = '"', @eol
txt:colorFG    = 0xE00000
DisplayName    = 'String (Double Quotes)'

But if you would like to get something like this:

1 "c:\\fdsasdf\\" + 333.3
2
3 "c:\\fd\n\r
4
5 sasdf\\" + 333.3

You need to change it to:

lexClass:
name    = c_String   
parent:dyn    = c_CPP, c_CPPCodeBlock
children    = c_URL
start:Tag    = '"'
skip:Tag    = '\\\r\n', '\\\n\r', '\\\n', '\\\r', '\n', '\n\r', '\r\n', '\r'
end:Tag    = '"', @eol
txt:colorFG    = 0xE00000
DisplayName    = 'String (Double Quotes)'

Best regards
 Flashermail
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.140 seconds.