Print Page | Close Window

lex class definition for "C language" string

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Syntax Edit
Forum Description: Topics Related to Codejock Syntax Edit
URL: http://forum.codejock.com/forum_posts.asp?TID=22314
Printed Date: 24 April 2024 at 11:31am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: lex class definition for "C language" string
Posted By: popek_777
Subject: lex class definition for "C language" string
Date 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?





Replies:
Posted By: flashermail
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net