@quirekit/cm-legacy-modes 0.0.0-stage → 0.0.1-alpha.0
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 +143 -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/yaml.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var cons = ['true', 'false', 'on', 'off', 'yes', 'no'];
|
|
2
|
+
var keywordRegex = new RegExp("\\b(("+cons.join(")|(")+"))$", 'i');
|
|
3
|
+
|
|
4
|
+
export const yaml = {
|
|
5
|
+
name: "yaml",
|
|
6
|
+
token: function(stream, state) {
|
|
7
|
+
var ch = stream.peek();
|
|
8
|
+
var esc = state.escaped;
|
|
9
|
+
state.escaped = false;
|
|
10
|
+
/* comments */
|
|
11
|
+
if (ch == "#" && (stream.pos == 0 || /\s/.test(stream.string.charAt(stream.pos - 1)))) {
|
|
12
|
+
stream.skipToEnd();
|
|
13
|
+
return "comment";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (stream.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/))
|
|
17
|
+
return "string";
|
|
18
|
+
|
|
19
|
+
if (state.literal && stream.indentation() > state.keyCol) {
|
|
20
|
+
stream.skipToEnd(); return "string";
|
|
21
|
+
} else if (state.literal) { state.literal = false; }
|
|
22
|
+
if (stream.sol()) {
|
|
23
|
+
state.keyCol = 0;
|
|
24
|
+
state.pair = false;
|
|
25
|
+
state.pairStart = false;
|
|
26
|
+
/* document start */
|
|
27
|
+
if(stream.match('---')) { return "def"; }
|
|
28
|
+
/* document end */
|
|
29
|
+
if (stream.match('...')) { return "def"; }
|
|
30
|
+
/* array list item */
|
|
31
|
+
if (stream.match(/^\s*-\s+/)) { return 'meta'; }
|
|
32
|
+
}
|
|
33
|
+
/* inline pairs/lists */
|
|
34
|
+
if (stream.match(/^(\{|\}|\[|\])/)) {
|
|
35
|
+
if (ch == '{')
|
|
36
|
+
state.inlinePairs++;
|
|
37
|
+
else if (ch == '}')
|
|
38
|
+
state.inlinePairs--;
|
|
39
|
+
else if (ch == '[')
|
|
40
|
+
state.inlineList++;
|
|
41
|
+
else
|
|
42
|
+
state.inlineList--;
|
|
43
|
+
return 'meta';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* list separator */
|
|
47
|
+
if (state.inlineList > 0 && !esc && ch == ',') {
|
|
48
|
+
stream.next();
|
|
49
|
+
return 'meta';
|
|
50
|
+
}
|
|
51
|
+
/* pairs separator */
|
|
52
|
+
if (state.inlinePairs > 0 && !esc && ch == ',') {
|
|
53
|
+
state.keyCol = 0;
|
|
54
|
+
state.pair = false;
|
|
55
|
+
state.pairStart = false;
|
|
56
|
+
stream.next();
|
|
57
|
+
return 'meta';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* start of value of a pair */
|
|
61
|
+
if (state.pairStart) {
|
|
62
|
+
/* block literals */
|
|
63
|
+
if (stream.match(/^\s*(\||\>)\s*/)) { state.literal = true; return 'meta'; };
|
|
64
|
+
/* references */
|
|
65
|
+
if (stream.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i)) { return 'variable'; }
|
|
66
|
+
/* numbers */
|
|
67
|
+
if (state.inlinePairs == 0 && stream.match(/^\s*-?[0-9\.\,]+\s?$/)) { return 'number'; }
|
|
68
|
+
if (state.inlinePairs > 0 && stream.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/)) { return 'number'; }
|
|
69
|
+
/* keywords */
|
|
70
|
+
if (stream.match(keywordRegex)) { return 'keyword'; }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* pairs (associative arrays) -> key */
|
|
74
|
+
if (!state.pair && stream.match(/^\s*(?:[,\[\]{}&*!|>'"%@`][^\s'":]|[^,\[\]{}#&*!|>'"%@`])[^#]*?(?=\s*:($|\s))/)) {
|
|
75
|
+
state.pair = true;
|
|
76
|
+
state.keyCol = stream.indentation();
|
|
77
|
+
return "atom";
|
|
78
|
+
}
|
|
79
|
+
if (state.pair && stream.match(/^:\s*/)) { state.pairStart = true; return 'meta'; }
|
|
80
|
+
|
|
81
|
+
/* nothing found, continue */
|
|
82
|
+
state.pairStart = false;
|
|
83
|
+
state.escaped = (ch == '\\');
|
|
84
|
+
stream.next();
|
|
85
|
+
return null;
|
|
86
|
+
},
|
|
87
|
+
startState: function() {
|
|
88
|
+
return {
|
|
89
|
+
pair: false,
|
|
90
|
+
pairStart: false,
|
|
91
|
+
keyCol: 0,
|
|
92
|
+
inlinePairs: 0,
|
|
93
|
+
inlineList: 0,
|
|
94
|
+
literal: false,
|
|
95
|
+
escaped: false
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
languageData: {
|
|
99
|
+
commentTokens: {line: "#"}
|
|
100
|
+
}
|
|
101
|
+
};
|
package/mode/z80.d.ts
ADDED
package/mode/z80.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
function mkZ80(ez80) {
|
|
2
|
+
var keywords1, keywords2;
|
|
3
|
+
if (ez80) {
|
|
4
|
+
keywords1 = /^(exx?|(ld|cp)([di]r?)?|[lp]ea|pop|push|ad[cd]|cpl|daa|dec|inc|neg|sbc|sub|and|bit|[cs]cf|x?or|res|set|r[lr]c?a?|r[lr]d|s[lr]a|srl|djnz|nop|[de]i|halt|im|in([di]mr?|ir?|irx|2r?)|ot(dmr?|[id]rx|imr?)|out(0?|[di]r?|[di]2r?)|tst(io)?|slp)(\.([sl]?i)?[sl])?\b/i;
|
|
5
|
+
keywords2 = /^(((call|j[pr]|rst|ret[in]?)(\.([sl]?i)?[sl])?)|(rs|st)mix)\b/i;
|
|
6
|
+
} else {
|
|
7
|
+
keywords1 = /^(exx?|(ld|cp|in)([di]r?)?|pop|push|ad[cd]|cpl|daa|dec|inc|neg|sbc|sub|and|bit|[cs]cf|x?or|res|set|r[lr]c?a?|r[lr]d|s[lr]a|srl|djnz|nop|rst|[de]i|halt|im|ot[di]r|out[di]?)\b/i;
|
|
8
|
+
keywords2 = /^(call|j[pr]|ret[in]?|b_?(call|jump))\b/i;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var variables1 = /^(af?|bc?|c|de?|e|hl?|l|i[xy]?|r|sp)\b/i;
|
|
12
|
+
var variables2 = /^(n?[zc]|p[oe]?|m)\b/i;
|
|
13
|
+
var errors = /^([hl][xy]|i[xy][hl]|slia|sll)\b/i;
|
|
14
|
+
var numbers = /^([\da-f]+h|[0-7]+o|[01]+b|\d+d?)\b/i;
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
name: "z80",
|
|
18
|
+
startState: function() {
|
|
19
|
+
return {
|
|
20
|
+
context: 0
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
token: function(stream, state) {
|
|
24
|
+
if (!stream.column())
|
|
25
|
+
state.context = 0;
|
|
26
|
+
|
|
27
|
+
if (stream.eatSpace())
|
|
28
|
+
return null;
|
|
29
|
+
|
|
30
|
+
var w;
|
|
31
|
+
|
|
32
|
+
if (stream.eatWhile(/\w/)) {
|
|
33
|
+
if (ez80 && stream.eat('.')) {
|
|
34
|
+
stream.eatWhile(/\w/);
|
|
35
|
+
}
|
|
36
|
+
w = stream.current();
|
|
37
|
+
|
|
38
|
+
if (stream.indentation()) {
|
|
39
|
+
if ((state.context == 1 || state.context == 4) && variables1.test(w)) {
|
|
40
|
+
state.context = 4;
|
|
41
|
+
return 'variable';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (state.context == 2 && variables2.test(w)) {
|
|
45
|
+
state.context = 4;
|
|
46
|
+
return 'variableName.special';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (keywords1.test(w)) {
|
|
50
|
+
state.context = 1;
|
|
51
|
+
return 'keyword';
|
|
52
|
+
} else if (keywords2.test(w)) {
|
|
53
|
+
state.context = 2;
|
|
54
|
+
return 'keyword';
|
|
55
|
+
} else if (state.context == 4 && numbers.test(w)) {
|
|
56
|
+
return 'number';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (errors.test(w))
|
|
60
|
+
return 'error';
|
|
61
|
+
} else if (stream.match(numbers)) {
|
|
62
|
+
return 'number';
|
|
63
|
+
} else {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
} else if (stream.eat(';')) {
|
|
67
|
+
stream.skipToEnd();
|
|
68
|
+
return 'comment';
|
|
69
|
+
} else if (stream.eat('"')) {
|
|
70
|
+
while (w = stream.next()) {
|
|
71
|
+
if (w == '"')
|
|
72
|
+
break;
|
|
73
|
+
|
|
74
|
+
if (w == '\\')
|
|
75
|
+
stream.next();
|
|
76
|
+
}
|
|
77
|
+
return 'string';
|
|
78
|
+
} else if (stream.eat('\'')) {
|
|
79
|
+
if (stream.match(/\\?.'/))
|
|
80
|
+
return 'number';
|
|
81
|
+
} else if (stream.eat('.') || stream.sol() && stream.eat('#')) {
|
|
82
|
+
state.context = 5;
|
|
83
|
+
|
|
84
|
+
if (stream.eatWhile(/\w/))
|
|
85
|
+
return 'def';
|
|
86
|
+
} else if (stream.eat('$')) {
|
|
87
|
+
if (stream.eatWhile(/[\da-f]/i))
|
|
88
|
+
return 'number';
|
|
89
|
+
} else if (stream.eat('%')) {
|
|
90
|
+
if (stream.eatWhile(/[01]/))
|
|
91
|
+
return 'number';
|
|
92
|
+
} else {
|
|
93
|
+
stream.next();
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const z80 = mkZ80(false)
|
|
101
|
+
export const ez80 = mkZ80(true)
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quirekit/cm-legacy-modes",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.1-alpha.0",
|
|
4
|
+
"description": "Collection of ported legacy language modes for the CodeMirror code editor",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/quirekit/quirekit.git",
|
|
9
|
+
"directory": "packages/cm/legacy-modes"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/quirekit/quirekit/tree/main/packages/cm/legacy-modes#readme",
|
|
12
|
+
"bugs": "https://github.com/quirekit/quirekit/issues",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"mode",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"THIRD_PARTY_NOTICES.md",
|
|
20
|
+
"UPSTREAM.json"
|
|
21
|
+
],
|
|
22
|
+
"exports": {
|
|
23
|
+
"./mode/*": {
|
|
24
|
+
"types": "./dist/mode/*.d.ts",
|
|
25
|
+
"import": "./dist/mode/*.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@quirekit/cm-language": "0.0.1-alpha.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"tsdown": "0.22.3",
|
|
34
|
+
"typescript": "6.0.3"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "node ../../../scripts/source-vendor/legacy.mjs",
|
|
38
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
39
|
+
}
|
|
6
40
|
}
|