Skip to content

Commit

Permalink
[Batch File] Fix comment scope around newlines
Browse files Browse the repository at this point in the history
I wish I knew what I was doing.
  • Loading branch information
mataha committed Jun 17, 2024
1 parent 3c25c09 commit 2b35efd
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Batch File/Batch File.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ contexts:
comment-body:
- meta_scope: comment.line.colon.dosbatch
- include: line-continuations
- match: \n
- match: $\n?
pop: 1

ignored-tail-inner:
Expand Down
93 changes: 79 additions & 14 deletions Batch File/tests/syntax_test_batch_file.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,60 +40,125 @@
REM ^
I'm a (com|ment) ^
not a comment
:: ^^^^^^^^^^^^^ - comment
:: ^^^^^^^^^^^^^^ - comment

REM
not a comment
:: ^^^^^^^^^^^^^ - comment
:: ^^^^^^^^^^^^^^ - comment

REM This follows a REM command
:: <- keyword.declaration.rem.dosbatch - comment
:: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.rem.dosbatch

REM This & and | echo "is commented out" ^
:: <- keyword.declaration.rem.dosbatch
:: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.command.rem.dosbatch comment.line.rem.dosbatch
:: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.command.rem.dosbatch comment.line.rem.dosbatch

REM No line ^
continuation
:: <- - comment
:: ^^^^^^^^^ - comment
:: ^^^^^^^^^^ - comment

::: Me too!
:: ^^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^^^^^ comment.line.colon.dosbatch

:::
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

:: Me too!
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^^^^ comment.line.colon.dosbatch

::
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

:+ Me too!
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^ comment.line.colon.dosbatch

:+
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

:= Me too!
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^ comment.line.colon.dosbatch

:=
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

:, Me too!
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^ comment.line.colon.dosbatch

:,
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

:; Me too!
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^ comment.line.colon.dosbatch

:;
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

: Me too!
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^ comment.line.colon.dosbatch

:
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

::^
Me too!
:: ^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^ comment.line.colon.dosbatch

::^

Me too!
:: ^^^^^^^^ comment.line.colon.dosbatch

::^


Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

: ^
Me too!
:: ^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^ comment.line.colon.dosbatch

: ^

Me too!
:: ^^^^^^^^ comment.line.colon.dosbatch

: ^


Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

: ^
A continued comment.^
Me too!
:: ^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^ comment.line.colon.dosbatch

: ^

Me too!
:: ^^^^^^^^ comment.line.colon.dosbatch

: ^
^
Not me, though.
:: ^^^^^^^^^^^^^^^^ - comment

:> ignored content ( & | )
:: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.colon.dosbatch
Expand All @@ -114,30 +179,30 @@ continuation
ECHO &&:: A comment
:: ^^ keyword.operator.logical.dosbatch
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^^^^^^ comment.line.colon.dosbatch

ECHO &:: A comment
:: ^ keyword.operator.logical.dosbatch
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^^^^^^ comment.line.colon.dosbatch

ECHO ||:: A comment
:: ^^ keyword.operator.logical.dosbatch
:: ^^ punctuation.definition.comment.dosbatch
:: ^^^^^^^^^^^^ comment.line.colon.dosbatch
:: ^^^^^^^^^^^^^ comment.line.colon.dosbatch

ECHO |:: Not a comment
:: ^ keyword.operator.assignment.pipe.dosbatch
:: ^^^^^^^^^^^^^^^^ invalid.illegal.unexpected.dosbatch

ECHO : Not a comment ^
:: ^^^^^^^^^^^^^^^ - comment
:: ^^^^^^^^^^^^^^^^^^ - comment
:: ^^ punctuation.separator.continuation.line.dosbatch

ECHO : Not a comment ^
:: Me not, too
:: <- - comment
::^^^^^^^^^^^^ - comment
::^^^^^^^^^^^^^ - comment

:::: [ @ Operator ] :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Expand Down

0 comments on commit 2b35efd

Please sign in to comment.