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 File] Fix line continuation #3999

Merged
merged 4 commits into from
Jul 9, 2024

Conversation

deathaxe
Copy link
Collaborator

This commit applies the following rule:

If ^ appears at the end of a line, the linefeed is stripped and the next character is escaped or uses its special meaning, if any. If the next character is also a linefeed, it is treated literal.

REM command seems to be working special by line continuation working only directly after the first token.

This commit applies the following rule:

If `^` appears at the end of a line, the linefeed is stripped and the next
character is escaped or uses its special meaning, if any.
If the next character is also a linefeed, it is treated literal.

REM command seems to be working special by line continuation working only
directly after the first token.
@deathaxe deathaxe force-pushed the pr/batch/fix-line-continuation branch from b6d0505 to b82c178 Compare June 22, 2024 15:30
Copy link
Contributor

@mataha mataha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaner than what I was attempting. I have a few comments though.

Batch File/Batch File.sublime-syntax Outdated Show resolved Hide resolved
Batch File/Batch File.sublime-syntax Show resolved Hide resolved
deathaxe added 3 commits June 23, 2024 10:36
A caret (`^`) at the beginning of a continued line is printed literal
as it is escaped by the continuing caret after stripping newline character.

1. It does not introduce an escape sequence.
2. It is not scoped `constant.character.escape` as it is just printed as is.
3. It differs from `^^` escape sequences by escaping caret already being
   scoped `punctuation.separator.continuation.line`.

Rule
====

Escaped <LF>

    - <LF> is stripped
    - The next character is escaped. If at the end of line buffer,
      then the next line is read and processed by phases 1 and 1.5
      and appended to the current one before escaping the next character.

Note:

Due to `^` being treated special, only at beginning of line, this construct
won't be supported properly under all circumstances when embedding batch
syntax into Markdown or any other syntax, with probably indented code blocks.
May be of interest, if syntax is extended by template languages.
Copy link
Contributor

@mataha mataha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@deathaxe deathaxe merged commit 5dbbc4d into sublimehq:master Jul 9, 2024
2 checks passed
@deathaxe deathaxe deleted the pr/batch/fix-line-continuation branch July 9, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants