Kentzo / MikrotikScript

Syntax highlighting and completions for the Mikrotik Scripting language for the Sublime Text editor
MIT License
58 stars 13 forks source link

Indented comments are not illegal #2

Closed mmastrac closed 10 years ago

mmastrac commented 10 years ago

At least in the version that I'm using, an indented comment is perfectly legal. Would it make sense to remove this check from the syntax?

mmastrac commented 10 years ago

This seems to work for me -- I can turn it into a pull request if it looks good:

diff --git a/MikrotikScript.YAML-tmLanguage b/MikrotikScript.YAML-tmLanguage
index 69e2085..00426de 100644
--- a/MikrotikScript.YAML-tmLanguage
+++ b/MikrotikScript.YAML-tmLanguage
@@ -43,15 +43,11 @@ repository:
   comments:
     patterns:
     - name: comment.line.number-sign.mikrotik-script
-      match: ^(#).*$\n?
+      match: (#).*$\n?
       captures:
         '1': {name: punctuation.definition.comment.mikrotik-script}
       comment: comments are ignored by syntax

-    - match: (#.*)$\n?
-      captures:
-        '1': {name: invalid.illegal.unexpected-comment.mikrotik-script}
-
   parameters-readwrite:
     patterns:
     - match: >
diff --git a/MikrotikScript.tmLanguage b/MikrotikScript.tmLanguage
index 57ac1d1..621f5f2 100644
--- a/MikrotikScript.tmLanguage
+++ b/MikrotikScript.tmLanguage
@@ -106,22 +106,10 @@
                                        <key>comment</key>
                                        <string>comments are ignored by syntax</string>
                                        <key>match</key>
-                                       <string>^(#).*$\n?</string>
+                                       <string>(#).*$\n?</string>
                                        <key>name</key>
                                        <string>comment.line.number-sign.mikrotik-script</string>
                                </dict>
-                               <dict>
-                                       <key>captures</key>
-                                       <dict>
-                                               <key>1</key>
-                                               <dict>
-                                                       <key>name</key>
-                                                       <string>invalid.illegal.unexpected-comment.mikrotik-script</string>
-                                               </dict>
-                                       </dict>
-                                       <key>match</key>
-                                       <string>(#.*)$\n?</string>
-                               </dict>
                        </array>
                </dict>
                <key>control-flow</key>
Kentzo commented 10 years ago

What version are you using? I guess it would make sense to ask on their forum first to confirm that it's not a bug in their parser.

mmastrac commented 10 years ago

I posted in the forums and it sounds like indented comments are valid as of 6.13: http://forum.mikrotik.com/viewtopic.php?f=9&t=88777&sid=f0127209049ca0ee2fc4b44a590714fe

mmastrac commented 10 years ago

Here's the changelog that specifies this as well:

http://forum.mikrotik.com/viewtopic.php?t=85085

It looks like this is also a valid comment now according to that post (the syntax highlighter in the ssh console confirms this):

put 1; # hi

Kentzo commented 10 years ago

Cool! Could you make a PR?

mmastrac commented 10 years ago

Closing in favour of PR #3