Syntax highlighting in the IDE

Dec 9, 2012
20
0
I have noticed, that the IDE does not highlight the "then", "else", "to" (in a DO loop) keywords. Why aren't they coloured as "iff", "endiff" or "do" are.
 
Dec 9, 2012
20
0
None of those are keywords in a DO statement. (Except for "to", which is only valid in 1 out of 13 possible DO syntaxes -- and the editor isn't able to determine when that is true.)
I see, I wasn't clear enough. Only "to" may be a keyword in a DO statement, that's right. What about IFF statement then? The "THEN" keyword is mandatory, so I believe it could be recognised properly. The "ELSE" keyword, when present, must be alone on the line - this, I presume, gives also the editor to ability to recognise it as a keyword. It is just weird to see them not coloured, as keywords ...
 
Dec 9, 2012
20
0
Can you provide an example of the syntax you're using?
Sure:
For "to" with DO ("to" not coloured):
do j=1 to %nSources
set sourceName=%@xmlxpath[/Tasks/Task[%i]/Sources/Source[%j]/@name]
set source=%@xmlxpath[/Tasks/Task[%i]/Sources/Source[%j]]
gosub handleSource
enddo
For "then" and "else" not being coloured:
iff %maxSubBackups==0 then
set backupType=full
set fullNo=%@eval[%lastFull+1]
if %fullNo==1000 gosub renumber
else
set backupType=%subBackupType
set fullNo=%lastFull
endiff
 
May 20, 2008
11,380
98
Syracuse, NY, USA
That was easy to repro. In BDEBUGGER I typed what appears below. "Then" and "else" were not highlighted.
Code:
iff 1 == 1 then
    echo foo
else
    echo bar
endiff
 

rconn

Administrator
Staff member
May 14, 2008
12,340
149
Same goes for "elseiff" - not highlighted either

Keywords inside an internal command (like DO or IFF) are not colorized; only commands, operators, strings, variables, and comments. The colorizing lexer cannot differentiate between something like a "then" or "to" and any other command argument. Doing that would require a custom lexer for every command; not a feasible approach.
 
Dec 9, 2012
20
0
Keywords inside an internal command (like DO or IFF) are not colorized; only commands, operators, strings, variables, and comments. The colorizing lexer cannot differentiate between something like a "then" or "to" and any other command argument. Doing that would require a custom lexer for every command; not a feasible approach.
I have tried some incorrect syntax in the IDE, as e.g.
iff 1==1 to do then else elseiff
else then if do 1==1
and found that the statement/command keywords are colored regardless of the syntax ("iff", "do", "if" only). This suggests that the colorizing lexer in the IDE does not care much about the syntax of the actual command. That's OK, I believe. Then, however, it sounds feasible to me, if the lexer just colored specific additional keywords also whenever they are encountered, hence coloring "to", "then", "else" and "elseiff" as well. I gather the arguments of commands are not very likely to match these keywords exactly, the closest match that comes to my mind is when such a keyword is preceded by "/", "-" or "%" prefixes. If these prefixes would be present, the keywords would not be colored. That could be the maximum level of the required lexer's "inteligence".

I believe, that by applying the above scheme we can gain more legibility of the TCC source code than without it, where it is difficult to recognize the starts and ends of command sections (then - endiff, then - else, then - elseiff, else - endiff, etc.) and some parts of the command, vital for its understanding are less visible, than they could (e.g. do ... to).

UPDATE: If we would like to have some syntax-dependent coloring, then I another idea comes to my mind, based on the assumption, that the lexer does recognise (and color) the main commands and statements, so it knows, when it is INSIDE such a command or statement. The statements and commands could provide a dictionary of additional keywords to color in the context of that particular statement or command. Then, they would be just colored, whenever they come within that statement or command. I am not sure, though, if the benefit are big enough to justify the effort in comparison with the first idea presented above ...
 
Similar threads
Thread starter Title Forum Replies Date
M syntax for sftp with publickey Support 3
vefatica IDE external command syntax color? Support 1
Joe Caverly Command Input Syntax Colouring Support 3
C Nested IF syntax — TCC behaving differently to CMD Support 12
rps Documentation Regular expression syntax link broken Support 1
Dan Glynhampton Documentation v15 help: Syntax error in example of @DEC Support 0
D Syntax error when redirecting eval Support 5
C @diskfree[ ] syntax in 15.00.17 Support 0
cgunhouse Eventlog Syntax issue Support 8
krischik Stop Script after Syntax Error. Support 6
J syntax problems multiple commands (command & command) Support 4
C CMD's "nested quote" syntax Support 3
T TCTOOLBAR syntax Support 0
S Status line syntax help Support 2
H Double prompt for password with * in FTP syntax Support 3
dcantor FFIND syntax -- is /E"regex" /X supported? Support 2
C extended DIR syntax? Support 7
J Problem with %var:find=replace% syntax Support 5
A syntax colouring Support 0
dcantor Syntax files, and suggestion Support 0
J Problem with peculiar CMD syntax Support 2
Kachupp IDE watch references Support 11
T Thanks for the assistance with IDE vs Bdebugger Support 3
K_Meinhard Small problem in german IDE 26 Support 3
vefatica IDE - when breakpoint is on a blank line? Support 3
Peter Murschall IDE: After undocking the command expansion Window is offended Support 2
Peter Murschall IDE: Ctrl-W is a Harakiri Command ! Support 23
Kachupp ide/bdebugger Support 17
rps IDE/BDEBUGGER ? Support 1
vefatica IDE.EXE's command line? Support 19
Peter Murschall IDE: RTL with non-English resources-problem is back in Build 28 Support 4
Peter Murschall v24 IDE/BDEBUGGER won't start Support 9
vefatica IDE stuck on "Insert tabs as spaces" Support 0
Peter Murschall IDE/BDEBUUGER in TCC 22 didn't run Support 7
T Fixed Problem with use of Batch parameters in the IDE Support 1
T Fixed IDE locks up if edit window for running batch is closed Support 6
Peter Murschall IDE destroys Text on Ctrl-U/Ctrl-Shift-U Support 12
C BDEBUGGER/IDE crashing Support 1
vefatica Monospace font in IDE? Support 3
vefatica IDE crashes every time Support 6
R TCC IDE Tabs - inactive tabs hard to see Support 14
vefatica IDE crashing Support 11
vefatica Why doesn't "IDE %_ININAME" work? Support 4
vefatica IDE's dynamic help ... Support 0
vefatica Contuing IDE gripes Support 11
vefatica WAD IDE, output window to foreground Support 3
vefatica Fixed IDE weirdness Support 3
vefatica IDE double-click select? Support 29
vefatica Doesn't IDE auto-indent? Support 3
T bdebugger / ide usage confusion Support 14

Similar threads