Page 1 of 2
Help to configure folding in my lexer
Posted: 20.06.2025 20:27
by RogerTunnicliffe
Hi Alexey,
forgive me as am new to this and know little of Regex but I wonder if you could help me.
My language has the following constructs
repeat.if
end.repeat
If (and sometimes .If)
End.If
I am having problems with folding when it detects the "repeat" in the "end.repeat" and matches it with an "IF" that may following
ie.
Repeat.If
somecode
End.Repeat
If X = 1
somecode
End.If
are you able to point me in the right direction
Thx
Roger
Re: Folding problems
Posted: 21.06.2025 07:20
by main Alexey
current lexer rules (regex) find only one word 'repeat' when text has 'repeat.if' ?
add the regex to find the whole thing 'repeat.if'. as one token.
some lexers do it: they have rule with regex [a-z_]\w* for usual words, and additional regex like
Code: Select all
(repeat\.if|end\.if|end\.repeat)\b
for special complex things.
this special rule must be placed _above_ usual rule.
Re: Folding problems
Posted: 21.06.2025 12:20
by RogerTunnicliffe
Thx Alexey, I'll give it a shot tomorrow morning.
Cheers
Roger
Oh yeah. How do I reference that in the start and end block ?
Re: Folding problems
Posted: 21.06.2025 14:00
by main Alexey
In the properties of the start/end block, check
[x] Identifier
(if regex-rule has kind 'Identifier')
and enter ID text:
end.if
Re: Folding problems
Posted: 21.06.2025 14:03
by main Alexey
How my version of 'CVBasic' end-rule looks like:
Re: Folding problems
Posted: 21.06.2025 23:20
by RogerTunnicliffe
Thx Alexey
Okay, last alteration to this post.!!
I seem to have it working in some programs but not others
One program might have the REPEAT's working but the IF's fail.
One program might have The IF's working while the REPEAT.IF, and the REPEAT.WHILE works but the REPEAT.FOR fails
The Lexer doesn't change only the program ???
Also...How do I stop these Repeats showing up in the Code Tree
Cheers
Roger
Re: Folding problems
Posted: 22.06.2025 14:45
by main Alexey
I don't undestand such vague questions. so, give me example file. with comments above blocks, which tell what you expect in each block.
and attach your .lcf file ( SynWrite/data/lexlib/LexerName.lcf ).
Re: Folding problems
Posted: 22.06.2025 14:58
by main Alexey
>>How do I stop these Repeats showing up in the Code Tree
Synwrite's LexerProps dialog has this checkbox for each range-rule:
[x] Display in syntax tree
Re: Help to configure folding in my lexer
Posted: 22.06.2025 22:08
by RogerTunnicliffe
Thx Alexey,
I have attached an archive.
You should be able to see when things work for one file but not the other
Cheers
Roger
Re: Help to configure folding in my lexer
Posted: 23.06.2025 07:23
by main Alexey
if I understand right, repeat-blocks were not folded. I fixed it. you missed the checkbox 'Ignore case' for begin-rule / end-rule. I checked it. now repeat-blocks are folded, and if-blocks too.
advice. you named lexer styles like 'white', 'red', 'aqua'.... bad! name them by sense:
Number
String
Id
Keyword
etc
I also fixed few regex. e.g. lead/trailing space is IGNORED: so I replaced it with \x20.