From 9cfc8cb2ef0d3928e2e9b005462f89edad13a6cc Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 18 Jun 2016 19:39:36 +0200 Subject: [PATCH] Add support for LiveScript --- components.js | 4 + components/prism-livescript.js | 118 ++++++++++++++++++ components/prism-livescript.min.js | 1 + examples/prism-livescript.html | 87 +++++++++++++ plugins/show-language/prism-show-language.js | 2 +- .../show-language/prism-show-language.min.js | 2 +- .../livescript/argument_feature.test | 17 +++ .../languages/livescript/boolean_feature.test | 21 ++++ .../languages/livescript/comment_feature.test | 18 +++ .../livescript/identifier_feature.test | 21 ++++ .../livescript/interpolated-string.test | 57 +++++++++ .../livescript/keyword-operator_feature.test | 57 +++++++++ .../languages/livescript/keyword_feature.test | 87 +++++++++++++ .../languages/livescript/number_feature.test | 21 ++++ .../livescript/operator_feature.test | 55 ++++++++ tests/languages/livescript/regex_feature.test | 27 ++++ .../languages/livescript/string_feature.test | 32 +++++ 17 files changed, 625 insertions(+), 2 deletions(-) create mode 100644 components/prism-livescript.js create mode 100644 components/prism-livescript.min.js create mode 100644 examples/prism-livescript.html create mode 100644 tests/languages/livescript/argument_feature.test create mode 100644 tests/languages/livescript/boolean_feature.test create mode 100644 tests/languages/livescript/comment_feature.test create mode 100644 tests/languages/livescript/identifier_feature.test create mode 100644 tests/languages/livescript/interpolated-string.test create mode 100644 tests/languages/livescript/keyword-operator_feature.test create mode 100644 tests/languages/livescript/keyword_feature.test create mode 100644 tests/languages/livescript/number_feature.test create mode 100644 tests/languages/livescript/operator_feature.test create mode 100644 tests/languages/livescript/regex_feature.test create mode 100644 tests/languages/livescript/string_feature.test diff --git a/components.js b/components.js index 47622735a2..becee49577 100644 --- a/components.js +++ b/components.js @@ -294,6 +294,10 @@ var components = { "require": "css", "owner": "Golmote" }, + "livescript": { + "title": "LiveScript", + "owner": "Golmote" + }, "lolcode": { "title": "LOLCODE", "owner": "Golmote" diff --git a/components/prism-livescript.js b/components/prism-livescript.js new file mode 100644 index 0000000000..97bee4aeb6 --- /dev/null +++ b/components/prism-livescript.js @@ -0,0 +1,118 @@ +Prism.languages.livescript = { + 'interpolated-string': { + pattern: /("""|")(?:\\[\s\S]|(?!\1)[^\\])*\1/, + greedy: true, + inside: { + 'variable': { + pattern: /(^|[^\\])#[a-z_](?:-?[a-z]|\d)*/m, + lookbehind: true + }, + 'interpolation': { + pattern: /(^|[^\\])#\{[^}]+\}/m, + lookbehind: true, + inside: { + 'interpolation-punctuation': { + pattern: /^#\{|\}$/, + alias: 'variable' + } + // See rest below + } + }, + 'string': /[\s\S]+/ + } + }, + 'comment': [ + { + pattern: /(^|[^\\])\/\*[\w\W]*?\*\//, + lookbehind: true, + greedy: true + }, + { + pattern: /(^|[^\\])#.*/, + lookbehind: true, + greedy: true + } + ], + 'string': [ + { + pattern: /('''|')(?:\\[\s\S]|(?!\1)[^\\])*\1/, + greedy: true + }, + { + pattern: /<\[[\s\S]*?\]>/, + greedy: true + }, + /\\[^\s,;\])}]+/ + ], + 'regex': [ + { + pattern: /\/\/(\[.+?]|\\.|(?!\/\/)[^\\])+\/\/[gimyu]{0,5}/, + greedy: true, + inside: { + 'comment': { + pattern: /(^|[^\\])#.*/, + lookbehind: true + } + } + }, + { + pattern: /\/(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}/, + greedy: true + } + ], + 'keyword': { + pattern: /(^|(?!-).)\b(?:break|case|catch|class|const|continue|default|do|else|extends|fallthrough|finally|for(?: ever)?|function|if|implements|it|let|loop|new|null|otherwise|own|return|super|switch|that|then|this|throw|try|unless|until|var|void|when|while|yield)(?!-)\b/m, + lookbehind: true + }, + 'keyword-operator': { + pattern: /(^|[^-])\b(?:(?:delete|require|typeof)!|(?:and|by|delete|export|from|import(?: all)?|in|instanceof|is(?:nt| not)?|not|of|or|til|to|typeof|with|xor)(?!-)\b)/m, + lookbehind: true, + alias: 'operator' + }, + 'boolean': { + pattern: /(^|[^-])\b(?:false|no|off|on|true|yes)(?!-)\b/m, + lookbehind: true + }, + 'argument': { + // Don't match .&. nor && + pattern: /(^|(?!\.&\.)[^&])&(?!&)\d*/m, + lookbehind: true, + alias: 'variable' + }, + 'number': /\b(?:\d+~[\da-z]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[a-z]\w*)?)/i, + 'identifier': /[a-z_](?:-?[a-z]|\d)*/i, + 'operator': [ + // Spaced . + { + pattern: /( )\.(?= )/, + lookbehind: true + }, + // Full list, in order: + // .= .~ .. ... + // .&. .^. .<<. .>>. .>>>. + // := :: ::= + // && + // || |> + // < << <<< <<<< + // <- <-- <-! <--! + // <~ <~~ <~! <~~! + // <| <= >> >= >? + // - -- -> --> + // + ++ + // @ @@ + // % %% + // * ** + // ! != !~= + // !~> !~~> + // !-> !--> + // ~ ~> ~~> ~= + // = == + // ^ ^^ + // / ? + /\.(?:[=~]|\.\.?)|\.(?:[&|^]|<<|>>>?)\.|:(?:=|:=?)|&&|\|[|>]|<(?:<[>=?]?|-(?:->?|>)?|\+\+?|@@?|%%?|\*\*?|!(?:~?=|--?>|~?~>)?|~(?:~?>|=)?|==?|\^\^?|[\/?]/ + ], + 'punctuation': /[(){}\[\]|.,:;`]/ +}; + +Prism.languages.livescript['interpolated-string'].inside['interpolation'].inside.rest = Prism.languages.livescript; \ No newline at end of file diff --git a/components/prism-livescript.min.js b/components/prism-livescript.min.js new file mode 100644 index 0000000000..b79f8157fd --- /dev/null +++ b/components/prism-livescript.min.js @@ -0,0 +1 @@ +Prism.languages.livescript={"interpolated-string":{pattern:/("""|")(?:\\[\s\S]|(?!\1)[^\\])*\1/,greedy:!0,inside:{variable:{pattern:/(^|[^\\])#[a-z_](?:-?[a-z]|\d)*/m,lookbehind:!0},interpolation:{pattern:/(^|[^\\])#\{[^}]+\}/m,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^#\{|\}$/,alias:"variable"}}},string:/[\s\S]+/}},comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0}],string:[{pattern:/('''|')(?:\\[\s\S]|(?!\1)[^\\])*\1/,greedy:!0},{pattern:/<\[[\s\S]*?\]>/,greedy:!0},/\\[^\s,;\])}]+/],regex:[{pattern:/\/\/(\[.+?]|\\.|(?!\/\/)[^\\])+\/\/[gimyu]{0,5}/,greedy:!0,inside:{comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0}}},{pattern:/\/(\[.+?]|\\.|[^\/\\\r\n])+\/[gimyu]{0,5}/,greedy:!0}],keyword:{pattern:/(^|(?!-).)\b(?:break|case|catch|class|const|continue|default|do|else|extends|fallthrough|finally|for(?: ever)?|function|if|implements|it|let|loop|new|null|otherwise|own|return|super|switch|that|then|this|throw|try|unless|until|var|void|when|while|yield)(?!-)\b/m,lookbehind:!0},"keyword-operator":{pattern:/(^|[^-])\b(?:(?:delete|require|typeof)!|(?:and|by|delete|export|from|import(?: all)?|in|instanceof|is(?:nt| not)?|not|of|or|til|to|typeof|with|xor)(?!-)\b)/m,lookbehind:!0,alias:"operator"},"boolean":{pattern:/(^|[^-])\b(?:false|no|off|on|true|yes)(?!-)\b/m,lookbehind:!0},argument:{pattern:/(^|(?!\.&\.)[^&])&(?!&)\d*/m,lookbehind:!0,alias:"variable"},number:/\b(?:\d+~[\da-z]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[a-z]\w*)?)/i,identifier:/[a-z_](?:-?[a-z]|\d)*/i,operator:[{pattern:/( )\.(?= )/,lookbehind:!0},/\.(?:[=~]|\.\.?)|\.(?:[&|^]|<<|>>>?)\.|:(?:=|:=?)|&&|\|[|>]|<(?:<[>=?]?|-(?:->?|>)?|\+\+?|@@?|%%?|\*\*?|!(?:~?=|--?>|~?~>)?|~(?:~?>|=)?|==?|\^\^?|[\/?]/],punctuation:/[(){}\[\]|.,:;`]/},Prism.languages.livescript["interpolated-string"].inside.interpolation.inside.rest=Prism.languages.livescript; \ No newline at end of file diff --git a/examples/prism-livescript.html b/examples/prism-livescript.html new file mode 100644 index 0000000000..7bc4ff82c9 --- /dev/null +++ b/examples/prism-livescript.html @@ -0,0 +1,87 @@ +

LiveScript

+

To use this language, use the class "language-livescript".

+ +

Comments

+
# This is a single line comment
+/* This is a
+multi line comment */
+ +

Numbers

+
42
+42km
+3.754km_2
+16~BadFace
+36~azertyuiop0123456789
+ +

Strings and interpolation

+
''
+''''''
+""
+""""""
+'Foo \' bar
+	baz'
+'''Foo \''' bar
+	bar'''
+"Foo #bar \"
+	#{2 + 2}\""
+"""#foobar \""" #{ if /test/ == 'test' then 3 else 4}
+	baz"""
+ +

Regex

+
/foobar/ig
+//
+^foo # foo
+[bar]*bA?z # barbaz
+//m
+ +

Full example

+
# example from Str.ls
+
+split = (sep, str) -->
+  str.split sep
+
+join = (sep, xs) -->
+  xs.join sep
+
+lines = (str) ->
+  return [] unless str.length
+  str.split '\n'
+
+unlines = (.join '\n')
+
+words = (str) ->
+  return [] unless str.length
+  str.split /[ ]+/
+
+unwords = (.join ' ')
+
+chars = (.split '')
+
+unchars = (.join '')
+
+reverse = (str) ->
+  str.split '' .reverse!.join ''
+
+repeat = (n, str) -->
+  result = ''
+  for til n
+    result += str
+  result
+
+capitalize = (str) ->
+  (str.char-at 0).to-upper-case! + str.slice 1
+
+camelize = (.replace /[-_]+(.)?/g, (, c) -> (c ? '').to-upper-case!)
+
+# convert camelCase to camel-case, and setJSON to set-JSON
+dasherize = (str) ->
+    str
+      .replace /([^-A-Z])([A-Z]+)/g, (, lower, upper) ->
+         "#{lower}-#{if upper.length > 1 then upper else upper.to-lower-case!}"
+      .replace /^([A-Z]+)/, (, upper) ->
+         if upper.length > 1 then "#upper-" else upper.to-lower-case!
+
+module.exports = {
+  split, join, lines, unlines, words, unwords, chars, unchars, reverse,
+  repeat, capitalize, camelize, dasherize,
+}
\ No newline at end of file diff --git a/plugins/show-language/prism-show-language.js b/plugins/show-language/prism-show-language.js index a448bb7c62..2749fcfea7 100644 --- a/plugins/show-language/prism-show-language.js +++ b/plugins/show-language/prism-show-language.js @@ -5,7 +5,7 @@ if (typeof self === 'undefined' || !self.Prism || !self.document) { } // The languages map is built automatically with gulp -var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","asciidoc":"AsciiDoc","aspnet":"ASP.NET (C#)","autoit":"AutoIt","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","graphql":"GraphQL","http":"HTTP","inform7":"Inform 7","json":"JSON","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","protobuf":"Protocol Buffers","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","yaml":"YAML"}/*]*/; +var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","asciidoc":"AsciiDoc","aspnet":"ASP.NET (C#)","autoit":"AutoIt","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","graphql":"GraphQL","http":"HTTP","inform7":"Inform 7","json":"JSON","latex":"LaTeX","livescript":"LiveScript","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","protobuf":"Protocol Buffers","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","yaml":"YAML"}/*]*/; Prism.hooks.add('before-highlight', function(env) { var pre = env.element.parentNode; if (!pre || !/pre/i.test(pre.nodeName)) { diff --git a/plugins/show-language/prism-show-language.min.js b/plugins/show-language/prism-show-language.min.js index 6343379c06..1955b70614 100644 --- a/plugins/show-language/prism-show-language.min.js +++ b/plugins/show-language/prism-show-language.min.js @@ -1 +1 @@ -!function(){if("undefined"!=typeof self&&self.Prism&&self.document){var e={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",css:"CSS",clike:"C-like",javascript:"JavaScript",abap:"ABAP",actionscript:"ActionScript",apacheconf:"Apache Configuration",apl:"APL",applescript:"AppleScript",asciidoc:"AsciiDoc",aspnet:"ASP.NET (C#)",autoit:"AutoIt",autohotkey:"AutoHotkey",basic:"BASIC",csharp:"C#",cpp:"C++",coffeescript:"CoffeeScript","css-extras":"CSS Extras",fsharp:"F#",glsl:"GLSL",graphql:"GraphQL",http:"HTTP",inform7:"Inform 7",json:"JSON",latex:"LaTeX",lolcode:"LOLCODE",matlab:"MATLAB",mel:"MEL",nasm:"NASM",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",ocaml:"OCaml",parigp:"PARI/GP",php:"PHP","php-extras":"PHP Extras",powershell:"PowerShell",protobuf:"Protocol Buffers",jsx:"React JSX",rest:"reST (reStructuredText)",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)",sql:"SQL",typescript:"TypeScript",vhdl:"VHDL",vim:"vim",wiki:"Wiki markup",yaml:"YAML"};Prism.hooks.add("before-highlight",function(s){var a=s.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var t,i,r=a.getAttribute("data-language")||e[s.language]||s.language.substring(0,1).toUpperCase()+s.language.substring(1),l=a.previousSibling;l&&/\s*\bprism-show-language\b\s*/.test(l.className)&&l.firstChild&&/\s*\bprism-show-language-label\b\s*/.test(l.firstChild.className)?i=l.firstChild:(t=document.createElement("div"),i=document.createElement("div"),i.className="prism-show-language-label",t.className="prism-show-language",t.appendChild(i),a.parentNode.insertBefore(t,a)),i.innerHTML=r}})}}(); \ No newline at end of file +!function(){if("undefined"!=typeof self&&self.Prism&&self.document){var e={html:"HTML",xml:"XML",svg:"SVG",mathml:"MathML",css:"CSS",clike:"C-like",javascript:"JavaScript",abap:"ABAP",actionscript:"ActionScript",apacheconf:"Apache Configuration",apl:"APL",applescript:"AppleScript",asciidoc:"AsciiDoc",aspnet:"ASP.NET (C#)",autoit:"AutoIt",autohotkey:"AutoHotkey",basic:"BASIC",csharp:"C#",cpp:"C++",coffeescript:"CoffeeScript","css-extras":"CSS Extras",fsharp:"F#",glsl:"GLSL",graphql:"GraphQL",http:"HTTP",inform7:"Inform 7",json:"JSON",latex:"LaTeX",livescript:"LiveScript",lolcode:"LOLCODE",matlab:"MATLAB",mel:"MEL",nasm:"NASM",nginx:"nginx",nsis:"NSIS",objectivec:"Objective-C",ocaml:"OCaml",parigp:"PARI/GP",php:"PHP","php-extras":"PHP Extras",powershell:"PowerShell",protobuf:"Protocol Buffers",jsx:"React JSX",rest:"reST (reStructuredText)",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)",sql:"SQL",typescript:"TypeScript",vhdl:"VHDL",vim:"vim",wiki:"Wiki markup",yaml:"YAML"};Prism.hooks.add("before-highlight",function(s){var a=s.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var t,i,r=a.getAttribute("data-language")||e[s.language]||s.language.substring(0,1).toUpperCase()+s.language.substring(1),l=a.previousSibling;l&&/\s*\bprism-show-language\b\s*/.test(l.className)&&l.firstChild&&/\s*\bprism-show-language-label\b\s*/.test(l.firstChild.className)?i=l.firstChild:(t=document.createElement("div"),i=document.createElement("div"),i.className="prism-show-language-label",t.className="prism-show-language",t.appendChild(i),a.parentNode.insertBefore(t,a)),i.innerHTML=r}})}}(); \ No newline at end of file diff --git a/tests/languages/livescript/argument_feature.test b/tests/languages/livescript/argument_feature.test new file mode 100644 index 0000000000..c195da9c5d --- /dev/null +++ b/tests/languages/livescript/argument_feature.test @@ -0,0 +1,17 @@ +& +&0 +&1 +&999 + +---------------------------------------------------- + +[ + ["argument", "&"], + ["argument", "&0"], + ["argument", "&1"], + ["argument", "&999"] +] + +---------------------------------------------------- + +Checks for arguments. \ No newline at end of file diff --git a/tests/languages/livescript/boolean_feature.test b/tests/languages/livescript/boolean_feature.test new file mode 100644 index 0000000000..8fa6348458 --- /dev/null +++ b/tests/languages/livescript/boolean_feature.test @@ -0,0 +1,21 @@ +false +no +off +on +true +yes + +---------------------------------------------------- + +[ + ["boolean", "false"], + ["boolean", "no"], + ["boolean", "off"], + ["boolean", "on"], + ["boolean", "true"], + ["boolean", "yes"] +] + +---------------------------------------------------- + +Checks for all boolean aliases. \ No newline at end of file diff --git a/tests/languages/livescript/comment_feature.test b/tests/languages/livescript/comment_feature.test new file mode 100644 index 0000000000..afb4276ecd --- /dev/null +++ b/tests/languages/livescript/comment_feature.test @@ -0,0 +1,18 @@ +/**/ +/* foo +bar */ +# +# foobar + +---------------------------------------------------- + +[ + ["comment", "/**/"], + ["comment", "/* foo\r\nbar */"], + ["comment", "#"], + ["comment", "# foobar"] +] + +---------------------------------------------------- + +Checks for comments. \ No newline at end of file diff --git a/tests/languages/livescript/identifier_feature.test b/tests/languages/livescript/identifier_feature.test new file mode 100644 index 0000000000..e0de5e84e1 --- /dev/null +++ b/tests/languages/livescript/identifier_feature.test @@ -0,0 +1,21 @@ +foo +fooBar42 +foo-bar42-baz +yes-no +function-case +delete-by + +---------------------------------------------------- + +[ + ["identifier", "foo"], + ["identifier", "fooBar42"], + ["identifier", "foo-bar42-baz"], + ["identifier", "yes-no"], + ["identifier", "function-case"], + ["identifier", "delete-by"] +] + +---------------------------------------------------- + +Checks for identifiers. \ No newline at end of file diff --git a/tests/languages/livescript/interpolated-string.test b/tests/languages/livescript/interpolated-string.test new file mode 100644 index 0000000000..015ae09043 --- /dev/null +++ b/tests/languages/livescript/interpolated-string.test @@ -0,0 +1,57 @@ +"""""" +"""Foo\"""bar""" +"""Foo +bar""" +"""#foobar #{foo + 42}""" + +"" +"Foo\"bar" +"Foo +bar" +"#foo #{ if /test/ == 'test' then 3 else 4}" + +---------------------------------------------------- + +[ + ["interpolated-string", [["string", "\"\"\"\"\"\""]]], + ["interpolated-string", [["string", "\"\"\"Foo\\\"\"\"bar\"\"\""]]], + ["interpolated-string", [["string", "\"\"\"Foo\r\nbar\"\"\""]]], + ["interpolated-string", [ + ["string", "\"\"\""], + ["variable", "#foobar"], + ["string", " "], + ["interpolation", [ + ["interpolation-punctuation", "#{"], + ["identifier", "foo"], + ["operator", "+"], + ["number", "42"], + ["interpolation-punctuation", "}"] + ]], + ["string", "\"\"\""] + ]], + ["interpolated-string", [["string", "\"\""]]], + ["interpolated-string", [["string", "\"Foo\\\"bar\""]]], + ["interpolated-string", [["string", "\"Foo\r\nbar\""]]], + ["interpolated-string", [ + ["string", "\""], + ["variable", "#foo"], + ["string", " "], + ["interpolation", [ + ["interpolation-punctuation", "#{"], + ["keyword", "if"], + ["regex", "/test/"], + ["operator", "=="], + ["string", "'test'"], + ["keyword", "then"], + ["number", "3"], + ["keyword", "else"], + ["number", "4"], + ["interpolation-punctuation", "}"] + ]], + ["string", "\""] + ]] +] + +---------------------------------------------------- + +Checks for interpolated strings. \ No newline at end of file diff --git a/tests/languages/livescript/keyword-operator_feature.test b/tests/languages/livescript/keyword-operator_feature.test new file mode 100644 index 0000000000..b6f3d90ad6 --- /dev/null +++ b/tests/languages/livescript/keyword-operator_feature.test @@ -0,0 +1,57 @@ +delete! +require! +typeof! + +and +by +delete +export +from +import +import all +in +instanceof +is +isnt +is not +not +of +or +til +to +typeof +with +xor + +---------------------------------------------------- + +[ + ["keyword-operator", "delete!"], + ["keyword-operator", "require!"], + ["keyword-operator", "typeof!"], + + ["keyword-operator", "and"], + ["keyword-operator", "by"], + ["keyword-operator", "delete"], + ["keyword-operator", "export"], + ["keyword-operator", "from"], + ["keyword-operator", "import"], + ["keyword-operator", "import all"], + ["keyword-operator", "in"], + ["keyword-operator", "instanceof"], + ["keyword-operator", "is"], + ["keyword-operator", "isnt"], + ["keyword-operator", "is not"], + ["keyword-operator", "not"], + ["keyword-operator", "of"], + ["keyword-operator", "or"], + ["keyword-operator", "til"], + ["keyword-operator", "to"], + ["keyword-operator", "typeof"], + ["keyword-operator", "with"], + ["keyword-operator", "xor"] +] + +---------------------------------------------------- + +Checks for all keyword operators. \ No newline at end of file diff --git a/tests/languages/livescript/keyword_feature.test b/tests/languages/livescript/keyword_feature.test new file mode 100644 index 0000000000..123f37d5fd --- /dev/null +++ b/tests/languages/livescript/keyword_feature.test @@ -0,0 +1,87 @@ +break +case +catch +class +const +continue +default +do +else +extends +fallthrough +finally +for +for ever +function +if +implements +it +let +loop +new +null +otherwise +own +return +super +switch +that +then +this +throw +try +unless +until +var +void +when +while +yield + +---------------------------------------------------- + +[ + ["keyword", "break"], + ["keyword", "case"], + ["keyword", "catch"], + ["keyword", "class"], + ["keyword", "const"], + ["keyword", "continue"], + ["keyword", "default"], + ["keyword", "do"], + ["keyword", "else"], + ["keyword", "extends"], + ["keyword", "fallthrough"], + ["keyword", "finally"], + ["keyword", "for"], + ["keyword", "for ever"], + ["keyword", "function"], + ["keyword", "if"], + ["keyword", "implements"], + ["keyword", "it"], + ["keyword", "let"], + ["keyword", "loop"], + ["keyword", "new"], + ["keyword", "null"], + ["keyword", "otherwise"], + ["keyword", "own"], + ["keyword", "return"], + ["keyword", "super"], + ["keyword", "switch"], + ["keyword", "that"], + ["keyword", "then"], + ["keyword", "this"], + ["keyword", "throw"], + ["keyword", "try"], + ["keyword", "unless"], + ["keyword", "until"], + ["keyword", "var"], + ["keyword", "void"], + ["keyword", "when"], + ["keyword", "while"], + ["keyword", "yield"] +] + +---------------------------------------------------- + +Checks for all keywords. \ No newline at end of file diff --git a/tests/languages/livescript/number_feature.test b/tests/languages/livescript/number_feature.test new file mode 100644 index 0000000000..7375927f83 --- /dev/null +++ b/tests/languages/livescript/number_feature.test @@ -0,0 +1,21 @@ +42 42_ 42km 42km_2 +4.514 0.47foo_7 +4_8_7_4.2_4_7 +4~12 +16~badFaCE +36~azertyuiop0123456789 + +---------------------------------------------------- + +[ + ["number", "42"], ["number", "42_"], ["number", "42km"], ["number", "42km_2"], + ["number", "4.514"], ["number", "0.47foo_7"], + ["number", "4_8_7_4.2_4_7"], + ["number", "4~12"], + ["number", "16~badFaCE"], + ["number", "36~azertyuiop0123456789"] +] + +---------------------------------------------------- + +Checks for numbers. \ No newline at end of file diff --git a/tests/languages/livescript/operator_feature.test b/tests/languages/livescript/operator_feature.test new file mode 100644 index 0000000000..d9565b24fd --- /dev/null +++ b/tests/languages/livescript/operator_feature.test @@ -0,0 +1,55 @@ +a . b +.= .~ .. ... +.&. .^. .<<. .>>. .>>>. +:= :: ::= +&& +|| |> +< << <<< <<<< +<- <-- <-! <--! +<~ <~~ <~! <~~! +<| <= >> >= >? +- -- -> --> ++ ++ +@ @@ +% %% +* ** +! != !~= +!~> !~~> +!-> !--> +~ ~> ~~> ~= += == +^ ^^ +/ ? + +---------------------------------------------------- + +[ + ["identifier", "a"], ["operator", "."], ["identifier", "b"], + ["operator", ".="], ["operator", ".~"], ["operator", ".."], ["operator", "..."], + ["operator", ".&."], ["operator", ".^."], ["operator", ".<<."], ["operator", ".>>."], ["operator", ".>>>."], + ["operator", ":="], ["operator", "::"], ["operator", "::="], + ["operator", "&&"], + ["operator", "||"], ["operator", "|>"], + ["operator", "<"], ["operator", "<<"], ["operator", "<<<"], ["operator", "<<<<"], + ["operator", "<-"], ["operator", "<--"], ["operator", "<-!"], ["operator", "<--!"], + ["operator", "<~"], ["operator", "<~~"], ["operator", "<~!"], ["operator", "<~~!"], + ["operator", "<|"], ["operator", "<="], ["operator", ""], ["operator", ">>"], ["operator", ">="], ["operator", ">?"], + ["operator", "-"], ["operator", "--"], ["operator", "->"], ["operator", "-->"], + ["operator", "+"], ["operator", "++"], + ["operator", "@"], ["operator", "@@"], + ["operator", "%"], ["operator", "%%"], + ["operator", "*"], ["operator", "**"], + ["operator", "!"], ["operator", "!="], ["operator", "!~="], + ["operator", "!~>"], ["operator", "!~~>"], + ["operator", "!->"], ["operator", "!-->"], + ["operator", "~"], ["operator", "~>"], ["operator", "~~>"], ["operator", "~="], + ["operator", "="], ["operator", "=="], + ["operator", "^"], ["operator", "^^"], + ["operator", "/"], ["operator", "?"] +] + +---------------------------------------------------- + +Checks for operators. \ No newline at end of file diff --git a/tests/languages/livescript/regex_feature.test b/tests/languages/livescript/regex_feature.test new file mode 100644 index 0000000000..0369ddb83f --- /dev/null +++ b/tests/languages/livescript/regex_feature.test @@ -0,0 +1,27 @@ +/foo[bar]/igm +// +foo | +[bar]* +//igmuy +// +foo #bar +[baz] # foo bar +// + +---------------------------------------------------- + +[ + ["regex", "/foo[bar]/igm"], + ["regex", ["//\r\nfoo |\r\n[bar]*\r\n//igmuy"]], + ["regex", [ + "//\r\nfoo ", + ["comment", "#bar"], + "\r\n[baz] ", + ["comment", "# foo bar"], + "\r\n//" + ]] +] + +---------------------------------------------------- + +Checks for regexps. \ No newline at end of file diff --git a/tests/languages/livescript/string_feature.test b/tests/languages/livescript/string_feature.test new file mode 100644 index 0000000000..313a1311a5 --- /dev/null +++ b/tests/languages/livescript/string_feature.test @@ -0,0 +1,32 @@ +'''''' +'''Foo\'''bar''' +'''Foo +bar''' + +'' +'Foo\'bar' +'Foo +bar' + +<[ foo bar baz ]> + +\foo \bar \"({[-!@^+baz + +---------------------------------------------------- + +[ + ["string", "''''''"], + ["string", "'''Foo\\'''bar'''"], + ["string", "'''Foo\r\nbar'''"], + ["string", "''"], + ["string", "'Foo\\'bar'"], + ["string", "'Foo\r\nbar'"], + ["string", "<[ foo bar baz ]>"], + ["string", "\\foo"], + ["string", "\\bar"], + ["string", "\\\"({[-!@^+baz"] +] + +---------------------------------------------------- + +Checks for strings. \ No newline at end of file