]> git.lizzy.rs Git - micro.git/commitdiff
Improve JavaScript syntax highlighting
authorAntoine Motet <antoine.motet@gmail.com>
Sun, 3 Dec 2017 22:30:29 +0000 (23:30 +0100)
committerAntoine Motet <antoine.motet@gmail.com>
Sun, 17 Dec 2017 22:53:58 +0000 (23:53 +0100)
- Sort keywords alphabetically
- Use `symbol.operator` for operators instead of `statement`
- Add a basic support for back-tick strings
- Mark unassigned keywords as errors

cmd/micro/runtime.go
runtime/syntax/javascript.yaml

index 6a08154cbed077f889564b4e39ce6824d80e088b..83ef61f85890bccffac627d31236d1f310c40c07 100644 (file)
@@ -2129,7 +2129,7 @@ func runtimeSyntaxJavaYaml() (*asset, error) {
        return a, nil
 }
 
-var _runtimeSyntaxJavascriptYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x54\x41\x73\xd3\x3a\x10\xbe\xe7\x57\xb8\x7e\x7d\xaf\xb6\x33\x8e\xf3\x0e\xef\x95\x66\x00\x4f\x81\xf4\x04\x85\x81\xe1\x82\xa4\x74\x64\x7b\x9d\xa8\x55\xe4\x8c\xb4\x4e\x1a\x58\xf8\xed\x8c\x9d\x84\xa6\x69\x08\xbd\xd4\x07\x59\xda\xf9\xf6\xdb\x4f\xbb\xda\x2d\x95\x06\x5c\xce\x60\xe0\x5d\xcb\xb9\x74\xb9\x55\x33\xec\x74\x0a\x40\xc8\x71\xd0\xf1\x3c\xcf\x6b\x10\x46\x4e\x61\xe0\xf9\x01\xe7\xbd\x6b\x77\x4c\x9c\xf7\xc0\xb1\xff\xfe\x3f\x7d\x26\xd2\xe3\xd0\x6f\x61\x13\x90\x05\xd8\x81\xe7\x8f\xfe\x3a\xea\x45\x49\x00\x66\xee\x75\xc3\xd4\x54\x05\x04\x1e\x35\xa8\x8e\xad\x35\xb8\x15\x69\xec\xe5\x95\x71\x28\x0d\xf6\x4c\x3d\xcd\x5a\x47\xce\x33\x16\x77\x45\x1a\xb0\x7f\xe3\x33\xc1\xfa\xf1\x99\x88\xa8\xcf\xfa\xf1\x69\xf3\xbf\x6d\x0c\x32\x2e\xcf\xe3\x0b\xd1\x0d\x03\x56\x7f\x16\x4c\xbf\x15\x29\x35\x6b\x73\x4a\xc3\x94\xf3\xcc\x7f\x04\x7d\xc3\xdc\xe5\xbc\xb7\x0e\xb1\xfa\x6d\xce\x0d\xf7\x10\x3e\xcc\x04\xeb\xc6\x22\x5d\x9b\x52\x56\x5e\x34\xc1\x1e\xcd\xfe\x90\x62\x87\x41\x15\x60\x50\x95\xaa\x75\x66\xe7\xf1\x17\x19\x7f\xbd\x12\xeb\x4d\x3f\x3e\xbb\x12\x11\x63\x03\x37\x93\x39\x0c\x84\x88\x58\x20\x36\x9e\x6e\x39\xcd\x2a\xdd\xcb\xac\xcc\x6f\x00\xdd\xaa\x2c\xdf\x88\xf3\xef\xe1\x41\x48\x40\x9c\x87\x87\x21\x8c\x38\x17\x87\x21\x4f\x12\x08\x25\xc2\x14\x0c\xae\xf2\x18\x64\x16\xe4\x0d\xe5\xd2\x01\xe5\x12\xf3\x09\xe5\x95\x41\x65\x6a\xa0\x02\x4a\x59\x6b\xa4\x02\x34\x20\x50\x51\x11\x68\x07\x54\x2a\x23\xb5\x5e\x86\x5b\xf5\xdf\xe5\x2c\x2b\x4b\x65\x6d\x72\x54\x95\xa1\x5c\x4b\xe7\x08\x6e\x11\x4c\xe1\x68\x0c\x48\xaa\x24\x65\x48\xb5\x55\xcd\xa1\x2a\xc9\xc0\x82\x2c\x60\x6d\x0d\x39\x40\x72\x0b\xd5\x08\x91\x6e\x69\x72\x92\x0b\xa9\xf0\x50\xb0\x35\x1a\x27\xca\x11\x4e\x6c\xb5\x20\xb4\x4b\x6a\xda\xac\x2a\x69\x2e\x2d\xb5\xef\x87\x34\x20\xcd\x2b\x55\xd0\x62\xa2\x34\xd0\x42\xe1\x24\xdc\xf3\x84\xd7\xa4\xa6\xd6\x9a\x6a\x53\x40\xa9\x0c\x14\x74\x29\x2f\x0f\x80\xd1\xd6\x40\xa5\xd4\x0e\xb6\x41\xab\x46\x6f\x01\xe7\xd6\xca\x25\xbd\xaa\x2a\x0d\xd2\xd0\x1b\x89\x40\x43\x53\x4f\xc1\x4a\xac\x2c\x0d\xad\xad\x2c\x5d\x6c\xf2\xf5\x4e\xde\x57\xb6\xc5\x73\xd9\x36\x00\xbd\xcf\xae\x21\x47\xfa\x08\xe3\xe1\xed\x8c\x3e\xa1\x55\x66\xfc\xbb\x0c\xb1\xb8\x9b\x44\x2f\x9e\xbf\x3c\xfa\xf1\x77\x3a\xf8\x87\xc4\x9e\x2b\x24\x6c\x14\x89\x80\x8d\x12\x41\x01\xe7\x9c\x27\x61\x18\xb1\x51\xb3\x13\x09\x1b\xab\xa9\x88\xf6\xde\x9b\xf3\x76\x5a\xb4\x4b\xba\x5a\xa9\xb1\xde\x9b\x1d\xad\x85\x65\xa5\xb1\x78\xc2\x7d\xce\xd3\x96\xd6\xef\xec\xb6\xb6\x6b\x2f\xb1\x1a\x57\xcd\xe7\x50\xda\x36\x8c\xef\xff\xb2\x81\x29\x76\x2c\xee\x46\xcd\xd6\x5a\x7a\x77\xd6\xad\xc9\xb7\xf9\xb6\x23\xcd\x20\x57\x52\xbf\x9e\x48\x7b\xe7\xfa\x58\x39\x27\xbb\x6a\x4e\x9e\x52\xcc\xb4\xad\xe1\x03\x11\x49\xb2\xab\xe2\x78\x37\x9e\xc7\xc4\x9f\x69\x38\x8f\x1e\x24\x97\x47\xc9\x5e\xae\x9f\x01\x00\x00\xff\xff\x7d\x0f\x62\xb5\xba\x06\x00\x00")
+var _runtimeSyntaxJavascriptYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x54\x5d\x73\xe3\x34\x14\x7d\xcf\xaf\xf0\x66\x0b\xb5\x9d\x71\x52\x1e\x60\x69\x06\xf0\x14\x68\x9f\xa0\x30\x30\xbc\x20\xa9\xbb\xd7\xf6\x75\xa2\x56\x96\x3d\xd2\x75\xd2\xc0\x85\xdf\xce\xc8\x49\x69\x71\xbb\xa5\x0f\x30\xeb\x07\xc9\xbe\x73\x74\xce\x91\xef\x47\xad\x0d\xd2\xae\xc3\x65\x74\x0d\x1b\xf0\xa5\xd3\x1d\x4d\x26\x15\x12\x96\xb4\x9c\x44\x51\x14\x05\x84\x85\x06\x97\xd1\x34\x96\x72\x7e\xed\x8f\x58\xca\x39\x7a\xf1\xe9\x67\x6f\x3e\x57\xf9\x51\x32\x1d\x60\x6b\x84\x0a\xdd\x32\x9a\x5e\xbd\x7e\x35\x4f\x17\x31\xda\x4d\x34\x4b\x72\xdb\x56\x18\x47\x1c\x50\x13\xd7\x1b\xf4\x7b\xd2\x2c\x2a\x5b\xeb\x09\x2c\xcd\x6d\xdf\x14\xc3\x41\x29\x0b\x91\xcd\x54\x1e\x8b\x4f\xb2\x53\x25\x4e\xb2\x53\x95\xf2\x89\x38\xc9\xde\x84\xfd\x36\x04\x20\xab\xcf\xb2\x0b\x35\x4b\x62\xd1\xff\xa2\x84\xf9\x4e\xe5\x1c\xd6\xf0\x95\x27\xb9\x94\xc5\xf4\x05\xf4\x81\x79\x26\xe5\xfc\x20\xb1\xdf\xee\xbe\x03\xf7\x39\xfe\xd8\x29\x31\xcb\x54\x7e\x08\xe5\xa2\xbe\x08\x62\x2f\x66\x7f\x4c\x31\x62\xd0\x15\x5a\xd2\xb5\x1e\x0e\x8b\xb3\xec\x57\xc8\x7e\x7b\xab\x0e\x2f\x27\xd9\xe9\x5b\x95\x0a\xb1\xf4\x1d\x94\xb8\x54\x2a\x15\xb1\xba\x3b\xe9\x77\x4d\xd1\x9a\x79\xe1\xa0\xbc\x41\xf2\xfb\xb4\xfc\xce\x52\xfe\x91\x3c\x0b\x89\x59\xca\xe4\x79\x88\x60\x29\xd5\xf3\x90\xff\x51\xa8\xed\xd0\x01\xb5\x2e\x60\x44\x36\x5b\xa4\x5f\x7e\xf1\xd5\xab\x3f\x3f\xca\x97\x1f\xf3\xfd\xe5\x09\x08\x1b\xb4\xb4\xff\xe5\x31\xf8\x9d\x2d\x19\xb6\xa0\x89\x0b\x87\x70\xc3\x25\x78\xe4\x12\xa8\x5c\xf3\x90\xa5\xb0\x92\xb6\x3d\x72\x85\x45\xbf\x5a\xa1\xe3\x0a\x6b\xe8\x0d\x71\x85\x06\x09\xb9\x6a\x19\x8d\x47\xc6\xdb\xae\x75\xc4\xb5\xb6\x60\xcc\x2e\x79\x50\x4c\x63\xd5\xba\x75\x5c\xf7\xb6\x24\xdd\x5a\x2e\x0d\x78\xcf\x78\x4b\x68\x2b\xcf\x2b\x24\xd6\x35\xeb\x66\xe0\xd2\x96\xf5\x50\x29\x25\xb6\x35\x1b\x24\xb6\xb8\x65\x87\xd4\x3b\xcb\x1e\xe9\x39\x11\xdf\x77\xe8\xd8\x6f\x75\xb8\x0a\xad\xb5\x67\x5a\xbb\x76\xcb\xe4\x76\x1c\x3a\xb6\xad\x79\x03\x8e\x37\xad\xae\x78\xbb\xd6\x06\x79\xab\x69\xcd\x3b\x8d\xa6\xba\xe7\x7d\x1d\x39\xf4\xe8\x36\x58\x45\x45\x4f\x51\x6f\xc1\x7b\xbd\xb2\x58\x1d\x54\xd1\xb9\xf6\x50\xbf\x31\xda\xbe\x09\xce\xcd\x60\xc3\xb3\xb6\x84\xae\x86\x12\xb9\x83\xf2\x06\x56\xc8\x9d\xd3\x1b\xa0\xb0\xb7\x61\x40\x60\xc5\x5d\x5f\x18\x5d\x26\xe3\xc6\x38\x30\xda\xde\x18\xee\x6d\x85\xb5\xb6\x58\xf1\x25\x5c\x26\x4f\xf4\xe8\x01\x4c\xae\x47\xae\xc1\x78\x7c\x08\xda\x0f\xa7\x01\x70\xe6\x1c\xec\xf8\xeb\xb6\x35\x08\x96\xbf\x0d\x46\xce\x6d\xdf\xec\xab\x86\xcf\xc3\x4d\xf8\xe2\x2e\x2d\xdf\x03\xad\xdf\xc3\x73\x39\x34\x2d\xff\x50\x5c\x63\x49\xfc\x13\xae\xce\x6f\x3b\xfe\x99\x9c\xb6\xab\xf7\xd8\x5b\x88\xab\x54\xc5\xe2\x6a\xa1\x38\x96\x52\xca\x45\x92\xa4\xe2\x2a\xbc\xa9\x85\x58\xe9\x46\xa5\x4f\xde\x49\xca\x61\x7a\x0d\x4b\xbe\x5f\x39\x44\xff\x31\xcb\x86\x88\x28\x6a\xeb\xe8\x58\x4e\xa5\xcc\x07\xda\xe9\x64\x3c\x6a\xfc\x60\x70\x3f\x3e\xc3\xe3\x09\xdc\x20\x33\x9d\xfe\x1d\x43\x5b\x8d\x22\xfe\x46\x77\x07\x2f\xf3\xfb\xe8\x83\x49\x7c\xf7\x3c\x54\xea\xb0\xd4\x60\xbe\x59\x83\xbb\x3f\xfa\x52\x3b\xc7\x63\x37\xc7\x1f\xd0\xcc\xbb\xb1\x99\x77\xff\x8d\x6c\x33\xf4\xe9\x23\xb9\xc5\x62\xac\x77\x34\xd6\x8b\x84\xfa\x77\x1a\x29\xd3\x47\x39\x95\xe9\xe2\x49\xae\xbf\x02\x00\x00\xff\xff\x25\x85\x54\x0e\xc1\x07\x00\x00")
 
 func runtimeSyntaxJavascriptYamlBytes() ([]byte, error) {
        return bindataRead(
index e51c5ff7d2e512f2b5d6864710dba29295d072cf..01553321c25617ade30b0cfbd79cca64fb9d864b 100644 (file)
@@ -15,14 +15,16 @@ rules:
     - symbol.brackets: "(\\{|\\})"
     - symbol.brackets: "(\\(|\\))"
     - symbol.brackets: "(\\[|\\])"
-    - statement: "\\b(break|case|catch|continue|default|delete|do|else|finally)\\b"
-    - statement: "\\b(for|function|class|extends|get|if|in|instanceof|new|return|set|switch|async|await)\\b"
-    - statement: "\\b(switch|this|throw|try|typeof|var|const|let|void|while|with)\\b"
+    - symbol.operator: "[-+/*=<>!~%?:&|]"
+    - statement: "\\b(async|await|break|case|catch|const|continue|debugger|default|delete|do|else|export|finally)\\b"
+    - statement: "\\b(for|function|class|extends|get|if|import|in|instanceof|let|new|return|set)\\b"
+    - statement: "\\b(super|switch|this|throw|try|typeof|var|void|while|with|yield)\\b"
+    # reserved but unassigned
+    - error: "\\b(enum|implements|interface|package|private|protected|public)"
     - constant: "\\b(null|undefined|NaN)\\b"
     - constant: "\\b(true|false)\\b"
     - type: "\\b(Array|Boolean|Date|Enumerator|Error|Function|Math)\\b"
     - type: "\\b(Number|Object|RegExp|String)\\b"
-    - statement: "[-+/*=<>!~%?:&|]"
     - constant: "/[^*]([^/]|(\\\\/))*[^\\\\]/[gim]*"
     - constant: "\\\\[0-7][0-7]?[0-7]?|\\\\x[0-9a-fA-F]+|\\\\[bfnrt'\"\\?\\\\]"
 
@@ -40,6 +42,12 @@ rules:
         rules:
             - constant.specialChar: "\\\\."
 
+    - constant.string:
+        start: "`"
+        end: "`"
+        rules:
+            - constant.specialChar: "\\\\."
+
     - comment:
         start: "//"
         end: "$"