@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
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
// Tokenizer
|
|
2
|
+
|
|
3
|
+
function kw(type) {return {type: type, style: "keyword"};}
|
|
4
|
+
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
|
|
5
|
+
var operator = kw("operator"), atom = {type: "atom", style: "atom"}, attribute = {type:"attribute", style: "attribute"};
|
|
6
|
+
var type = kw("typedef");
|
|
7
|
+
var keywords = {
|
|
8
|
+
"if": A, "while": A, "else": B, "do": B, "try": B,
|
|
9
|
+
"return": C, "break": C, "continue": C, "new": C, "throw": C,
|
|
10
|
+
"var": kw("var"), "inline":attribute, "static": attribute, "using":kw("import"),
|
|
11
|
+
"public": attribute, "private": attribute, "cast": kw("cast"), "import": kw("import"), "macro": kw("macro"),
|
|
12
|
+
"function": kw("function"), "catch": kw("catch"), "untyped": kw("untyped"), "callback": kw("cb"),
|
|
13
|
+
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
|
|
14
|
+
"in": operator, "never": kw("property_access"), "trace":kw("trace"),
|
|
15
|
+
"class": type, "abstract":type, "enum":type, "interface":type, "typedef":type, "extends":type, "implements":type, "dynamic":type,
|
|
16
|
+
"true": atom, "false": atom, "null": atom
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
var isOperatorChar = /[+\-*&%=<>!?|]/;
|
|
20
|
+
|
|
21
|
+
function chain(stream, state, f) {
|
|
22
|
+
state.tokenize = f;
|
|
23
|
+
return f(stream, state);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function toUnescaped(stream, end) {
|
|
27
|
+
var escaped = false, next;
|
|
28
|
+
while ((next = stream.next()) != null) {
|
|
29
|
+
if (next == end && !escaped)
|
|
30
|
+
return true;
|
|
31
|
+
escaped = !escaped && next == "\\";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Used as scratch variables to communicate multiple values without
|
|
36
|
+
// consing up tons of objects.
|
|
37
|
+
var type, content;
|
|
38
|
+
function ret(tp, style, cont) {
|
|
39
|
+
type = tp; content = cont;
|
|
40
|
+
return style;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function haxeTokenBase(stream, state) {
|
|
44
|
+
var ch = stream.next();
|
|
45
|
+
if (ch == '"' || ch == "'") {
|
|
46
|
+
return chain(stream, state, haxeTokenString(ch));
|
|
47
|
+
} else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
|
48
|
+
return ret(ch);
|
|
49
|
+
} else if (ch == "0" && stream.eat(/x/i)) {
|
|
50
|
+
stream.eatWhile(/[\da-f]/i);
|
|
51
|
+
return ret("number", "number");
|
|
52
|
+
} else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
|
|
53
|
+
stream.match(/^\d*(?:\.\d*(?!\.))?(?:[eE][+\-]?\d+)?/);
|
|
54
|
+
return ret("number", "number");
|
|
55
|
+
} else if (state.reAllowed && (ch == "~" && stream.eat(/\//))) {
|
|
56
|
+
toUnescaped(stream, "/");
|
|
57
|
+
stream.eatWhile(/[gimsu]/);
|
|
58
|
+
return ret("regexp", "string.special");
|
|
59
|
+
} else if (ch == "/") {
|
|
60
|
+
if (stream.eat("*")) {
|
|
61
|
+
return chain(stream, state, haxeTokenComment);
|
|
62
|
+
} else if (stream.eat("/")) {
|
|
63
|
+
stream.skipToEnd();
|
|
64
|
+
return ret("comment", "comment");
|
|
65
|
+
} else {
|
|
66
|
+
stream.eatWhile(isOperatorChar);
|
|
67
|
+
return ret("operator", null, stream.current());
|
|
68
|
+
}
|
|
69
|
+
} else if (ch == "#") {
|
|
70
|
+
stream.skipToEnd();
|
|
71
|
+
return ret("conditional", "meta");
|
|
72
|
+
} else if (ch == "@") {
|
|
73
|
+
stream.eat(/:/);
|
|
74
|
+
stream.eatWhile(/[\w_]/);
|
|
75
|
+
return ret ("metadata", "meta");
|
|
76
|
+
} else if (isOperatorChar.test(ch)) {
|
|
77
|
+
stream.eatWhile(isOperatorChar);
|
|
78
|
+
return ret("operator", null, stream.current());
|
|
79
|
+
} else {
|
|
80
|
+
var word;
|
|
81
|
+
if(/[A-Z]/.test(ch)) {
|
|
82
|
+
stream.eatWhile(/[\w_<>]/);
|
|
83
|
+
word = stream.current();
|
|
84
|
+
return ret("type", "type", word);
|
|
85
|
+
} else {
|
|
86
|
+
stream.eatWhile(/[\w_]/);
|
|
87
|
+
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
|
|
88
|
+
return (known && state.kwAllowed) ? ret(known.type, known.style, word) :
|
|
89
|
+
ret("variable", "variable", word);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function haxeTokenString(quote) {
|
|
95
|
+
return function(stream, state) {
|
|
96
|
+
if (toUnescaped(stream, quote))
|
|
97
|
+
state.tokenize = haxeTokenBase;
|
|
98
|
+
return ret("string", "string");
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function haxeTokenComment(stream, state) {
|
|
103
|
+
var maybeEnd = false, ch;
|
|
104
|
+
while (ch = stream.next()) {
|
|
105
|
+
if (ch == "/" && maybeEnd) {
|
|
106
|
+
state.tokenize = haxeTokenBase;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
maybeEnd = (ch == "*");
|
|
110
|
+
}
|
|
111
|
+
return ret("comment", "comment");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Parser
|
|
115
|
+
|
|
116
|
+
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true};
|
|
117
|
+
|
|
118
|
+
function HaxeLexical(indented, column, type, align, prev, info) {
|
|
119
|
+
this.indented = indented;
|
|
120
|
+
this.column = column;
|
|
121
|
+
this.type = type;
|
|
122
|
+
this.prev = prev;
|
|
123
|
+
this.info = info;
|
|
124
|
+
if (align != null) this.align = align;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function inScope(state, varname) {
|
|
128
|
+
for (var v = state.localVars; v; v = v.next)
|
|
129
|
+
if (v.name == varname) return true;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function parseHaxe(state, style, type, content, stream) {
|
|
133
|
+
var cc = state.cc;
|
|
134
|
+
// Communicate our context to the combinators.
|
|
135
|
+
// (Less wasteful than consing up a hundred closures on every call.)
|
|
136
|
+
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
|
|
137
|
+
|
|
138
|
+
if (!state.lexical.hasOwnProperty("align"))
|
|
139
|
+
state.lexical.align = true;
|
|
140
|
+
|
|
141
|
+
while(true) {
|
|
142
|
+
var combinator = cc.length ? cc.pop() : statement;
|
|
143
|
+
if (combinator(type, content)) {
|
|
144
|
+
while(cc.length && cc[cc.length - 1].lex)
|
|
145
|
+
cc.pop()();
|
|
146
|
+
if (cx.marked) return cx.marked;
|
|
147
|
+
if (type == "variable" && inScope(state, content)) return "variableName.local";
|
|
148
|
+
if (type == "variable" && imported(state, content)) return "variableName.special";
|
|
149
|
+
return style;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function imported(state, typename) {
|
|
155
|
+
if (/[a-z]/.test(typename.charAt(0)))
|
|
156
|
+
return false;
|
|
157
|
+
var len = state.importedtypes.length;
|
|
158
|
+
for (var i = 0; i<len; i++)
|
|
159
|
+
if(state.importedtypes[i]==typename) return true;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function registerimport(importname) {
|
|
163
|
+
var state = cx.state;
|
|
164
|
+
for (var t = state.importedtypes; t; t = t.next)
|
|
165
|
+
if(t.name == importname) return;
|
|
166
|
+
state.importedtypes = { name: importname, next: state.importedtypes };
|
|
167
|
+
}
|
|
168
|
+
// Combinator utils
|
|
169
|
+
|
|
170
|
+
var cx = {state: null, column: null, marked: null, cc: null};
|
|
171
|
+
function pass() {
|
|
172
|
+
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
|
|
173
|
+
}
|
|
174
|
+
function cont() {
|
|
175
|
+
pass.apply(null, arguments);
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
function inList(name, list) {
|
|
179
|
+
for (var v = list; v; v = v.next)
|
|
180
|
+
if (v.name == name) return true;
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
function register(varname) {
|
|
184
|
+
var state = cx.state;
|
|
185
|
+
if (state.context) {
|
|
186
|
+
cx.marked = "def";
|
|
187
|
+
if (inList(varname, state.localVars)) return;
|
|
188
|
+
state.localVars = {name: varname, next: state.localVars};
|
|
189
|
+
} else if (state.globalVars) {
|
|
190
|
+
if (inList(varname, state.globalVars)) return;
|
|
191
|
+
state.globalVars = {name: varname, next: state.globalVars};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Combinators
|
|
196
|
+
|
|
197
|
+
var defaultVars = {name: "this", next: null};
|
|
198
|
+
function pushcontext() {
|
|
199
|
+
if (!cx.state.context) cx.state.localVars = defaultVars;
|
|
200
|
+
cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
|
|
201
|
+
}
|
|
202
|
+
function popcontext() {
|
|
203
|
+
cx.state.localVars = cx.state.context.vars;
|
|
204
|
+
cx.state.context = cx.state.context.prev;
|
|
205
|
+
}
|
|
206
|
+
popcontext.lex = true;
|
|
207
|
+
function pushlex(type, info) {
|
|
208
|
+
var result = function() {
|
|
209
|
+
var state = cx.state;
|
|
210
|
+
state.lexical = new HaxeLexical(state.indented, cx.stream.column(), type, null, state.lexical, info);
|
|
211
|
+
};
|
|
212
|
+
result.lex = true;
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
function poplex() {
|
|
216
|
+
var state = cx.state;
|
|
217
|
+
if (state.lexical.prev) {
|
|
218
|
+
if (state.lexical.type == ")")
|
|
219
|
+
state.indented = state.lexical.indented;
|
|
220
|
+
state.lexical = state.lexical.prev;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
poplex.lex = true;
|
|
224
|
+
|
|
225
|
+
function expect(wanted) {
|
|
226
|
+
function f(type) {
|
|
227
|
+
if (type == wanted) return cont();
|
|
228
|
+
else if (wanted == ";") return pass();
|
|
229
|
+
else return cont(f);
|
|
230
|
+
}
|
|
231
|
+
return f;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function statement(type) {
|
|
235
|
+
if (type == "@") return cont(metadef);
|
|
236
|
+
if (type == "var") return cont(pushlex("vardef"), vardef1, expect(";"), poplex);
|
|
237
|
+
if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
|
|
238
|
+
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
|
239
|
+
if (type == "{") return cont(pushlex("}"), pushcontext, block, poplex, popcontext);
|
|
240
|
+
if (type == ";") return cont();
|
|
241
|
+
if (type == "attribute") return cont(maybeattribute);
|
|
242
|
+
if (type == "function") return cont(functiondef);
|
|
243
|
+
if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
|
|
244
|
+
poplex, statement, poplex);
|
|
245
|
+
if (type == "variable") return cont(pushlex("stat"), maybelabel);
|
|
246
|
+
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
|
|
247
|
+
block, poplex, poplex);
|
|
248
|
+
if (type == "case") return cont(expression, expect(":"));
|
|
249
|
+
if (type == "default") return cont(expect(":"));
|
|
250
|
+
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
|
|
251
|
+
statement, poplex, popcontext);
|
|
252
|
+
if (type == "import") return cont(importdef, expect(";"));
|
|
253
|
+
if (type == "typedef") return cont(typedef);
|
|
254
|
+
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
|
255
|
+
}
|
|
256
|
+
function expression(type) {
|
|
257
|
+
if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);
|
|
258
|
+
if (type == "type" ) return cont(maybeoperator);
|
|
259
|
+
if (type == "function") return cont(functiondef);
|
|
260
|
+
if (type == "keyword c") return cont(maybeexpression);
|
|
261
|
+
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeoperator);
|
|
262
|
+
if (type == "operator") return cont(expression);
|
|
263
|
+
if (type == "[") return cont(pushlex("]"), commasep(maybeexpression, "]"), poplex, maybeoperator);
|
|
264
|
+
if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
|
|
265
|
+
return cont();
|
|
266
|
+
}
|
|
267
|
+
function maybeexpression(type) {
|
|
268
|
+
if (type.match(/[;\}\)\],]/)) return pass();
|
|
269
|
+
return pass(expression);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function maybeoperator(type, value) {
|
|
273
|
+
if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator);
|
|
274
|
+
if (type == "operator" || type == ":") return cont(expression);
|
|
275
|
+
if (type == ";") return;
|
|
276
|
+
if (type == "(") return cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);
|
|
277
|
+
if (type == ".") return cont(property, maybeoperator);
|
|
278
|
+
if (type == "[") return cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function maybeattribute(type) {
|
|
282
|
+
if (type == "attribute") return cont(maybeattribute);
|
|
283
|
+
if (type == "function") return cont(functiondef);
|
|
284
|
+
if (type == "var") return cont(vardef1);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function metadef(type) {
|
|
288
|
+
if(type == ":") return cont(metadef);
|
|
289
|
+
if(type == "variable") return cont(metadef);
|
|
290
|
+
if(type == "(") return cont(pushlex(")"), commasep(metaargs, ")"), poplex, statement);
|
|
291
|
+
}
|
|
292
|
+
function metaargs(type) {
|
|
293
|
+
if(type == "variable") return cont();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function importdef (type, value) {
|
|
297
|
+
if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
|
|
298
|
+
else if(type == "variable" || type == "property" || type == "." || value == "*") return cont(importdef);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function typedef (type, value)
|
|
302
|
+
{
|
|
303
|
+
if(type == "variable" && /[A-Z]/.test(value.charAt(0))) { registerimport(value); return cont(); }
|
|
304
|
+
else if (type == "type" && /[A-Z]/.test(value.charAt(0))) { return cont(); }
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function maybelabel(type) {
|
|
308
|
+
if (type == ":") return cont(poplex, statement);
|
|
309
|
+
return pass(maybeoperator, expect(";"), poplex);
|
|
310
|
+
}
|
|
311
|
+
function property(type) {
|
|
312
|
+
if (type == "variable") {cx.marked = "property"; return cont();}
|
|
313
|
+
}
|
|
314
|
+
function objprop(type) {
|
|
315
|
+
if (type == "variable") cx.marked = "property";
|
|
316
|
+
if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expression);
|
|
317
|
+
}
|
|
318
|
+
function commasep(what, end) {
|
|
319
|
+
function proceed(type) {
|
|
320
|
+
if (type == ",") return cont(what, proceed);
|
|
321
|
+
if (type == end) return cont();
|
|
322
|
+
return cont(expect(end));
|
|
323
|
+
}
|
|
324
|
+
return function(type) {
|
|
325
|
+
if (type == end) return cont();
|
|
326
|
+
else return pass(what, proceed);
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function block(type) {
|
|
330
|
+
if (type == "}") return cont();
|
|
331
|
+
return pass(statement, block);
|
|
332
|
+
}
|
|
333
|
+
function vardef1(type, value) {
|
|
334
|
+
if (type == "variable"){register(value); return cont(typeuse, vardef2);}
|
|
335
|
+
return cont();
|
|
336
|
+
}
|
|
337
|
+
function vardef2(type, value) {
|
|
338
|
+
if (value == "=") return cont(expression, vardef2);
|
|
339
|
+
if (type == ",") return cont(vardef1);
|
|
340
|
+
}
|
|
341
|
+
function forspec1(type, value) {
|
|
342
|
+
if (type == "variable") {
|
|
343
|
+
register(value);
|
|
344
|
+
return cont(forin, expression)
|
|
345
|
+
} else {
|
|
346
|
+
return pass()
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
function forin(_type, value) {
|
|
350
|
+
if (value == "in") return cont();
|
|
351
|
+
}
|
|
352
|
+
function functiondef(type, value) {
|
|
353
|
+
//function names starting with upper-case letters are recognised as types, so cludging them together here.
|
|
354
|
+
if (type == "variable" || type == "type") {register(value); return cont(functiondef);}
|
|
355
|
+
if (value == "new") return cont(functiondef);
|
|
356
|
+
if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, typeuse, statement, popcontext);
|
|
357
|
+
}
|
|
358
|
+
function typeuse(type) {
|
|
359
|
+
if(type == ":") return cont(typestring);
|
|
360
|
+
}
|
|
361
|
+
function typestring(type) {
|
|
362
|
+
if(type == "type") return cont();
|
|
363
|
+
if(type == "variable") return cont();
|
|
364
|
+
if(type == "{") return cont(pushlex("}"), commasep(typeprop, "}"), poplex);
|
|
365
|
+
}
|
|
366
|
+
function typeprop(type) {
|
|
367
|
+
if(type == "variable") return cont(typeuse);
|
|
368
|
+
}
|
|
369
|
+
function funarg(type, value) {
|
|
370
|
+
if (type == "variable") {register(value); return cont(typeuse);}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// Interface
|
|
374
|
+
export const haxe = {
|
|
375
|
+
name: "haxe",
|
|
376
|
+
startState: function(indentUnit) {
|
|
377
|
+
var defaulttypes = ["Int", "Float", "String", "Void", "Std", "Bool", "Dynamic", "Array"];
|
|
378
|
+
var state = {
|
|
379
|
+
tokenize: haxeTokenBase,
|
|
380
|
+
reAllowed: true,
|
|
381
|
+
kwAllowed: true,
|
|
382
|
+
cc: [],
|
|
383
|
+
lexical: new HaxeLexical(-indentUnit, 0, "block", false),
|
|
384
|
+
importedtypes: defaulttypes,
|
|
385
|
+
context: null,
|
|
386
|
+
indented: 0
|
|
387
|
+
};
|
|
388
|
+
return state;
|
|
389
|
+
},
|
|
390
|
+
|
|
391
|
+
token: function(stream, state) {
|
|
392
|
+
if (stream.sol()) {
|
|
393
|
+
if (!state.lexical.hasOwnProperty("align"))
|
|
394
|
+
state.lexical.align = false;
|
|
395
|
+
state.indented = stream.indentation();
|
|
396
|
+
}
|
|
397
|
+
if (stream.eatSpace()) return null;
|
|
398
|
+
var style = state.tokenize(stream, state);
|
|
399
|
+
if (type == "comment") return style;
|
|
400
|
+
state.reAllowed = !!(type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/));
|
|
401
|
+
state.kwAllowed = type != '.';
|
|
402
|
+
return parseHaxe(state, style, type, content, stream);
|
|
403
|
+
},
|
|
404
|
+
|
|
405
|
+
indent: function(state, textAfter, cx) {
|
|
406
|
+
if (state.tokenize != haxeTokenBase) return 0;
|
|
407
|
+
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
|
|
408
|
+
if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
|
|
409
|
+
var type = lexical.type, closing = firstChar == type;
|
|
410
|
+
if (type == "vardef") return lexical.indented + 4;
|
|
411
|
+
else if (type == "form" && firstChar == "{") return lexical.indented;
|
|
412
|
+
else if (type == "stat" || type == "form") return lexical.indented + cx.unit;
|
|
413
|
+
else if (lexical.info == "switch" && !closing)
|
|
414
|
+
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? cx.unit : 2 * cx.unit);
|
|
415
|
+
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
|
|
416
|
+
else return lexical.indented + (closing ? 0 : cx.unit);
|
|
417
|
+
},
|
|
418
|
+
|
|
419
|
+
languageData: {
|
|
420
|
+
indentOnInput: /^\s*[{}]$/,
|
|
421
|
+
commentTokens: {line: "//", block: {open: "/*", close: "*/"}}
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
export const hxml = {
|
|
426
|
+
name: "hxml",
|
|
427
|
+
startState: function () {
|
|
428
|
+
return {
|
|
429
|
+
define: false,
|
|
430
|
+
inString: false
|
|
431
|
+
};
|
|
432
|
+
},
|
|
433
|
+
token: function (stream, state) {
|
|
434
|
+
var ch = stream.peek();
|
|
435
|
+
var sol = stream.sol();
|
|
436
|
+
|
|
437
|
+
///* comments */
|
|
438
|
+
if (ch == "#") {
|
|
439
|
+
stream.skipToEnd();
|
|
440
|
+
return "comment";
|
|
441
|
+
}
|
|
442
|
+
if (sol && ch == "-") {
|
|
443
|
+
var style = "variable-2";
|
|
444
|
+
|
|
445
|
+
stream.eat(/-/);
|
|
446
|
+
|
|
447
|
+
if (stream.peek() == "-") {
|
|
448
|
+
stream.eat(/-/);
|
|
449
|
+
style = "keyword a";
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
if (stream.peek() == "D") {
|
|
453
|
+
stream.eat(/[D]/);
|
|
454
|
+
style = "keyword c";
|
|
455
|
+
state.define = true;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
stream.eatWhile(/[A-Z]/i);
|
|
459
|
+
return style;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
var ch = stream.peek();
|
|
463
|
+
|
|
464
|
+
if (state.inString == false && ch == "'") {
|
|
465
|
+
state.inString = true;
|
|
466
|
+
stream.next();
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (state.inString == true) {
|
|
470
|
+
if (stream.skipTo("'")) {
|
|
471
|
+
|
|
472
|
+
} else {
|
|
473
|
+
stream.skipToEnd();
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (stream.peek() == "'") {
|
|
477
|
+
stream.next();
|
|
478
|
+
state.inString = false;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
return "string";
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
stream.next();
|
|
485
|
+
return null;
|
|
486
|
+
},
|
|
487
|
+
languageData: {
|
|
488
|
+
commentTokens: {line: "#"}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
function failFirstLine(stream, state) {
|
|
2
|
+
stream.skipToEnd();
|
|
3
|
+
state.cur = header;
|
|
4
|
+
return "error";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function start(stream, state) {
|
|
8
|
+
if (stream.match(/^HTTP\/\d\.\d/)) {
|
|
9
|
+
state.cur = responseStatusCode;
|
|
10
|
+
return "keyword";
|
|
11
|
+
} else if (stream.match(/^[A-Z]+/) && /[ \t]/.test(stream.peek())) {
|
|
12
|
+
state.cur = requestPath;
|
|
13
|
+
return "keyword";
|
|
14
|
+
} else {
|
|
15
|
+
return failFirstLine(stream, state);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function responseStatusCode(stream, state) {
|
|
20
|
+
var code = stream.match(/^\d+/);
|
|
21
|
+
if (!code) return failFirstLine(stream, state);
|
|
22
|
+
|
|
23
|
+
state.cur = responseStatusText;
|
|
24
|
+
var status = Number(code[0]);
|
|
25
|
+
if (status >= 100 && status < 400) {
|
|
26
|
+
return "atom";
|
|
27
|
+
} else {
|
|
28
|
+
return "error";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function responseStatusText(stream, state) {
|
|
33
|
+
stream.skipToEnd();
|
|
34
|
+
state.cur = header;
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function requestPath(stream, state) {
|
|
39
|
+
stream.eatWhile(/\S/);
|
|
40
|
+
state.cur = requestProtocol;
|
|
41
|
+
return "string.special";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function requestProtocol(stream, state) {
|
|
45
|
+
if (stream.match(/^HTTP\/\d\.\d$/)) {
|
|
46
|
+
state.cur = header;
|
|
47
|
+
return "keyword";
|
|
48
|
+
} else {
|
|
49
|
+
return failFirstLine(stream, state);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function header(stream) {
|
|
54
|
+
if (stream.sol() && !stream.eat(/[ \t]/)) {
|
|
55
|
+
if (stream.match(/^.*?:/)) {
|
|
56
|
+
return "atom";
|
|
57
|
+
} else {
|
|
58
|
+
stream.skipToEnd();
|
|
59
|
+
return "error";
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
stream.skipToEnd();
|
|
63
|
+
return "string";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function body(stream) {
|
|
68
|
+
stream.skipToEnd();
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const http = {
|
|
73
|
+
name: "http",
|
|
74
|
+
token: function(stream, state) {
|
|
75
|
+
var cur = state.cur;
|
|
76
|
+
if (cur != header && cur != body && stream.eatSpace()) return null;
|
|
77
|
+
return cur(stream, state);
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
blankLine: function(state) {
|
|
81
|
+
state.cur = body;
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
startState: function() {
|
|
85
|
+
return {cur: start};
|
|
86
|
+
}
|
|
87
|
+
};
|