Skip to content

Commit

Permalink
Batch: highlight "goto" keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
Sobak committed Feb 11, 2024
1 parent fe9fcb3 commit 07c9dd6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Language/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function setupRules()
'ROBOCOPY', 'SET', 'SETLOCAL', 'SC', 'SCHTASKS', 'SHIFT', 'SHUTDOWN', 'SORT', 'START',
'SUBST', 'SYSTEMINFO', 'TASKLIST', 'TASKKILL', 'TIME', 'TITLE', 'TREE', 'TYPE', 'VER',
'VERIFY', 'VOL', 'XCOPY', 'WMIC', 'CSCRIPT',
'echo', 'set', 'for', 'if', 'exit', 'else', 'do', 'not', 'defined', 'exist',
'echo', 'set', 'for', 'if', 'exit', 'else', 'do', 'not', 'defined', 'exist', 'goto',
]), ['priority' => 3]),
],

Expand Down
14 changes: 7 additions & 7 deletions Tests/Expected/Test/batch/big.bat.tkn
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ rem usage: backbat backupdir

rem Make sure that there is at least one argument

{keyword:Kadet\Highlighter\Parser\Token\Token}if{/keyword:Kadet\Highlighter\Parser\Token\Token} {keyword:Kadet\Highlighter\Parser\Token\Token}not{/keyword:Kadet\Highlighter\Parser\Token\Token} "{variable:Kadet\Highlighter\Parser\Token\Token}%1{/variable:Kadet\Highlighter\Parser\Token\Token}"=="" goto argsok
{keyword:Kadet\Highlighter\Parser\Token\Token}if{/keyword:Kadet\Highlighter\Parser\Token\Token} {keyword:Kadet\Highlighter\Parser\Token\Token}not{/keyword:Kadet\Highlighter\Parser\Token\Token} "{variable:Kadet\Highlighter\Parser\Token\Token}%1{/variable:Kadet\Highlighter\Parser\Token\Token}"=="" {keyword:Kadet\Highlighter\Parser\Token\Token}goto{/keyword:Kadet\Highlighter\Parser\Token\Token} argsok

{keyword:Kadet\Highlighter\Parser\Token\Token}echo{/keyword:Kadet\Highlighter\Parser\Token\Token} {string:Kadet\Highlighter\Parser\Token\Token}usage: {variable:Kadet\Highlighter\Parser\Token\Token}%0{/variable:Kadet\Highlighter\Parser\Token\Token} backupdir{/string:Kadet\Highlighter\Parser\Token\Token}
{keyword:Kadet\Highlighter\Parser\Token\Token}echo{/keyword:Kadet\Highlighter\Parser\Token\Token} {string:Kadet\Highlighter\Parser\Token\Token}where: backupdir is the directory to copy batch files{/string:Kadet\Highlighter\Parser\Token\Token}
{keyword:Kadet\Highlighter\Parser\Token\Token}echo{/keyword:Kadet\Highlighter\Parser\Token\Token} {string:Kadet\Highlighter\Parser\Token\Token}all batch files in the current directory will{/string:Kadet\Highlighter\Parser\Token\Token}
{keyword:Kadet\Highlighter\Parser\Token\Token}echo{/keyword:Kadet\Highlighter\Parser\Token\Token} {string:Kadet\Highlighter\Parser\Token\Token}be backed up{/string:Kadet\Highlighter\Parser\Token\Token}

goto end
{keyword:Kadet\Highlighter\Parser\Token\Token}goto{/keyword:Kadet\Highlighter\Parser\Token\Token} end


:argsok
Expand All @@ -33,23 +33,23 @@ goto end

{comment:Kadet\Highlighter\Parser\Token\Token}rem Check to make sure that the backupdir exists and isn't a file{/comment:Kadet\Highlighter\Parser\Token\Token}

