Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch Syntax "keyword" + ":" => "keyword:" dont work properly #222

Closed
GabrielFrigo4 opened this issue Jan 2, 2024 · 5 comments
Closed
Labels
batch Caused by the batch lexer committed Issue fixed in repository but not in release

Comments

@GabrielFrigo4
Copy link

GabrielFrigo4 commented Jan 2, 2024

In the .bat file, when I add a colon ":" right after a keyword => "keyword:', that keyword loses its highlighting, which was not supposed to happen. Furthermore, when I have a word before a function ":function_name" => "word :function_name", the function also loses its highlighting, and that was not expected behavior either

NOTE1: When a ":function_name" appears in the code between double quotes, it is not highlighted, which is the expected behavior.
NOTE2: I know that notepad++ != Lexilla. However, notepad++ uses Lexilla, so to fix this behavior in notepad++ you have to fix it in Lexilla

image

@GabrielFrigo4 GabrielFrigo4 changed the title Batch "keyword" + ":" => "keyword:" dont work properly Batch Syntax "keyword" + ":" => "keyword:" dont work properly Jan 2, 2024
@nyamatongwe nyamatongwe added the batch Caused by the batch lexer label Jan 3, 2024
@mpheath
Copy link

mpheath commented Jan 3, 2024

NOTE1: When a ":function_name" appears in the code between double quotes, it is not highlighted, which is the expected behavior.

Not aware of any issue with labels in quotes and I cannot consider why a label would be highlighted in quotes. So I have not done anything about it and not sure if I want to do more than necessary.

Before and after fix displayed in SciTE.
keyswords_with_colon

Issue222.bat.zip

@GabrielFrigo4
Copy link
Author

NOTE1: When a ":function_name" appears in the code between double quotes, it is not highlighted, which is the expected behavior.

Not aware of any issue with labels in quotes and I cannot consider why a label would be highlighted in quotes. So I have not done anything about it and not sure if I want to do more than necessary.

Before and after fix displayed in SciTE. keyswords_with_colon

Issue222.bat.zip

The correction is perfect.
Regarding NOTE1, I think I expressed myself wrong, as it is not supposed to highlight functions in quotation marks. I just wanted to make it clear that this was not supposed to change with this fix :)

@nyamatongwe
Copy link
Member

Why is this patch styling goto targets in SCE_BAT_COMMAND as if they were commands? There is a difference in the current lexer between goto and call but that is OK since call runs an external file command and goto is just internal flow control.

@mpheath
Copy link

mpheath commented Jan 4, 2024

@GabrielFrigo4 Keywords may look good. What follows the keywords is questionable. Thanks for the reply to clarify NOTE1.

@nyamatongwe call can be passed both an external command or a label as the label is recognized by the colon. It certainly is debatable about which direction to go with it as being command style or label as default style. Either go with command style or try to prevent it and use default style if a label. And goto followed the same logic as the decision as made with call. Some objection was expected about my decision and perhaps should be done the other way.

goto is always followed by label or sometimes I have seen (goto) with no label which IIRC alters the stack, which the latter seems OK as it terminates at ). goto might be easier to fix than call which as mentioned can be followed by label or command so might need special handling.

I'll try the other way of striving for default styling for label and see what can come up with. Might take alittle while as I have some other matters to attend to first. I may need to allocate more time into the other way as it might need more attention to correct the styling.

Test Gtihub styling:
call file.bat
call "file.bat"
call :label
goto :label
goto label
echo: %var%
echo: text
echo text
(goto)

and for those who cannot locate the spacebar:

call:label
goto:label
echo:%var%
echo:text

and to consider that colon is not needed for label after goto makes this invalid:

gotolabel

Seems worse with label styled as keyword. (goto) incorrect style. LexBatch has no string style to compare evenly and Github seems missing a command style so uses a default style unless quoted. Little inspiration there. LexBatch might be able to do better.

@mpheath
Copy link

mpheath commented Jan 4, 2024

Version 2.

This might be less colourful for labels, though the keywords are fixed. IMO it is more technically correct.

  • call can handle internal commands, external commands and labels.
  • A label is not a command so it should never have been styled as a command previously after goto or call.

Perhaps thoughts are I gone too much the other way. Consider that people claim that a called label is a function or subroutine. CMD with goto or call, stops and goes to the label and continues execution. The difference is that call processes arguments and returns back to the position of the caller. I see no clear evidence that a label can be a command.

Before and after fix displayed in SciTE.
keyswords_with_colon2

Issue222_v2.zip

@nyamatongwe nyamatongwe added the committed Issue fixed in repository but not in release label Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
batch Caused by the batch lexer committed Issue fixed in repository but not in release
Projects
None yet
Development

No branches or pull requests

3 participants