@quirekit/cm-legacy-modes 0.0.0-stage → 0.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +27 -2
- package/README.zh-CN.md +28 -0
- package/THIRD_PARTY_NOTICES.md +141 -0
- package/UPSTREAM.json +16 -0
- package/dist/mode/README.md +52 -0
- package/dist/mode/apl.d.ts +2 -0
- package/dist/mode/apl.js +140 -0
- package/dist/mode/asciiarmor.d.ts +2 -0
- package/dist/mode/asciiarmor.js +54 -0
- package/dist/mode/asn1.d.ts +12 -0
- package/dist/mode/asn1.js +190 -0
- package/dist/mode/asterisk.d.ts +2 -0
- package/dist/mode/asterisk.js +186 -0
- package/dist/mode/brainfuck.d.ts +2 -0
- package/dist/mode/brainfuck.js +68 -0
- package/dist/mode/clike.d.ts +35 -0
- package/dist/mode/clike.js +1019 -0
- package/dist/mode/clojure.d.ts +2 -0
- package/dist/mode/clojure.js +272 -0
- package/dist/mode/cmake.d.ts +2 -0
- package/dist/mode/cmake.js +80 -0
- package/dist/mode/cobol.d.ts +2 -0
- package/dist/mode/cobol.js +234 -0
- package/dist/mode/coffeescript.d.ts +2 -0
- package/dist/mode/coffeescript.js +327 -0
- package/dist/mode/commonlisp.d.ts +2 -0
- package/dist/mode/commonlisp.js +107 -0
- package/dist/mode/crystal.d.ts +2 -0
- package/dist/mode/crystal.js +417 -0
- package/dist/mode/css.d.ts +5 -0
- package/dist/mode/css.js +846 -0
- package/dist/mode/cypher.d.ts +2 -0
- package/dist/mode/cypher.js +120 -0
- package/dist/mode/d.d.ts +2 -0
- package/dist/mode/d.js +203 -0
- package/dist/mode/diff.d.ts +2 -0
- package/dist/mode/diff.js +29 -0
- package/dist/mode/dockerfile.d.ts +2 -0
- package/dist/mode/dockerfile.js +198 -0
- package/dist/mode/dtd.d.ts +2 -0
- package/dist/mode/dtd.js +120 -0
- package/dist/mode/dylan.d.ts +2 -0
- package/dist/mode/dylan.js +336 -0
- package/dist/mode/ebnf.d.ts +2 -0
- package/dist/mode/ebnf.js +149 -0
- package/dist/mode/ecl.d.ts +2 -0
- package/dist/mode/ecl.js +188 -0
- package/dist/mode/eiffel.d.ts +2 -0
- package/dist/mode/eiffel.js +145 -0
- package/dist/mode/elm.d.ts +2 -0
- package/dist/mode/elm.js +228 -0
- package/dist/mode/erlang.d.ts +2 -0
- package/dist/mode/erlang.js +580 -0
- package/dist/mode/factor.d.ts +2 -0
- package/dist/mode/factor.js +63 -0
- package/dist/mode/fcl.d.ts +2 -0
- package/dist/mode/fcl.js +153 -0
- package/dist/mode/forth.d.ts +2 -0
- package/dist/mode/forth.js +162 -0
- package/dist/mode/fortran.d.ts +2 -0
- package/dist/mode/fortran.js +171 -0
- package/dist/mode/gas.d.ts +3 -0
- package/dist/mode/gas.js +342 -0
- package/dist/mode/gherkin.d.ts +2 -0
- package/dist/mode/gherkin.js +146 -0
- package/dist/mode/go.d.ts +2 -0
- package/dist/mode/go.js +163 -0
- package/dist/mode/groovy.d.ts +2 -0
- package/dist/mode/groovy.js +226 -0
- package/dist/mode/haskell.d.ts +2 -0
- package/dist/mode/haskell.js +238 -0
- package/dist/mode/haxe.d.ts +3 -0
- package/dist/mode/haxe.js +490 -0
- package/dist/mode/http.d.ts +2 -0
- package/dist/mode/http.js +87 -0
- package/dist/mode/idl.d.ts +2 -0
- package/dist/mode/idl.js +274 -0
- package/dist/mode/javascript.d.ts +5 -0
- package/dist/mode/javascript.js +922 -0
- package/dist/mode/jinja2.d.ts +2 -0
- package/dist/mode/jinja2.js +170 -0
- package/dist/mode/julia.d.ts +2 -0
- package/dist/mode/julia.js +367 -0
- package/dist/mode/livescript.d.ts +2 -0
- package/dist/mode/livescript.js +257 -0
- package/dist/mode/lua.d.ts +2 -0
- package/dist/mode/lua.js +135 -0
- package/dist/mode/mathematica.d.ts +2 -0
- package/dist/mode/mathematica.js +153 -0
- package/dist/mode/mbox.d.ts +2 -0
- package/dist/mode/mbox.js +114 -0
- package/dist/mode/mirc.d.ts +2 -0
- package/dist/mode/mirc.js +174 -0
- package/dist/mode/mllike.d.ts +4 -0
- package/dist/mode/mllike.js +346 -0
- package/dist/mode/modelica.d.ts +2 -0
- package/dist/mode/modelica.js +190 -0
- package/dist/mode/mscgen.d.ts +4 -0
- package/dist/mode/mscgen.js +147 -0
- package/dist/mode/mumps.d.ts +2 -0
- package/dist/mode/mumps.js +127 -0
- package/dist/mode/nginx.d.ts +2 -0
- package/dist/mode/nginx.js +161 -0
- package/dist/mode/nsis.d.ts +2 -0
- package/dist/mode/nsis.js +78 -0
- package/dist/mode/ntriples.d.ts +2 -0
- package/dist/mode/ntriples.js +139 -0
- package/dist/mode/octave.d.ts +2 -0
- package/dist/mode/octave.js +123 -0
- package/dist/mode/oz.d.ts +2 -0
- package/dist/mode/oz.js +233 -0
- package/dist/mode/pascal.d.ts +2 -0
- package/dist/mode/pascal.js +122 -0
- package/dist/mode/pegjs.d.ts +2 -0
- package/dist/mode/pegjs.js +85 -0
- package/dist/mode/perl.d.ts +2 -0
- package/dist/mode/perl.js +818 -0
- package/dist/mode/pig.d.ts +2 -0
- package/dist/mode/pig.js +147 -0
- package/dist/mode/powershell.d.ts +2 -0
- package/dist/mode/powershell.js +379 -0
- package/dist/mode/properties.d.ts +2 -0
- package/dist/mode/properties.js +60 -0
- package/dist/mode/protobuf.d.ts +2 -0
- package/dist/mode/protobuf.js +55 -0
- package/dist/mode/pug.d.ts +2 -0
- package/dist/mode/pug.js +502 -0
- package/dist/mode/puppet.d.ts +2 -0
- package/dist/mode/puppet.js +203 -0
- package/dist/mode/python.d.ts +3 -0
- package/dist/mode/python.js +388 -0
- package/dist/mode/q.d.ts +2 -0
- package/dist/mode/q.js +124 -0
- package/dist/mode/r.d.ts +2 -0
- package/dist/mode/r.js +172 -0
- package/dist/mode/rpm.d.ts +3 -0
- package/dist/mode/rpm.js +88 -0
- package/dist/mode/ruby.d.ts +2 -0
- package/dist/mode/ruby.js +287 -0
- package/dist/mode/rust.d.ts +2 -0
- package/dist/mode/rust.js +54 -0
- package/dist/mode/sas.d.ts +2 -0
- package/dist/mode/sas.js +266 -0
- package/dist/mode/sass.d.ts +2 -0
- package/dist/mode/sass.js +427 -0
- package/dist/mode/scheme.d.ts +2 -0
- package/dist/mode/scheme.js +261 -0
- package/dist/mode/shell.d.ts +2 -0
- package/dist/mode/shell.js +146 -0
- package/dist/mode/sieve.d.ts +2 -0
- package/dist/mode/sieve.js +176 -0
- package/dist/mode/simple-mode.d.ts +14 -0
- package/dist/mode/simple-mode.js +136 -0
- package/dist/mode/smalltalk.d.ts +2 -0
- package/dist/mode/smalltalk.js +151 -0
- package/dist/mode/solr.d.ts +2 -0
- package/dist/mode/solr.js +78 -0
- package/dist/mode/sparql.d.ts +2 -0
- package/dist/mode/sparql.js +169 -0
- package/dist/mode/spreadsheet.d.ts +2 -0
- package/dist/mode/spreadsheet.js +96 -0
- package/dist/mode/sql.d.ts +27 -0
- package/dist/mode/sql.js +481 -0
- package/dist/mode/stex.d.ts +3 -0
- package/dist/mode/stex.js +245 -0
- package/dist/mode/stylus.d.ts +2 -0
- package/dist/mode/stylus.js +747 -0
- package/dist/mode/swift.d.ts +2 -0
- package/dist/mode/swift.js +200 -0
- package/dist/mode/tcl.d.ts +2 -0
- package/dist/mode/tcl.js +123 -0
- package/dist/mode/textile.d.ts +2 -0
- package/dist/mode/textile.js +440 -0
- package/dist/mode/tiddlywiki.d.ts +2 -0
- package/dist/mode/tiddlywiki.js +277 -0
- package/dist/mode/tiki.d.ts +2 -0
- package/dist/mode/tiki.js +291 -0
- package/dist/mode/toml.d.ts +2 -0
- package/dist/mode/toml.js +74 -0
- package/dist/mode/troff.d.ts +2 -0
- package/dist/mode/troff.js +63 -0
- package/dist/mode/ttcn-cfg.d.ts +2 -0
- package/dist/mode/ttcn-cfg.js +199 -0
- package/dist/mode/ttcn.d.ts +2 -0
- package/dist/mode/ttcn.js +255 -0
- package/dist/mode/turtle.d.ts +2 -0
- package/dist/mode/turtle.js +145 -0
- package/dist/mode/vb.d.ts +2 -0
- package/dist/mode/vb.js +254 -0
- package/dist/mode/vbscript.d.ts +3 -0
- package/dist/mode/vbscript.js +320 -0
- package/dist/mode/velocity.d.ts +2 -0
- package/dist/mode/velocity.js +184 -0
- package/dist/mode/verilog.d.ts +3 -0
- package/dist/mode/verilog.js +601 -0
- package/dist/mode/vhdl.d.ts +2 -0
- package/dist/mode/vhdl.js +172 -0
- package/dist/mode/wast.d.ts +2 -0
- package/dist/mode/wast.js +119 -0
- package/dist/mode/webidl.d.ts +2 -0
- package/dist/mode/webidl.js +179 -0
- package/dist/mode/xml.d.ts +3 -0
- package/dist/mode/xml.js +397 -0
- package/dist/mode/xquery.d.ts +2 -0
- package/dist/mode/xquery.js +415 -0
- package/dist/mode/yacas.d.ts +2 -0
- package/dist/mode/yacas.js +181 -0
- package/dist/mode/yaml.d.ts +2 -0
- package/dist/mode/yaml.js +101 -0
- package/dist/mode/z80.d.ts +3 -0
- package/dist/mode/z80.js +101 -0
- package/mode/README.md +52 -0
- package/mode/apl.d.ts +2 -0
- package/mode/apl.js +140 -0
- package/mode/asciiarmor.d.ts +2 -0
- package/mode/asciiarmor.js +54 -0
- package/mode/asn1.d.ts +12 -0
- package/mode/asn1.js +190 -0
- package/mode/asterisk.d.ts +2 -0
- package/mode/asterisk.js +186 -0
- package/mode/brainfuck.d.ts +2 -0
- package/mode/brainfuck.js +68 -0
- package/mode/clike.d.ts +35 -0
- package/mode/clike.js +1019 -0
- package/mode/clojure.d.ts +2 -0
- package/mode/clojure.js +272 -0
- package/mode/cmake.d.ts +2 -0
- package/mode/cmake.js +80 -0
- package/mode/cobol.d.ts +2 -0
- package/mode/cobol.js +234 -0
- package/mode/coffeescript.d.ts +2 -0
- package/mode/coffeescript.js +327 -0
- package/mode/commonlisp.d.ts +2 -0
- package/mode/commonlisp.js +107 -0
- package/mode/crystal.d.ts +2 -0
- package/mode/crystal.js +417 -0
- package/mode/css.d.ts +5 -0
- package/mode/css.js +846 -0
- package/mode/cypher.d.ts +2 -0
- package/mode/cypher.js +120 -0
- package/mode/d.d.ts +2 -0
- package/mode/d.js +203 -0
- package/mode/diff.d.ts +2 -0
- package/mode/diff.js +29 -0
- package/mode/dockerfile.d.ts +2 -0
- package/mode/dockerfile.js +198 -0
- package/mode/dtd.d.ts +2 -0
- package/mode/dtd.js +120 -0
- package/mode/dylan.d.ts +2 -0
- package/mode/dylan.js +336 -0
- package/mode/ebnf.d.ts +2 -0
- package/mode/ebnf.js +149 -0
- package/mode/ecl.d.ts +2 -0
- package/mode/ecl.js +188 -0
- package/mode/eiffel.d.ts +2 -0
- package/mode/eiffel.js +145 -0
- package/mode/elm.d.ts +2 -0
- package/mode/elm.js +228 -0
- package/mode/erlang.d.ts +2 -0
- package/mode/erlang.js +580 -0
- package/mode/factor.d.ts +2 -0
- package/mode/factor.js +63 -0
- package/mode/fcl.d.ts +2 -0
- package/mode/fcl.js +153 -0
- package/mode/forth.d.ts +2 -0
- package/mode/forth.js +162 -0
- package/mode/fortran.d.ts +2 -0
- package/mode/fortran.js +171 -0
- package/mode/gas.d.ts +3 -0
- package/mode/gas.js +342 -0
- package/mode/gherkin.d.ts +2 -0
- package/mode/gherkin.js +146 -0
- package/mode/go.d.ts +2 -0
- package/mode/go.js +163 -0
- package/mode/groovy.d.ts +2 -0
- package/mode/groovy.js +226 -0
- package/mode/haskell.d.ts +2 -0
- package/mode/haskell.js +238 -0
- package/mode/haxe.d.ts +3 -0
- package/mode/haxe.js +490 -0
- package/mode/http.d.ts +2 -0
- package/mode/http.js +87 -0
- package/mode/idl.d.ts +2 -0
- package/mode/idl.js +274 -0
- package/mode/javascript.d.ts +5 -0
- package/mode/javascript.js +922 -0
- package/mode/jinja2.d.ts +2 -0
- package/mode/jinja2.js +170 -0
- package/mode/julia.d.ts +2 -0
- package/mode/julia.js +367 -0
- package/mode/livescript.d.ts +2 -0
- package/mode/livescript.js +257 -0
- package/mode/lua.d.ts +2 -0
- package/mode/lua.js +135 -0
- package/mode/mathematica.d.ts +2 -0
- package/mode/mathematica.js +153 -0
- package/mode/mbox.d.ts +2 -0
- package/mode/mbox.js +114 -0
- package/mode/mirc.d.ts +2 -0
- package/mode/mirc.js +174 -0
- package/mode/mllike.d.ts +4 -0
- package/mode/mllike.js +346 -0
- package/mode/modelica.d.ts +2 -0
- package/mode/modelica.js +190 -0
- package/mode/mscgen.d.ts +4 -0
- package/mode/mscgen.js +147 -0
- package/mode/mumps.d.ts +2 -0
- package/mode/mumps.js +127 -0
- package/mode/nginx.d.ts +2 -0
- package/mode/nginx.js +161 -0
- package/mode/nsis.d.ts +2 -0
- package/mode/nsis.js +78 -0
- package/mode/ntriples.d.ts +2 -0
- package/mode/ntriples.js +139 -0
- package/mode/octave.d.ts +2 -0
- package/mode/octave.js +123 -0
- package/mode/oz.d.ts +2 -0
- package/mode/oz.js +233 -0
- package/mode/pascal.d.ts +2 -0
- package/mode/pascal.js +122 -0
- package/mode/pegjs.d.ts +2 -0
- package/mode/pegjs.js +85 -0
- package/mode/perl.d.ts +2 -0
- package/mode/perl.js +818 -0
- package/mode/pig.d.ts +2 -0
- package/mode/pig.js +147 -0
- package/mode/powershell.d.ts +2 -0
- package/mode/powershell.js +379 -0
- package/mode/properties.d.ts +2 -0
- package/mode/properties.js +60 -0
- package/mode/protobuf.d.ts +2 -0
- package/mode/protobuf.js +55 -0
- package/mode/pug.d.ts +2 -0
- package/mode/pug.js +502 -0
- package/mode/puppet.d.ts +2 -0
- package/mode/puppet.js +203 -0
- package/mode/python.d.ts +3 -0
- package/mode/python.js +388 -0
- package/mode/q.d.ts +2 -0
- package/mode/q.js +124 -0
- package/mode/r.d.ts +2 -0
- package/mode/r.js +172 -0
- package/mode/rpm.d.ts +3 -0
- package/mode/rpm.js +88 -0
- package/mode/ruby.d.ts +2 -0
- package/mode/ruby.js +287 -0
- package/mode/rust.d.ts +2 -0
- package/mode/rust.js +54 -0
- package/mode/sas.d.ts +2 -0
- package/mode/sas.js +266 -0
- package/mode/sass.d.ts +2 -0
- package/mode/sass.js +427 -0
- package/mode/scheme.d.ts +2 -0
- package/mode/scheme.js +261 -0
- package/mode/shell.d.ts +2 -0
- package/mode/shell.js +146 -0
- package/mode/sieve.d.ts +2 -0
- package/mode/sieve.js +176 -0
- package/mode/simple-mode.d.ts +14 -0
- package/mode/simple-mode.js +136 -0
- package/mode/smalltalk.d.ts +2 -0
- package/mode/smalltalk.js +151 -0
- package/mode/solr.d.ts +2 -0
- package/mode/solr.js +78 -0
- package/mode/sparql.d.ts +2 -0
- package/mode/sparql.js +169 -0
- package/mode/spreadsheet.d.ts +2 -0
- package/mode/spreadsheet.js +96 -0
- package/mode/sql.d.ts +27 -0
- package/mode/sql.js +481 -0
- package/mode/stex.d.ts +3 -0
- package/mode/stex.js +245 -0
- package/mode/stylus.d.ts +2 -0
- package/mode/stylus.js +747 -0
- package/mode/swift.d.ts +2 -0
- package/mode/swift.js +200 -0
- package/mode/tcl.d.ts +2 -0
- package/mode/tcl.js +123 -0
- package/mode/textile.d.ts +2 -0
- package/mode/textile.js +440 -0
- package/mode/tiddlywiki.d.ts +2 -0
- package/mode/tiddlywiki.js +277 -0
- package/mode/tiki.d.ts +2 -0
- package/mode/tiki.js +291 -0
- package/mode/toml.d.ts +2 -0
- package/mode/toml.js +74 -0
- package/mode/troff.d.ts +2 -0
- package/mode/troff.js +63 -0
- package/mode/ttcn-cfg.d.ts +2 -0
- package/mode/ttcn-cfg.js +199 -0
- package/mode/ttcn.d.ts +2 -0
- package/mode/ttcn.js +255 -0
- package/mode/turtle.d.ts +2 -0
- package/mode/turtle.js +145 -0
- package/mode/vb.d.ts +2 -0
- package/mode/vb.js +254 -0
- package/mode/vbscript.d.ts +3 -0
- package/mode/vbscript.js +320 -0
- package/mode/velocity.d.ts +2 -0
- package/mode/velocity.js +184 -0
- package/mode/verilog.d.ts +3 -0
- package/mode/verilog.js +601 -0
- package/mode/vhdl.d.ts +2 -0
- package/mode/vhdl.js +172 -0
- package/mode/wast.d.ts +2 -0
- package/mode/wast.js +119 -0
- package/mode/webidl.d.ts +2 -0
- package/mode/webidl.js +179 -0
- package/mode/xml.d.ts +3 -0
- package/mode/xml.js +397 -0
- package/mode/xquery.d.ts +2 -0
- package/mode/xquery.js +415 -0
- package/mode/yacas.d.ts +2 -0
- package/mode/yacas.js +181 -0
- package/mode/yaml.d.ts +2 -0
- package/mode/yaml.js +101 -0
- package/mode/z80.d.ts +3 -0
- package/mode/z80.js +101 -0
- package/package.json +37 -3
package/mode/crystal.js
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
function wordRegExp(words, end) {
|
|
2
|
+
return new RegExp((end ? "" : "^") + "(?:" + words.join("|") + ")" + (end ? "$" : "\\b"));
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function chain(tokenize, stream, state) {
|
|
6
|
+
state.tokenize.push(tokenize);
|
|
7
|
+
return tokenize(stream, state);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var operators = /^(?:[-+/%|&^]|\*\*?|[<>]{2})/;
|
|
11
|
+
var conditionalOperators = /^(?:[=!]~|===|<=>|[<>=!]=?|[|&]{2}|~)/;
|
|
12
|
+
var indexingOperators = /^(?:\[\][?=]?)/;
|
|
13
|
+
var anotherOperators = /^(?:\.(?:\.{2})?|->|[?:])/;
|
|
14
|
+
var idents = /^[a-z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/;
|
|
15
|
+
var types = /^[A-Z_\u009F-\uFFFF][a-zA-Z0-9_\u009F-\uFFFF]*/;
|
|
16
|
+
var keywords = wordRegExp([
|
|
17
|
+
"abstract", "alias", "as", "asm", "begin", "break", "case", "class", "def", "do",
|
|
18
|
+
"else", "elsif", "end", "ensure", "enum", "extend", "for", "fun", "if",
|
|
19
|
+
"include", "instance_sizeof", "lib", "macro", "module", "next", "of", "out", "pointerof",
|
|
20
|
+
"private", "protected", "rescue", "return", "require", "select", "sizeof", "struct",
|
|
21
|
+
"super", "then", "type", "typeof", "uninitialized", "union", "unless", "until", "when", "while", "with",
|
|
22
|
+
"yield", "__DIR__", "__END_LINE__", "__FILE__", "__LINE__"
|
|
23
|
+
]);
|
|
24
|
+
var atomWords = wordRegExp(["true", "false", "nil", "self"]);
|
|
25
|
+
var indentKeywordsArray = [
|
|
26
|
+
"def", "fun", "macro",
|
|
27
|
+
"class", "module", "struct", "lib", "enum", "union",
|
|
28
|
+
"do", "for"
|
|
29
|
+
];
|
|
30
|
+
var indentKeywords = wordRegExp(indentKeywordsArray);
|
|
31
|
+
var indentExpressionKeywordsArray = ["if", "unless", "case", "while", "until", "begin", "then"];
|
|
32
|
+
var indentExpressionKeywords = wordRegExp(indentExpressionKeywordsArray);
|
|
33
|
+
var dedentKeywordsArray = ["end", "else", "elsif", "rescue", "ensure"];
|
|
34
|
+
var dedentKeywords = wordRegExp(dedentKeywordsArray);
|
|
35
|
+
var dedentPunctualsArray = ["\\)", "\\}", "\\]"];
|
|
36
|
+
var dedentPunctuals = new RegExp("^(?:" + dedentPunctualsArray.join("|") + ")$");
|
|
37
|
+
var nextTokenizer = {
|
|
38
|
+
"def": tokenFollowIdent, "fun": tokenFollowIdent, "macro": tokenMacroDef,
|
|
39
|
+
"class": tokenFollowType, "module": tokenFollowType, "struct": tokenFollowType,
|
|
40
|
+
"lib": tokenFollowType, "enum": tokenFollowType, "union": tokenFollowType
|
|
41
|
+
};
|
|
42
|
+
var matching = {"[": "]", "{": "}", "(": ")", "<": ">"};
|
|
43
|
+
|
|
44
|
+
function tokenBase(stream, state) {
|
|
45
|
+
if (stream.eatSpace()) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Macros
|
|
50
|
+
if (state.lastToken != "\\" && stream.match("{%", false)) {
|
|
51
|
+
return chain(tokenMacro("%", "%"), stream, state);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (state.lastToken != "\\" && stream.match("{{", false)) {
|
|
55
|
+
return chain(tokenMacro("{", "}"), stream, state);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Comments
|
|
59
|
+
if (stream.peek() == "#") {
|
|
60
|
+
stream.skipToEnd();
|
|
61
|
+
return "comment";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Variables and keywords
|
|
65
|
+
var matched;
|
|
66
|
+
if (stream.match(idents)) {
|
|
67
|
+
stream.eat(/[?!]/);
|
|
68
|
+
|
|
69
|
+
matched = stream.current();
|
|
70
|
+
if (stream.eat(":")) {
|
|
71
|
+
return "atom";
|
|
72
|
+
} else if (state.lastToken == ".") {
|
|
73
|
+
return "property";
|
|
74
|
+
} else if (keywords.test(matched)) {
|
|
75
|
+
if (indentKeywords.test(matched)) {
|
|
76
|
+
if (!(matched == "fun" && state.blocks.indexOf("lib") >= 0) && !(matched == "def" && state.lastToken == "abstract")) {
|
|
77
|
+
state.blocks.push(matched);
|
|
78
|
+
state.currentIndent += 1;
|
|
79
|
+
}
|
|
80
|
+
} else if ((state.lastStyle == "operator" || !state.lastStyle) && indentExpressionKeywords.test(matched)) {
|
|
81
|
+
state.blocks.push(matched);
|
|
82
|
+
state.currentIndent += 1;
|
|
83
|
+
} else if (matched == "end") {
|
|
84
|
+
state.blocks.pop();
|
|
85
|
+
state.currentIndent -= 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (nextTokenizer.hasOwnProperty(matched)) {
|
|
89
|
+
state.tokenize.push(nextTokenizer[matched]);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return "keyword";
|
|
93
|
+
} else if (atomWords.test(matched)) {
|
|
94
|
+
return "atom";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return "variable";
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Class variables and instance variables
|
|
101
|
+
// or attributes
|
|
102
|
+
if (stream.eat("@")) {
|
|
103
|
+
if (stream.peek() == "[") {
|
|
104
|
+
return chain(tokenNest("[", "]", "meta"), stream, state);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
stream.eat("@");
|
|
108
|
+
stream.match(idents) || stream.match(types);
|
|
109
|
+
return "propertyName";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Constants and types
|
|
113
|
+
if (stream.match(types)) {
|
|
114
|
+
return "tag";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Symbols or ':' operator
|
|
118
|
+
if (stream.eat(":")) {
|
|
119
|
+
if (stream.eat("\"")) {
|
|
120
|
+
return chain(tokenQuote("\"", "atom", false), stream, state);
|
|
121
|
+
} else if (stream.match(idents) || stream.match(types) ||
|
|
122
|
+
stream.match(operators) || stream.match(conditionalOperators) || stream.match(indexingOperators)) {
|
|
123
|
+
return "atom";
|
|
124
|
+
}
|
|
125
|
+
stream.eat(":");
|
|
126
|
+
return "operator";
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Strings
|
|
130
|
+
if (stream.eat("\"")) {
|
|
131
|
+
return chain(tokenQuote("\"", "string", true), stream, state);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Strings or regexps or macro variables or '%' operator
|
|
135
|
+
if (stream.peek() == "%") {
|
|
136
|
+
var style = "string";
|
|
137
|
+
var embed = true;
|
|
138
|
+
var delim;
|
|
139
|
+
|
|
140
|
+
if (stream.match("%r")) {
|
|
141
|
+
// Regexps
|
|
142
|
+
style = "string.special";
|
|
143
|
+
delim = stream.next();
|
|
144
|
+
} else if (stream.match("%w")) {
|
|
145
|
+
embed = false;
|
|
146
|
+
delim = stream.next();
|
|
147
|
+
} else if (stream.match("%q")) {
|
|
148
|
+
embed = false;
|
|
149
|
+
delim = stream.next();
|
|
150
|
+
} else {
|
|
151
|
+
if(delim = stream.match(/^%([^\w\s=])/)) {
|
|
152
|
+
delim = delim[1];
|
|
153
|
+
} else if (stream.match(/^%[a-zA-Z_\u009F-\uFFFF][\w\u009F-\uFFFF]*/)) {
|
|
154
|
+
// Macro variables
|
|
155
|
+
return "meta";
|
|
156
|
+
} else if (stream.eat('%')) {
|
|
157
|
+
// '%' operator
|
|
158
|
+
return "operator";
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (matching.hasOwnProperty(delim)) {
|
|
163
|
+
delim = matching[delim];
|
|
164
|
+
}
|
|
165
|
+
return chain(tokenQuote(delim, style, embed), stream, state);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Here Docs
|
|
169
|
+
if (matched = stream.match(/^<<-('?)([A-Z]\w*)\1/)) {
|
|
170
|
+
return chain(tokenHereDoc(matched[2], !matched[1]), stream, state)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Characters
|
|
174
|
+
if (stream.eat("'")) {
|
|
175
|
+
stream.match(/^(?:[^']|\\(?:[befnrtv0'"]|[0-7]{3}|u(?:[0-9a-fA-F]{4}|\{[0-9a-fA-F]{1,6}\})))/);
|
|
176
|
+
stream.eat("'");
|
|
177
|
+
return "atom";
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Numbers
|
|
181
|
+
if (stream.eat("0")) {
|
|
182
|
+
if (stream.eat("x")) {
|
|
183
|
+
stream.match(/^[0-9a-fA-F_]+/);
|
|
184
|
+
} else if (stream.eat("o")) {
|
|
185
|
+
stream.match(/^[0-7_]+/);
|
|
186
|
+
} else if (stream.eat("b")) {
|
|
187
|
+
stream.match(/^[01_]+/);
|
|
188
|
+
}
|
|
189
|
+
return "number";
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (stream.eat(/^\d/)) {
|
|
193
|
+
stream.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+-]?\d+)?/);
|
|
194
|
+
return "number";
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Operators
|
|
198
|
+
if (stream.match(operators)) {
|
|
199
|
+
stream.eat("="); // Operators can follow assign symbol.
|
|
200
|
+
return "operator";
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (stream.match(conditionalOperators) || stream.match(anotherOperators)) {
|
|
204
|
+
return "operator";
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Parens and braces
|
|
208
|
+
if (matched = stream.match(/[({[]/, false)) {
|
|
209
|
+
matched = matched[0];
|
|
210
|
+
return chain(tokenNest(matched, matching[matched], null), stream, state);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Escapes
|
|
214
|
+
if (stream.eat("\\")) {
|
|
215
|
+
stream.next();
|
|
216
|
+
return "meta";
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
stream.next();
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function tokenNest(begin, end, style, started) {
|
|
224
|
+
return function (stream, state) {
|
|
225
|
+
if (!started && stream.match(begin)) {
|
|
226
|
+
state.tokenize[state.tokenize.length - 1] = tokenNest(begin, end, style, true);
|
|
227
|
+
state.currentIndent += 1;
|
|
228
|
+
return style;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
var nextStyle = tokenBase(stream, state);
|
|
232
|
+
if (stream.current() === end) {
|
|
233
|
+
state.tokenize.pop();
|
|
234
|
+
state.currentIndent -= 1;
|
|
235
|
+
nextStyle = style;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return nextStyle;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function tokenMacro(begin, end, started) {
|
|
243
|
+
return function (stream, state) {
|
|
244
|
+
if (!started && stream.match("{" + begin)) {
|
|
245
|
+
state.currentIndent += 1;
|
|
246
|
+
state.tokenize[state.tokenize.length - 1] = tokenMacro(begin, end, true);
|
|
247
|
+
return "meta";
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (stream.match(end + "}")) {
|
|
251
|
+
state.currentIndent -= 1;
|
|
252
|
+
state.tokenize.pop();
|
|
253
|
+
return "meta";
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return tokenBase(stream, state);
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function tokenMacroDef(stream, state) {
|
|
261
|
+
if (stream.eatSpace()) {
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
var matched;
|
|
266
|
+
if (matched = stream.match(idents)) {
|
|
267
|
+
if (matched == "def") {
|
|
268
|
+
return "keyword";
|
|
269
|
+
}
|
|
270
|
+
stream.eat(/[?!]/);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
state.tokenize.pop();
|
|
274
|
+
return "def";
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function tokenFollowIdent(stream, state) {
|
|
278
|
+
if (stream.eatSpace()) {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (stream.match(idents)) {
|
|
283
|
+
stream.eat(/[!?]/);
|
|
284
|
+
} else {
|
|
285
|
+
stream.match(operators) || stream.match(conditionalOperators) || stream.match(indexingOperators);
|
|
286
|
+
}
|
|
287
|
+
state.tokenize.pop();
|
|
288
|
+
return "def";
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function tokenFollowType(stream, state) {
|
|
292
|
+
if (stream.eatSpace()) {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
stream.match(types);
|
|
297
|
+
state.tokenize.pop();
|
|
298
|
+
return "def";
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function tokenQuote(end, style, embed) {
|
|
302
|
+
return function (stream, state) {
|
|
303
|
+
var escaped = false;
|
|
304
|
+
|
|
305
|
+
while (stream.peek()) {
|
|
306
|
+
if (!escaped) {
|
|
307
|
+
if (stream.match("{%", false)) {
|
|
308
|
+
state.tokenize.push(tokenMacro("%", "%"));
|
|
309
|
+
return style;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (stream.match("{{", false)) {
|
|
313
|
+
state.tokenize.push(tokenMacro("{", "}"));
|
|
314
|
+
return style;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (embed && stream.match("#{", false)) {
|
|
318
|
+
state.tokenize.push(tokenNest("#{", "}", "meta"));
|
|
319
|
+
return style;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
var ch = stream.next();
|
|
323
|
+
|
|
324
|
+
if (ch == end) {
|
|
325
|
+
state.tokenize.pop();
|
|
326
|
+
return style;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
escaped = embed && ch == "\\";
|
|
330
|
+
} else {
|
|
331
|
+
stream.next();
|
|
332
|
+
escaped = false;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return style;
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function tokenHereDoc(phrase, embed) {
|
|
341
|
+
return function (stream, state) {
|
|
342
|
+
if (stream.sol()) {
|
|
343
|
+
stream.eatSpace()
|
|
344
|
+
if (stream.match(phrase)) {
|
|
345
|
+
state.tokenize.pop();
|
|
346
|
+
return "string";
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
var escaped = false;
|
|
351
|
+
while (stream.peek()) {
|
|
352
|
+
if (!escaped) {
|
|
353
|
+
if (stream.match("{%", false)) {
|
|
354
|
+
state.tokenize.push(tokenMacro("%", "%"));
|
|
355
|
+
return "string";
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (stream.match("{{", false)) {
|
|
359
|
+
state.tokenize.push(tokenMacro("{", "}"));
|
|
360
|
+
return "string";
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (embed && stream.match("#{", false)) {
|
|
364
|
+
state.tokenize.push(tokenNest("#{", "}", "meta"));
|
|
365
|
+
return "string";
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
escaped = stream.next() == "\\" && embed;
|
|
369
|
+
} else {
|
|
370
|
+
stream.next();
|
|
371
|
+
escaped = false;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return "string";
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export const crystal = {
|
|
380
|
+
name: "crystal",
|
|
381
|
+
startState: function () {
|
|
382
|
+
return {
|
|
383
|
+
tokenize: [tokenBase],
|
|
384
|
+
currentIndent: 0,
|
|
385
|
+
lastToken: null,
|
|
386
|
+
lastStyle: null,
|
|
387
|
+
blocks: []
|
|
388
|
+
};
|
|
389
|
+
},
|
|
390
|
+
|
|
391
|
+
token: function (stream, state) {
|
|
392
|
+
var style = state.tokenize[state.tokenize.length - 1](stream, state);
|
|
393
|
+
var token = stream.current();
|
|
394
|
+
|
|
395
|
+
if (style && style != "comment") {
|
|
396
|
+
state.lastToken = token;
|
|
397
|
+
state.lastStyle = style;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return style;
|
|
401
|
+
},
|
|
402
|
+
|
|
403
|
+
indent: function (state, textAfter, cx) {
|
|
404
|
+
textAfter = textAfter.replace(/^\s*(?:\{%)?\s*|\s*(?:%\})?\s*$/g, "");
|
|
405
|
+
|
|
406
|
+
if (dedentKeywords.test(textAfter) || dedentPunctuals.test(textAfter)) {
|
|
407
|
+
return cx.unit * (state.currentIndent - 1);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return cx.unit * state.currentIndent;
|
|
411
|
+
},
|
|
412
|
+
|
|
413
|
+
languageData: {
|
|
414
|
+
indentOnInput: wordRegExp(dedentPunctualsArray.concat(dedentKeywordsArray), true),
|
|
415
|
+
commentTokens: {line: "#"}
|
|
416
|
+
}
|
|
417
|
+
};
|
package/mode/css.d.ts
ADDED