{keyword:Kadet\Highlighter\Parser\Token\Token}if{/keyword:Kadet\Highlighter\Parser\Token\Token} {keyword:Kadet\Highlighter\Parser\Token\Token}not{/keyword:Kadet\Highlighter\Parser\Token\Token} {keyword:Kadet\Highlighter\Parser\Token\Token}exist{/keyword:Kadet\Highlighter\Parser\Token\Token} {variable:Kadet\Highlighter\Parser\Token\Token}%backupdir%{/variable:Kadet\Highlighter\Parser\Token\Token} goto notfile
{keyword:Kadet\Highlighter\Parser\Token\Token}if{/keyword:Kadet\Highlighter\Parser\Token\Token} {keyword:Kadet\Highlighter\Parser\Token\Token}not{/keyword:Kadet\Highlighter\Parser\Token\Token} {keyword:Kadet\Highlighter\Parser\Token\Token}exist{/keyword:Kadet\Highlighter\Parser\Token\Token} {variable:Kadet\Highlighter\Parser\Token\Token}%backupdir%{/variable:Kadet\Highlighter\Parser\Token\Token} {keyword:Kadet\Highlighter\Parser\Token\Token}goto{/keyword:Kadet\Highlighter\Parser\Token\Token} notfile

{keyword:Kadet\Highlighter\Parser\Token\Token}echo{/keyword:Kadet\Highlighter\Parser\Token\Token} {variable:Kadet\Highlighter\Parser\Token\Token}%backupdir%{/variable:Kadet\Highlighter\Parser\Token\Token} is a file
goto end
{keyword:Kadet\Highlighter\Parser\Token\Token}goto{/keyword:Kadet\Highlighter\Parser\Token\Token} end


:notfile

{comment:Kadet\Highlighter\Parser\Token\Token}rem If the directory does not exist, create it.{/comment:Kadet\Highlighter\Parser\Token\Token}

{keyword:Kadet\Highlighter\Parser\Token\Token}if{/keyword:Kadet\Highlighter\Parser\Token\Token} {keyword:Kadet\Highlighter\Parser\Token\Token}exist{/keyword:Kadet\Highlighter\Parser\Token\Token} {variable:Kadet\Highlighter\Parser\Token\Token}%backupdir%{/variable:Kadet\Highlighter\Parser\Token\Token}\nul goto skipdir
{keyword:Kadet\Highlighter\Parser\Token\Token}if{/keyword:Kadet\Highlighter\Parser\Token\Token} {keyword:Kadet\Highlighter\Parser\Token\Token}exist{/keyword:Kadet\Highlighter\Parser\Token\Token} {variable:Kadet\Highlighter\Parser\Token\Token}%backupdir%{/variable:Kadet\Highlighter\Parser\Token\Token}\nul {keyword:Kadet\Highlighter\Parser\Token\Token}goto{/keyword:Kadet\Highlighter\Parser\Token\Token} skipdir

{keyword:Kadet\Highlighter\Parser\Token\Token}md{/keyword:Kadet\Highlighter\Parser\Token\Token} {variable:Kadet\Highlighter\Parser\Token\Token}%backupdir%{/variable:Kadet\Highlighter\Parser\Token\Token}
{keyword:Kadet\Highlighter\Parser\Token\Token}if{/keyword:Kadet\Highlighter\Parser\Token\Token} "{variable:Kadet\Highlighter\Parser\Token\Token}%errorlevel%{/variable:Kadet\Highlighter\Parser\Token\Token}"=="0" goto skipdir
{keyword:Kadet\Highlighter\Parser\Token\Token}if{/keyword:Kadet\Highlighter\Parser\Token\Token} "{variable:Kadet\Highlighter\Parser\Token\Token}%errorlevel%{/variable:Kadet\Highlighter\Parser\Token\Token}"=="0" {keyword:Kadet\Highlighter\Parser\Token\Token}goto{/keyword:Kadet\Highlighter\Parser\Token\Token} skipdir

{keyword:Kadet\Highlighter\Parser\Token\Token}echo{/keyword:Kadet\Highlighter\Parser\Token\Token} {string:Kadet\Highlighter\Parser\Token\Token}Error creating backup directory{/string:Kadet\Highlighter\Parser\Token\Token}
goto end
{keyword:Kadet\Highlighter\Parser\Token\Token}goto{/keyword:Kadet\Highlighter\Parser\Token\Token} end


:skipdir
Expand Down

0 comments on commit 07c9dd6

Please sign in to comment.