Lexer line continuation

All questions regarding lexer highlighting schemes are discussed here...
Post Reply
Lennart
Posts: 2
Joined: 15.01.2020 13:19

Lexer line continuation

Post by Lennart »

Hello,

SynWrite came to my attention and I do like it very much.

I have started a lexer for an internel script language. It's is working fine in SynWrite.
Now I'm looking for a way to continue a line, if it ends on the char | (maybe also whitspace afterwards)


E.g. a single line to lex would look like this:

Code: Select all

RCGetItems,Inspections.Inspection_1.Tool Set.002 M adjust threshold.Result Double Result.Range.Fail High|
   Inspections.Inspection_1.Tool Set.003 M adjust lut.Result Double Result.Range.Fail High|
   Inspections.Inspection_1.Tool Set.930 M Max area 1 Image.Result Double Result.Value|
   RemoteInputs.Remote Input 8|
   RemoteInputs.Remote Input 7|
   RemoteInputs.Remote Input 9,,Col

The first word is the command, the rest should be part of the same line. This is indicated by the | at the end.

Is there a way to achive this in SynWrite ?

This is also an example on a file to lex:

Code: Select all

RCPutConfig,,RT00100.0110-RC-ExternalTool-M2.pac,300000

PrintValue,Expecting LoadTime to be less than 6 Second.
If,LoadTime,grt,6
LogVariable,LoadTime,FAIL
else
LogVariable,LoadTime
Endif
*


RCSetItems,Inspections.Inspection_1.Tool Set.Image1=Test Image1-051503.bmp


********* Move to First Solid Circle **************
*************************************************************
 Set All External Tool Inputs 
*************************************************************

RCSetItems,Inspections.Inspection_1.Tool Set.External Tool.DLL.Input 01=101|
 Inspections.Inspection_1.Tool Set.External Tool.DLL.Input 02=111|
 Inspections.Inspection_1.Tool Set.External Tool.DLL.Input 03=121|
 Inspections.Inspection_1.Tool Set.External Tool.DLL.Input 04=131|
 Inspections.Inspection_1.Tool Set.External Tool.DLL.Input 05=141|
 Inspections.Inspection_1.Tool Set.External Tool.DLL.Input 06=151|
 Inspections.Inspection_1.Tool Set.External Tool.DLL.Input 07=161|
 Inspections.Inspection_1.Tool Set.External Tool.DLL.Input 08=171|   
 Inspections.Inspection_1.Tool Set.External Tool.DLL.Input 09=181|
 Inspections.Inspection_1.Tool Set.External Tool.DLL.Input 10=191| 
 Inspections.Inspection_1.Tool Set.External Tool.DLL.Input 11=201, , Col
Thank you very much!
Lennart
ScriptTesterTXT.7z
Lexer in question
(2.45 KiB) Downloaded 89 times
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

what do you mean by "achieve this in synwrite"? do you want to hilite the entire line with one color? part after 1st word with one color? what do you want to hilite and how?
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

in any way, reg.ex. for parser can include (\|\s*\n) to catch the | char with linebreak.
Lennart
Posts: 2
Joined: 15.01.2020 13:19

Post by Lennart »

Hello Alxey,

thank you for your hints. I should be more precise.

I'm dealing with a script language written by someone some time ago. But I cannot change it.

It is executed line by line.
lines start with a command (like RCSetItems, RCGetItems, If, LogItems) followed by some amount of parameters separated by comma.
This script language does also allow to deal with some sort of array, which is split by '|'

e.g. This is a valid command:
LogVariable,LoadTime,FAIL

or this:
RCPutConfig,,RT00100.0110-RC-ExternalTool-M2.pac,300000

or this
RCGetItems,Inspections.Inspection_1.Tool Set.002 M adjust threshold.Result Double Result.Range.Fail High|
Inspections.Inspection_1.Tool Set.003 M adjust lut.Result Double Result.Range.Fail High|
Inspections.Inspection_1.Tool Set.930 M Max area 1 Image.Result Double Result.Value|
RemoteInputs.Remote Input 8|
RemoteInputs.Remote Input 7|
RemoteInputs.Remote Input 9,,Col


The script language does also know comments. Comments are lines starting with // or * or with any amount of whitespace.

The lines starting with any amount of whitespace are the once troubling me. These can either be comments or, if the previous line ends on a | or a comma (+ possible whitespace), the line(s) should be lexed as if they where on a single line.

For the commands the goal is to highlight them only if they are at the beginning of the line (this is working fine), plus there are some special values in the current approach which are highlighted on any position. (Just if someone does wonder about them in the file attached in the original post.)

Best regards
Lennart
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Ok. so the tail of a command, is not highlighted yet? and this gives wrong highlighting of next line starting with a space (it must not be comment)? then you must add "parser rule" which will find the tail, and hilite it (with any style). the rule for tail must take tail with | char and next line (if | at the line end).

viewtopic.php?f=4&t=2336
Post Reply