fluentd-ui 0.3.12 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd-ui might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/application.js +2 -0
- data/app/assets/javascripts/codemirror.js +29 -0
- data/app/assets/javascripts/codemirror_fluentd.js +59 -0
- data/app/assets/stylesheets/application.css +6 -0
- data/app/views/fluentd/settings/edit.html.haml +1 -1
- data/app/views/shared/vue/_setting.html.erb +1 -1
- data/bower.json +2 -1
- data/lib/fluentd-ui/version.rb +1 -1
- data/spec/features/source_and_output_spec.rb +16 -6
- data/vendor/assets/javascripts/bower/codemirror/.bower.json +29 -0
- data/vendor/assets/javascripts/bower/codemirror/AUTHORS +423 -0
- data/vendor/assets/javascripts/bower/codemirror/CONTRIBUTING.md +76 -0
- data/vendor/assets/javascripts/bower/codemirror/LICENSE +19 -0
- data/vendor/assets/javascripts/bower/codemirror/README.md +11 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/comment/comment.js +183 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/comment/continuecomment.js +85 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.js +155 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.css +6 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/panel.js +94 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/placeholder.js +58 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/rulers.js +64 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/closebrackets.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/closetag.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/continuelist.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchbrackets.js +120 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchtags.js +66 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/trailingspace.js +27 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/brace-fold.js +105 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/comment-fold.js +57 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldcode.js +145 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.css +20 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.js +134 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/indent-fold.js +44 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/markdown-fold.js +49 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/xml-fold.js +182 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/anyword-hint.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/css-hint.js +56 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/html-hint.js +348 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/javascript-hint.js +146 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.css +38 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.js +389 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/sql-hint.js +197 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/xml-hint.js +110 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/coffeescript-lint.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/css-lint.js +35 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/javascript-lint.js +136 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/json-lint.js +31 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.css +73 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.js +204 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/yaml-lint.js +28 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.css +112 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.js +643 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/loadmode.js +64 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex.js +118 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex_test.js +33 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/overlay.js +85 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/simple.js +213 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/colorize.js +40 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode-standalone.js +157 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.js +72 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.node.js +120 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/annotatescrollbar.js +76 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/scrollpastend.js +46 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.css +66 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/match-highlighter.js +128 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.css +8 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.js +90 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/search.js +164 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/searchcursor.js +189 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/selection/active-line.js +71 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/selection/mark-selection.js +118 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.css +86 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.js +670 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/worker.js +44 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/wrap/hardwrap.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/bower.json +16 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/emacs.js +411 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/sublime.js +540 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/vim.js +4901 -0
- data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.css +309 -0
- data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.js +8029 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/apl/apl.js +175 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/asterisk/asterisk.js +198 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clike/clike.js +489 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clike/scala.html +767 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clojure/clojure.js +243 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/cobol/cobol.js +255 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/coffeescript/coffeescript.js +369 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/commonlisp/commonlisp.js +122 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/css.js +717 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/less.html +152 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/less_test.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/scss.html +157 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/scss_test.js +110 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/test.js +135 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/cypher/cypher.js +146 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/d/d.js +218 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dart/dart.js +50 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/diff/diff.js +47 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/django/django.js +67 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dockerfile/dockerfile.js +76 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dtd/dtd.js +142 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dylan/dylan.js +299 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ebnf/ebnf.js +195 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ecl/ecl.js +207 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/eiffel/eiffel.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/erlang/erlang.js +622 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/fortran/fortran.js +188 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gas/gas.js +345 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gfm/gfm.js +123 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gfm/test.js +213 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gherkin/gherkin.js +178 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/go/go.js +184 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/groovy/groovy.js +226 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haml/haml.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haml/test.js +97 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haskell/haskell.js +267 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haxe/haxe.js +518 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/htmlembedded/htmlembedded.js +86 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/htmlmixed/htmlmixed.js +121 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/http/http.js +113 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/idl/idl.js +290 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/jade/jade.js +590 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/javascript.js +686 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/json-ld.html +72 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/test.js +200 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/typescript.html +61 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/jinja2/jinja2.js +142 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/julia/julia.js +301 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/kotlin/kotlin.js +280 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/livescript/livescript.js +280 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/lua/lua.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/markdown/markdown.js +765 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/markdown/test.js +754 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/meta.js +165 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/mirc/mirc.js +193 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/mllike/mllike.js +205 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/modelica/modelica.js +245 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/nginx/nginx.js +178 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ntriples/ntriples.js +186 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/octave/octave.js +135 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pascal/pascal.js +109 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pegjs/pegjs.js +114 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/perl/perl.js +832 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/php/php.js +226 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/php/test.js +154 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pig/pig.js +188 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/properties/properties.js +78 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/puppet/puppet.js +220 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/python/python.js +359 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/q/q.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/r/r.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rpm/rpm.js +101 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rst/rst.js +557 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ruby/ruby.js +285 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ruby/test.js +14 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rust/rust.js +451 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sass/sass.js +327 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/scheme/scheme.js +248 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/shell/shell.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/shell/test.js +58 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sieve/sieve.js +193 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/slim/slim.js +575 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/slim/test.js +96 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smalltalk/smalltalk.js +168 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smarty/smarty.js +221 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smartymixed/smartymixed.js +197 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/solr/solr.js +104 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/soy/soy.js +198 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sparql/sparql.js +174 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/spreadsheet/spreadsheet.js +109 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sql/sql.js +391 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/stex/stex.js +251 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/stex/test.js +123 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tcl/tcl.js +147 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/textile/test.js +417 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/textile/textile.js +469 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.js +369 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.css +26 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.js +323 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/toml/toml.js +88 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tornado/tornado.js +68 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/turtle/turtle.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/vb/vb.js +274 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/vbscript/vbscript.js +350 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/velocity/velocity.js +201 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/verilog/test.js +273 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/verilog/verilog.js +364 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xml/test.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xml/xml.js +384 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xquery/test.js +67 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xquery/xquery.js +447 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/yaml/yaml.js +117 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/z80/z80.js +100 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/3024-day.css +38 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/3024-night.css +37 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/ambiance-mobile.css +5 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/ambiance.css +77 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/base16-dark.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/base16-light.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/blackboard.css +30 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/cobalt.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/eclipse.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/elegant.css +13 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/erlang-dark.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/lesser-dark.css +45 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/mbo.css +35 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/mdn-like.css +44 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/midnight.css +45 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/monokai.css +31 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/neat.css +12 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/neo.css +43 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/night.css +26 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-dark.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-light.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/pastel-on-dark.css +50 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/rubyblue.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/solarized.css +165 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/the-matrix.css +28 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-bright.css +35 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-eighties.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/twilight.css +30 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/vibrant-ink.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/xq-dark.css +51 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/xq-light.css +43 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/zenburn.css +37 -0
- metadata +225 -2
@@ -0,0 +1,285 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../../lib/codemirror"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
CodeMirror.defineMode("ruby", function(config) {
|
15
|
+
function wordObj(words) {
|
16
|
+
var o = {};
|
17
|
+
for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;
|
18
|
+
return o;
|
19
|
+
}
|
20
|
+
var keywords = wordObj([
|
21
|
+
"alias", "and", "BEGIN", "begin", "break", "case", "class", "def", "defined?", "do", "else",
|
22
|
+
"elsif", "END", "end", "ensure", "false", "for", "if", "in", "module", "next", "not", "or",
|
23
|
+
"redo", "rescue", "retry", "return", "self", "super", "then", "true", "undef", "unless",
|
24
|
+
"until", "when", "while", "yield", "nil", "raise", "throw", "catch", "fail", "loop", "callcc",
|
25
|
+
"caller", "lambda", "proc", "public", "protected", "private", "require", "load",
|
26
|
+
"require_relative", "extend", "autoload", "__END__", "__FILE__", "__LINE__", "__dir__"
|
27
|
+
]);
|
28
|
+
var indentWords = wordObj(["def", "class", "case", "for", "while", "module", "then",
|
29
|
+
"catch", "loop", "proc", "begin"]);
|
30
|
+
var dedentWords = wordObj(["end", "until"]);
|
31
|
+
var matching = {"[": "]", "{": "}", "(": ")"};
|
32
|
+
var curPunc;
|
33
|
+
|
34
|
+
function chain(newtok, stream, state) {
|
35
|
+
state.tokenize.push(newtok);
|
36
|
+
return newtok(stream, state);
|
37
|
+
}
|
38
|
+
|
39
|
+
function tokenBase(stream, state) {
|
40
|
+
curPunc = null;
|
41
|
+
if (stream.sol() && stream.match("=begin") && stream.eol()) {
|
42
|
+
state.tokenize.push(readBlockComment);
|
43
|
+
return "comment";
|
44
|
+
}
|
45
|
+
if (stream.eatSpace()) return null;
|
46
|
+
var ch = stream.next(), m;
|
47
|
+
if (ch == "`" || ch == "'" || ch == '"') {
|
48
|
+
return chain(readQuoted(ch, "string", ch == '"' || ch == "`"), stream, state);
|
49
|
+
} else if (ch == "/") {
|
50
|
+
var currentIndex = stream.current().length;
|
51
|
+
if (stream.skipTo("/")) {
|
52
|
+
var search_till = stream.current().length;
|
53
|
+
stream.backUp(stream.current().length - currentIndex);
|
54
|
+
var balance = 0; // balance brackets
|
55
|
+
while (stream.current().length < search_till) {
|
56
|
+
var chchr = stream.next();
|
57
|
+
if (chchr == "(") balance += 1;
|
58
|
+
else if (chchr == ")") balance -= 1;
|
59
|
+
if (balance < 0) break;
|
60
|
+
}
|
61
|
+
stream.backUp(stream.current().length - currentIndex);
|
62
|
+
if (balance == 0)
|
63
|
+
return chain(readQuoted(ch, "string-2", true), stream, state);
|
64
|
+
}
|
65
|
+
return "operator";
|
66
|
+
} else if (ch == "%") {
|
67
|
+
var style = "string", embed = true;
|
68
|
+
if (stream.eat("s")) style = "atom";
|
69
|
+
else if (stream.eat(/[WQ]/)) style = "string";
|
70
|
+
else if (stream.eat(/[r]/)) style = "string-2";
|
71
|
+
else if (stream.eat(/[wxq]/)) { style = "string"; embed = false; }
|
72
|
+
var delim = stream.eat(/[^\w\s=]/);
|
73
|
+
if (!delim) return "operator";
|
74
|
+
if (matching.propertyIsEnumerable(delim)) delim = matching[delim];
|
75
|
+
return chain(readQuoted(delim, style, embed, true), stream, state);
|
76
|
+
} else if (ch == "#") {
|
77
|
+
stream.skipToEnd();
|
78
|
+
return "comment";
|
79
|
+
} else if (ch == "<" && (m = stream.match(/^<-?[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) {
|
80
|
+
return chain(readHereDoc(m[1]), stream, state);
|
81
|
+
} else if (ch == "0") {
|
82
|
+
if (stream.eat("x")) stream.eatWhile(/[\da-fA-F]/);
|
83
|
+
else if (stream.eat("b")) stream.eatWhile(/[01]/);
|
84
|
+
else stream.eatWhile(/[0-7]/);
|
85
|
+
return "number";
|
86
|
+
} else if (/\d/.test(ch)) {
|
87
|
+
stream.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/);
|
88
|
+
return "number";
|
89
|
+
} else if (ch == "?") {
|
90
|
+
while (stream.match(/^\\[CM]-/)) {}
|
91
|
+
if (stream.eat("\\")) stream.eatWhile(/\w/);
|
92
|
+
else stream.next();
|
93
|
+
return "string";
|
94
|
+
} else if (ch == ":") {
|
95
|
+
if (stream.eat("'")) return chain(readQuoted("'", "atom", false), stream, state);
|
96
|
+
if (stream.eat('"')) return chain(readQuoted('"', "atom", true), stream, state);
|
97
|
+
|
98
|
+
// :> :>> :< :<< are valid symbols
|
99
|
+
if (stream.eat(/[\<\>]/)) {
|
100
|
+
stream.eat(/[\<\>]/);
|
101
|
+
return "atom";
|
102
|
+
}
|
103
|
+
|
104
|
+
// :+ :- :/ :* :| :& :! are valid symbols
|
105
|
+
if (stream.eat(/[\+\-\*\/\&\|\:\!]/)) {
|
106
|
+
return "atom";
|
107
|
+
}
|
108
|
+
|
109
|
+
// Symbols can't start by a digit
|
110
|
+
if (stream.eat(/[a-zA-Z$@_\xa1-\uffff]/)) {
|
111
|
+
stream.eatWhile(/[\w$\xa1-\uffff]/);
|
112
|
+
// Only one ? ! = is allowed and only as the last character
|
113
|
+
stream.eat(/[\?\!\=]/);
|
114
|
+
return "atom";
|
115
|
+
}
|
116
|
+
return "operator";
|
117
|
+
} else if (ch == "@" && stream.match(/^@?[a-zA-Z_\xa1-\uffff]/)) {
|
118
|
+
stream.eat("@");
|
119
|
+
stream.eatWhile(/[\w\xa1-\uffff]/);
|
120
|
+
return "variable-2";
|
121
|
+
} else if (ch == "$") {
|
122
|
+
if (stream.eat(/[a-zA-Z_]/)) {
|
123
|
+
stream.eatWhile(/[\w]/);
|
124
|
+
} else if (stream.eat(/\d/)) {
|
125
|
+
stream.eat(/\d/);
|
126
|
+
} else {
|
127
|
+
stream.next(); // Must be a special global like $: or $!
|
128
|
+
}
|
129
|
+
return "variable-3";
|
130
|
+
} else if (/[a-zA-Z_\xa1-\uffff]/.test(ch)) {
|
131
|
+
stream.eatWhile(/[\w\xa1-\uffff]/);
|
132
|
+
stream.eat(/[\?\!]/);
|
133
|
+
if (stream.eat(":")) return "atom";
|
134
|
+
return "ident";
|
135
|
+
} else if (ch == "|" && (state.varList || state.lastTok == "{" || state.lastTok == "do")) {
|
136
|
+
curPunc = "|";
|
137
|
+
return null;
|
138
|
+
} else if (/[\(\)\[\]{}\\;]/.test(ch)) {
|
139
|
+
curPunc = ch;
|
140
|
+
return null;
|
141
|
+
} else if (ch == "-" && stream.eat(">")) {
|
142
|
+
return "arrow";
|
143
|
+
} else if (/[=+\-\/*:\.^%<>~|]/.test(ch)) {
|
144
|
+
var more = stream.eatWhile(/[=+\-\/*:\.^%<>~|]/);
|
145
|
+
if (ch == "." && !more) curPunc = ".";
|
146
|
+
return "operator";
|
147
|
+
} else {
|
148
|
+
return null;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
function tokenBaseUntilBrace(depth) {
|
153
|
+
if (!depth) depth = 1;
|
154
|
+
return function(stream, state) {
|
155
|
+
if (stream.peek() == "}") {
|
156
|
+
if (depth == 1) {
|
157
|
+
state.tokenize.pop();
|
158
|
+
return state.tokenize[state.tokenize.length-1](stream, state);
|
159
|
+
} else {
|
160
|
+
state.tokenize[state.tokenize.length - 1] = tokenBaseUntilBrace(depth - 1);
|
161
|
+
}
|
162
|
+
} else if (stream.peek() == "{") {
|
163
|
+
state.tokenize[state.tokenize.length - 1] = tokenBaseUntilBrace(depth + 1);
|
164
|
+
}
|
165
|
+
return tokenBase(stream, state);
|
166
|
+
};
|
167
|
+
}
|
168
|
+
function tokenBaseOnce() {
|
169
|
+
var alreadyCalled = false;
|
170
|
+
return function(stream, state) {
|
171
|
+
if (alreadyCalled) {
|
172
|
+
state.tokenize.pop();
|
173
|
+
return state.tokenize[state.tokenize.length-1](stream, state);
|
174
|
+
}
|
175
|
+
alreadyCalled = true;
|
176
|
+
return tokenBase(stream, state);
|
177
|
+
};
|
178
|
+
}
|
179
|
+
function readQuoted(quote, style, embed, unescaped) {
|
180
|
+
return function(stream, state) {
|
181
|
+
var escaped = false, ch;
|
182
|
+
|
183
|
+
if (state.context.type === 'read-quoted-paused') {
|
184
|
+
state.context = state.context.prev;
|
185
|
+
stream.eat("}");
|
186
|
+
}
|
187
|
+
|
188
|
+
while ((ch = stream.next()) != null) {
|
189
|
+
if (ch == quote && (unescaped || !escaped)) {
|
190
|
+
state.tokenize.pop();
|
191
|
+
break;
|
192
|
+
}
|
193
|
+
if (embed && ch == "#" && !escaped) {
|
194
|
+
if (stream.eat("{")) {
|
195
|
+
if (quote == "}") {
|
196
|
+
state.context = {prev: state.context, type: 'read-quoted-paused'};
|
197
|
+
}
|
198
|
+
state.tokenize.push(tokenBaseUntilBrace());
|
199
|
+
break;
|
200
|
+
} else if (/[@\$]/.test(stream.peek())) {
|
201
|
+
state.tokenize.push(tokenBaseOnce());
|
202
|
+
break;
|
203
|
+
}
|
204
|
+
}
|
205
|
+
escaped = !escaped && ch == "\\";
|
206
|
+
}
|
207
|
+
return style;
|
208
|
+
};
|
209
|
+
}
|
210
|
+
function readHereDoc(phrase) {
|
211
|
+
return function(stream, state) {
|
212
|
+
if (stream.match(phrase)) state.tokenize.pop();
|
213
|
+
else stream.skipToEnd();
|
214
|
+
return "string";
|
215
|
+
};
|
216
|
+
}
|
217
|
+
function readBlockComment(stream, state) {
|
218
|
+
if (stream.sol() && stream.match("=end") && stream.eol())
|
219
|
+
state.tokenize.pop();
|
220
|
+
stream.skipToEnd();
|
221
|
+
return "comment";
|
222
|
+
}
|
223
|
+
|
224
|
+
return {
|
225
|
+
startState: function() {
|
226
|
+
return {tokenize: [tokenBase],
|
227
|
+
indented: 0,
|
228
|
+
context: {type: "top", indented: -config.indentUnit},
|
229
|
+
continuedLine: false,
|
230
|
+
lastTok: null,
|
231
|
+
varList: false};
|
232
|
+
},
|
233
|
+
|
234
|
+
token: function(stream, state) {
|
235
|
+
if (stream.sol()) state.indented = stream.indentation();
|
236
|
+
var style = state.tokenize[state.tokenize.length-1](stream, state), kwtype;
|
237
|
+
var thisTok = curPunc;
|
238
|
+
if (style == "ident") {
|
239
|
+
var word = stream.current();
|
240
|
+
style = state.lastTok == "." ? "property"
|
241
|
+
: keywords.propertyIsEnumerable(stream.current()) ? "keyword"
|
242
|
+
: /^[A-Z]/.test(word) ? "tag"
|
243
|
+
: (state.lastTok == "def" || state.lastTok == "class" || state.varList) ? "def"
|
244
|
+
: "variable";
|
245
|
+
if (style == "keyword") {
|
246
|
+
thisTok = word;
|
247
|
+
if (indentWords.propertyIsEnumerable(word)) kwtype = "indent";
|
248
|
+
else if (dedentWords.propertyIsEnumerable(word)) kwtype = "dedent";
|
249
|
+
else if ((word == "if" || word == "unless") && stream.column() == stream.indentation())
|
250
|
+
kwtype = "indent";
|
251
|
+
else if (word == "do" && state.context.indented < state.indented)
|
252
|
+
kwtype = "indent";
|
253
|
+
}
|
254
|
+
}
|
255
|
+
if (curPunc || (style && style != "comment")) state.lastTok = thisTok;
|
256
|
+
if (curPunc == "|") state.varList = !state.varList;
|
257
|
+
|
258
|
+
if (kwtype == "indent" || /[\(\[\{]/.test(curPunc))
|
259
|
+
state.context = {prev: state.context, type: curPunc || style, indented: state.indented};
|
260
|
+
else if ((kwtype == "dedent" || /[\)\]\}]/.test(curPunc)) && state.context.prev)
|
261
|
+
state.context = state.context.prev;
|
262
|
+
|
263
|
+
if (stream.eol())
|
264
|
+
state.continuedLine = (curPunc == "\\" || style == "operator");
|
265
|
+
return style;
|
266
|
+
},
|
267
|
+
|
268
|
+
indent: function(state, textAfter) {
|
269
|
+
if (state.tokenize[state.tokenize.length-1] != tokenBase) return 0;
|
270
|
+
var firstChar = textAfter && textAfter.charAt(0);
|
271
|
+
var ct = state.context;
|
272
|
+
var closing = ct.type == matching[firstChar] ||
|
273
|
+
ct.type == "keyword" && /^(?:end|until|else|elsif|when|rescue)\b/.test(textAfter);
|
274
|
+
return ct.indented + (closing ? 0 : config.indentUnit) +
|
275
|
+
(state.continuedLine ? config.indentUnit : 0);
|
276
|
+
},
|
277
|
+
|
278
|
+
electricChars: "}de", // enD and rescuE
|
279
|
+
lineComment: "#"
|
280
|
+
};
|
281
|
+
});
|
282
|
+
|
283
|
+
CodeMirror.defineMIME("text/x-ruby", "ruby");
|
284
|
+
|
285
|
+
});
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function() {
|
5
|
+
var mode = CodeMirror.getMode({indentUnit: 2}, "ruby");
|
6
|
+
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
7
|
+
|
8
|
+
MT("divide_equal_operator",
|
9
|
+
"[variable bar] [operator /=] [variable foo]");
|
10
|
+
|
11
|
+
MT("divide_equal_operator_no_spacing",
|
12
|
+
"[variable foo][operator /=][number 42]");
|
13
|
+
|
14
|
+
})();
|
@@ -0,0 +1,451 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../../lib/codemirror"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
CodeMirror.defineMode("rust", function() {
|
15
|
+
var indentUnit = 4, altIndentUnit = 2;
|
16
|
+
var valKeywords = {
|
17
|
+
"if": "if-style", "while": "if-style", "loop": "else-style", "else": "else-style",
|
18
|
+
"do": "else-style", "ret": "else-style", "fail": "else-style",
|
19
|
+
"break": "atom", "cont": "atom", "const": "let", "resource": "fn",
|
20
|
+
"let": "let", "fn": "fn", "for": "for", "alt": "alt", "iface": "iface",
|
21
|
+
"impl": "impl", "type": "type", "enum": "enum", "mod": "mod",
|
22
|
+
"as": "op", "true": "atom", "false": "atom", "assert": "op", "check": "op",
|
23
|
+
"claim": "op", "native": "ignore", "unsafe": "ignore", "import": "else-style",
|
24
|
+
"export": "else-style", "copy": "op", "log": "op", "log_err": "op",
|
25
|
+
"use": "op", "bind": "op", "self": "atom", "struct": "enum"
|
26
|
+
};
|
27
|
+
var typeKeywords = function() {
|
28
|
+
var keywords = {"fn": "fn", "block": "fn", "obj": "obj"};
|
29
|
+
var atoms = "bool uint int i8 i16 i32 i64 u8 u16 u32 u64 float f32 f64 str char".split(" ");
|
30
|
+
for (var i = 0, e = atoms.length; i < e; ++i) keywords[atoms[i]] = "atom";
|
31
|
+
return keywords;
|
32
|
+
}();
|
33
|
+
var operatorChar = /[+\-*&%=<>!?|\.@]/;
|
34
|
+
|
35
|
+
// Tokenizer
|
36
|
+
|
37
|
+
// Used as scratch variable to communicate multiple values without
|
38
|
+
// consing up tons of objects.
|
39
|
+
var tcat, content;
|
40
|
+
function r(tc, style) {
|
41
|
+
tcat = tc;
|
42
|
+
return style;
|
43
|
+
}
|
44
|
+
|
45
|
+
function tokenBase(stream, state) {
|
46
|
+
var ch = stream.next();
|
47
|
+
if (ch == '"') {
|
48
|
+
state.tokenize = tokenString;
|
49
|
+
return state.tokenize(stream, state);
|
50
|
+
}
|
51
|
+
if (ch == "'") {
|
52
|
+
tcat = "atom";
|
53
|
+
if (stream.eat("\\")) {
|
54
|
+
if (stream.skipTo("'")) { stream.next(); return "string"; }
|
55
|
+
else { return "error"; }
|
56
|
+
} else {
|
57
|
+
stream.next();
|
58
|
+
return stream.eat("'") ? "string" : "error";
|
59
|
+
}
|
60
|
+
}
|
61
|
+
if (ch == "/") {
|
62
|
+
if (stream.eat("/")) { stream.skipToEnd(); return "comment"; }
|
63
|
+
if (stream.eat("*")) {
|
64
|
+
state.tokenize = tokenComment(1);
|
65
|
+
return state.tokenize(stream, state);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
if (ch == "#") {
|
69
|
+
if (stream.eat("[")) { tcat = "open-attr"; return null; }
|
70
|
+
stream.eatWhile(/\w/);
|
71
|
+
return r("macro", "meta");
|
72
|
+
}
|
73
|
+
if (ch == ":" && stream.match(":<")) {
|
74
|
+
return r("op", null);
|
75
|
+
}
|
76
|
+
if (ch.match(/\d/) || (ch == "." && stream.eat(/\d/))) {
|
77
|
+
var flp = false;
|
78
|
+
if (!stream.match(/^x[\da-f]+/i) && !stream.match(/^b[01]+/)) {
|
79
|
+
stream.eatWhile(/\d/);
|
80
|
+
if (stream.eat(".")) { flp = true; stream.eatWhile(/\d/); }
|
81
|
+
if (stream.match(/^e[+\-]?\d+/i)) { flp = true; }
|
82
|
+
}
|
83
|
+
if (flp) stream.match(/^f(?:32|64)/);
|
84
|
+
else stream.match(/^[ui](?:8|16|32|64)/);
|
85
|
+
return r("atom", "number");
|
86
|
+
}
|
87
|
+
if (ch.match(/[()\[\]{}:;,]/)) return r(ch, null);
|
88
|
+
if (ch == "-" && stream.eat(">")) return r("->", null);
|
89
|
+
if (ch.match(operatorChar)) {
|
90
|
+
stream.eatWhile(operatorChar);
|
91
|
+
return r("op", null);
|
92
|
+
}
|
93
|
+
stream.eatWhile(/\w/);
|
94
|
+
content = stream.current();
|
95
|
+
if (stream.match(/^::\w/)) {
|
96
|
+
stream.backUp(1);
|
97
|
+
return r("prefix", "variable-2");
|
98
|
+
}
|
99
|
+
if (state.keywords.propertyIsEnumerable(content))
|
100
|
+
return r(state.keywords[content], content.match(/true|false/) ? "atom" : "keyword");
|
101
|
+
return r("name", "variable");
|
102
|
+
}
|
103
|
+
|
104
|
+
function tokenString(stream, state) {
|
105
|
+
var ch, escaped = false;
|
106
|
+
while (ch = stream.next()) {
|
107
|
+
if (ch == '"' && !escaped) {
|
108
|
+
state.tokenize = tokenBase;
|
109
|
+
return r("atom", "string");
|
110
|
+
}
|
111
|
+
escaped = !escaped && ch == "\\";
|
112
|
+
}
|
113
|
+
// Hack to not confuse the parser when a string is split in
|
114
|
+
// pieces.
|
115
|
+
return r("op", "string");
|
116
|
+
}
|
117
|
+
|
118
|
+
function tokenComment(depth) {
|
119
|
+
return function(stream, state) {
|
120
|
+
var lastCh = null, ch;
|
121
|
+
while (ch = stream.next()) {
|
122
|
+
if (ch == "/" && lastCh == "*") {
|
123
|
+
if (depth == 1) {
|
124
|
+
state.tokenize = tokenBase;
|
125
|
+
break;
|
126
|
+
} else {
|
127
|
+
state.tokenize = tokenComment(depth - 1);
|
128
|
+
return state.tokenize(stream, state);
|
129
|
+
}
|
130
|
+
}
|
131
|
+
if (ch == "*" && lastCh == "/") {
|
132
|
+
state.tokenize = tokenComment(depth + 1);
|
133
|
+
return state.tokenize(stream, state);
|
134
|
+
}
|
135
|
+
lastCh = ch;
|
136
|
+
}
|
137
|
+
return "comment";
|
138
|
+
};
|
139
|
+
}
|
140
|
+
|
141
|
+
// Parser
|
142
|
+
|
143
|
+
var cx = {state: null, stream: null, marked: null, cc: null};
|
144
|
+
function pass() {
|
145
|
+
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
|
146
|
+
}
|
147
|
+
function cont() {
|
148
|
+
pass.apply(null, arguments);
|
149
|
+
return true;
|
150
|
+
}
|
151
|
+
|
152
|
+
function pushlex(type, info) {
|
153
|
+
var result = function() {
|
154
|
+
var state = cx.state;
|
155
|
+
state.lexical = {indented: state.indented, column: cx.stream.column(),
|
156
|
+
type: type, prev: state.lexical, info: info};
|
157
|
+
};
|
158
|
+
result.lex = true;
|
159
|
+
return result;
|
160
|
+
}
|
161
|
+
function poplex() {
|
162
|
+
var state = cx.state;
|
163
|
+
if (state.lexical.prev) {
|
164
|
+
if (state.lexical.type == ")")
|
165
|
+
state.indented = state.lexical.indented;
|
166
|
+
state.lexical = state.lexical.prev;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
function typecx() { cx.state.keywords = typeKeywords; }
|
170
|
+
function valcx() { cx.state.keywords = valKeywords; }
|
171
|
+
poplex.lex = typecx.lex = valcx.lex = true;
|
172
|
+
|
173
|
+
function commasep(comb, end) {
|
174
|
+
function more(type) {
|
175
|
+
if (type == ",") return cont(comb, more);
|
176
|
+
if (type == end) return cont();
|
177
|
+
return cont(more);
|
178
|
+
}
|
179
|
+
return function(type) {
|
180
|
+
if (type == end) return cont();
|
181
|
+
return pass(comb, more);
|
182
|
+
};
|
183
|
+
}
|
184
|
+
|
185
|
+
function stat_of(comb, tag) {
|
186
|
+
return cont(pushlex("stat", tag), comb, poplex, block);
|
187
|
+
}
|
188
|
+
function block(type) {
|
189
|
+
if (type == "}") return cont();
|
190
|
+
if (type == "let") return stat_of(letdef1, "let");
|
191
|
+
if (type == "fn") return stat_of(fndef);
|
192
|
+
if (type == "type") return cont(pushlex("stat"), tydef, endstatement, poplex, block);
|
193
|
+
if (type == "enum") return stat_of(enumdef);
|
194
|
+
if (type == "mod") return stat_of(mod);
|
195
|
+
if (type == "iface") return stat_of(iface);
|
196
|
+
if (type == "impl") return stat_of(impl);
|
197
|
+
if (type == "open-attr") return cont(pushlex("]"), commasep(expression, "]"), poplex);
|
198
|
+
if (type == "ignore" || type.match(/[\]\);,]/)) return cont(block);
|
199
|
+
return pass(pushlex("stat"), expression, poplex, endstatement, block);
|
200
|
+
}
|
201
|
+
function endstatement(type) {
|
202
|
+
if (type == ";") return cont();
|
203
|
+
return pass();
|
204
|
+
}
|
205
|
+
function expression(type) {
|
206
|
+
if (type == "atom" || type == "name") return cont(maybeop);
|
207
|
+
if (type == "{") return cont(pushlex("}"), exprbrace, poplex);
|
208
|
+
if (type.match(/[\[\(]/)) return matchBrackets(type, expression);
|
209
|
+
if (type.match(/[\]\)\};,]/)) return pass();
|
210
|
+
if (type == "if-style") return cont(expression, expression);
|
211
|
+
if (type == "else-style" || type == "op") return cont(expression);
|
212
|
+
if (type == "for") return cont(pattern, maybetype, inop, expression, expression);
|
213
|
+
if (type == "alt") return cont(expression, altbody);
|
214
|
+
if (type == "fn") return cont(fndef);
|
215
|
+
if (type == "macro") return cont(macro);
|
216
|
+
return cont();
|
217
|
+
}
|
218
|
+
function maybeop(type) {
|
219
|
+
if (content == ".") return cont(maybeprop);
|
220
|
+
if (content == "::<"){return cont(typarams, maybeop);}
|
221
|
+
if (type == "op" || content == ":") return cont(expression);
|
222
|
+
if (type == "(" || type == "[") return matchBrackets(type, expression);
|
223
|
+
return pass();
|
224
|
+
}
|
225
|
+
function maybeprop() {
|
226
|
+
if (content.match(/^\w+$/)) {cx.marked = "variable"; return cont(maybeop);}
|
227
|
+
return pass(expression);
|
228
|
+
}
|
229
|
+
function exprbrace(type) {
|
230
|
+
if (type == "op") {
|
231
|
+
if (content == "|") return cont(blockvars, poplex, pushlex("}", "block"), block);
|
232
|
+
if (content == "||") return cont(poplex, pushlex("}", "block"), block);
|
233
|
+
}
|
234
|
+
if (content == "mutable" || (content.match(/^\w+$/) && cx.stream.peek() == ":"
|
235
|
+
&& !cx.stream.match("::", false)))
|
236
|
+
return pass(record_of(expression));
|
237
|
+
return pass(block);
|
238
|
+
}
|
239
|
+
function record_of(comb) {
|
240
|
+
function ro(type) {
|
241
|
+
if (content == "mutable" || content == "with") {cx.marked = "keyword"; return cont(ro);}
|
242
|
+
if (content.match(/^\w*$/)) {cx.marked = "variable"; return cont(ro);}
|
243
|
+
if (type == ":") return cont(comb, ro);
|
244
|
+
if (type == "}") return cont();
|
245
|
+
return cont(ro);
|
246
|
+
}
|
247
|
+
return ro;
|
248
|
+
}
|
249
|
+
function blockvars(type) {
|
250
|
+
if (type == "name") {cx.marked = "def"; return cont(blockvars);}
|
251
|
+
if (type == "op" && content == "|") return cont();
|
252
|
+
return cont(blockvars);
|
253
|
+
}
|
254
|
+
|
255
|
+
function letdef1(type) {
|
256
|
+
if (type.match(/[\]\)\};]/)) return cont();
|
257
|
+
if (content == "=") return cont(expression, letdef2);
|
258
|
+
if (type == ",") return cont(letdef1);
|
259
|
+
return pass(pattern, maybetype, letdef1);
|
260
|
+
}
|
261
|
+
function letdef2(type) {
|
262
|
+
if (type.match(/[\]\)\};,]/)) return pass(letdef1);
|
263
|
+
else return pass(expression, letdef2);
|
264
|
+
}
|
265
|
+
function maybetype(type) {
|
266
|
+
if (type == ":") return cont(typecx, rtype, valcx);
|
267
|
+
return pass();
|
268
|
+
}
|
269
|
+
function inop(type) {
|
270
|
+
if (type == "name" && content == "in") {cx.marked = "keyword"; return cont();}
|
271
|
+
return pass();
|
272
|
+
}
|
273
|
+
function fndef(type) {
|
274
|
+
if (content == "@" || content == "~") {cx.marked = "keyword"; return cont(fndef);}
|
275
|
+
if (type == "name") {cx.marked = "def"; return cont(fndef);}
|
276
|
+
if (content == "<") return cont(typarams, fndef);
|
277
|
+
if (type == "{") return pass(expression);
|
278
|
+
if (type == "(") return cont(pushlex(")"), commasep(argdef, ")"), poplex, fndef);
|
279
|
+
if (type == "->") return cont(typecx, rtype, valcx, fndef);
|
280
|
+
if (type == ";") return cont();
|
281
|
+
return cont(fndef);
|
282
|
+
}
|
283
|
+
function tydef(type) {
|
284
|
+
if (type == "name") {cx.marked = "def"; return cont(tydef);}
|
285
|
+
if (content == "<") return cont(typarams, tydef);
|
286
|
+
if (content == "=") return cont(typecx, rtype, valcx);
|
287
|
+
return cont(tydef);
|
288
|
+
}
|
289
|
+
function enumdef(type) {
|
290
|
+
if (type == "name") {cx.marked = "def"; return cont(enumdef);}
|
291
|
+
if (content == "<") return cont(typarams, enumdef);
|
292
|
+
if (content == "=") return cont(typecx, rtype, valcx, endstatement);
|
293
|
+
if (type == "{") return cont(pushlex("}"), typecx, enumblock, valcx, poplex);
|
294
|
+
return cont(enumdef);
|
295
|
+
}
|
296
|
+
function enumblock(type) {
|
297
|
+
if (type == "}") return cont();
|
298
|
+
if (type == "(") return cont(pushlex(")"), commasep(rtype, ")"), poplex, enumblock);
|
299
|
+
if (content.match(/^\w+$/)) cx.marked = "def";
|
300
|
+
return cont(enumblock);
|
301
|
+
}
|
302
|
+
function mod(type) {
|
303
|
+
if (type == "name") {cx.marked = "def"; return cont(mod);}
|
304
|
+
if (type == "{") return cont(pushlex("}"), block, poplex);
|
305
|
+
return pass();
|
306
|
+
}
|
307
|
+
function iface(type) {
|
308
|
+
if (type == "name") {cx.marked = "def"; return cont(iface);}
|
309
|
+
if (content == "<") return cont(typarams, iface);
|
310
|
+
if (type == "{") return cont(pushlex("}"), block, poplex);
|
311
|
+
return pass();
|
312
|
+
}
|
313
|
+
function impl(type) {
|
314
|
+
if (content == "<") return cont(typarams, impl);
|
315
|
+
if (content == "of" || content == "for") {cx.marked = "keyword"; return cont(rtype, impl);}
|
316
|
+
if (type == "name") {cx.marked = "def"; return cont(impl);}
|
317
|
+
if (type == "{") return cont(pushlex("}"), block, poplex);
|
318
|
+
return pass();
|
319
|
+
}
|
320
|
+
function typarams() {
|
321
|
+
if (content == ">") return cont();
|
322
|
+
if (content == ",") return cont(typarams);
|
323
|
+
if (content == ":") return cont(rtype, typarams);
|
324
|
+
return pass(rtype, typarams);
|
325
|
+
}
|
326
|
+
function argdef(type) {
|
327
|
+
if (type == "name") {cx.marked = "def"; return cont(argdef);}
|
328
|
+
if (type == ":") return cont(typecx, rtype, valcx);
|
329
|
+
return pass();
|
330
|
+
}
|
331
|
+
function rtype(type) {
|
332
|
+
if (type == "name") {cx.marked = "variable-3"; return cont(rtypemaybeparam); }
|
333
|
+
if (content == "mutable") {cx.marked = "keyword"; return cont(rtype);}
|
334
|
+
if (type == "atom") return cont(rtypemaybeparam);
|
335
|
+
if (type == "op" || type == "obj") return cont(rtype);
|
336
|
+
if (type == "fn") return cont(fntype);
|
337
|
+
if (type == "{") return cont(pushlex("{"), record_of(rtype), poplex);
|
338
|
+
return matchBrackets(type, rtype);
|
339
|
+
}
|
340
|
+
function rtypemaybeparam() {
|
341
|
+
if (content == "<") return cont(typarams);
|
342
|
+
return pass();
|
343
|
+
}
|
344
|
+
function fntype(type) {
|
345
|
+
if (type == "(") return cont(pushlex("("), commasep(rtype, ")"), poplex, fntype);
|
346
|
+
if (type == "->") return cont(rtype);
|
347
|
+
return pass();
|
348
|
+
}
|
349
|
+
function pattern(type) {
|
350
|
+
if (type == "name") {cx.marked = "def"; return cont(patternmaybeop);}
|
351
|
+
if (type == "atom") return cont(patternmaybeop);
|
352
|
+
if (type == "op") return cont(pattern);
|
353
|
+
if (type.match(/[\]\)\};,]/)) return pass();
|
354
|
+
return matchBrackets(type, pattern);
|
355
|
+
}
|
356
|
+
function patternmaybeop(type) {
|
357
|
+
if (type == "op" && content == ".") return cont();
|
358
|
+
if (content == "to") {cx.marked = "keyword"; return cont(pattern);}
|
359
|
+
else return pass();
|
360
|
+
}
|
361
|
+
function altbody(type) {
|
362
|
+
if (type == "{") return cont(pushlex("}", "alt"), altblock1, poplex);
|
363
|
+
return pass();
|
364
|
+
}
|
365
|
+
function altblock1(type) {
|
366
|
+
if (type == "}") return cont();
|
367
|
+
if (type == "|") return cont(altblock1);
|
368
|
+
if (content == "when") {cx.marked = "keyword"; return cont(expression, altblock2);}
|
369
|
+
if (type.match(/[\]\);,]/)) return cont(altblock1);
|
370
|
+
return pass(pattern, altblock2);
|
371
|
+
}
|
372
|
+
function altblock2(type) {
|
373
|
+
if (type == "{") return cont(pushlex("}", "alt"), block, poplex, altblock1);
|
374
|
+
else return pass(altblock1);
|
375
|
+
}
|
376
|
+
|
377
|
+
function macro(type) {
|
378
|
+
if (type.match(/[\[\(\{]/)) return matchBrackets(type, expression);
|
379
|
+
return pass();
|
380
|
+
}
|
381
|
+
function matchBrackets(type, comb) {
|
382
|
+
if (type == "[") return cont(pushlex("]"), commasep(comb, "]"), poplex);
|
383
|
+
if (type == "(") return cont(pushlex(")"), commasep(comb, ")"), poplex);
|
384
|
+
if (type == "{") return cont(pushlex("}"), commasep(comb, "}"), poplex);
|
385
|
+
return cont();
|
386
|
+
}
|
387
|
+
|
388
|
+
function parse(state, stream, style) {
|
389
|
+
var cc = state.cc;
|
390
|
+
// Communicate our context to the combinators.
|
391
|
+
// (Less wasteful than consing up a hundred closures on every call.)
|
392
|
+
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
|
393
|
+
|
394
|
+
while (true) {
|
395
|
+
var combinator = cc.length ? cc.pop() : block;
|
396
|
+
if (combinator(tcat)) {
|
397
|
+
while(cc.length && cc[cc.length - 1].lex)
|
398
|
+
cc.pop()();
|
399
|
+
return cx.marked || style;
|
400
|
+
}
|
401
|
+
}
|
402
|
+
}
|
403
|
+
|
404
|
+
return {
|
405
|
+
startState: function() {
|
406
|
+
return {
|
407
|
+
tokenize: tokenBase,
|
408
|
+
cc: [],
|
409
|
+
lexical: {indented: -indentUnit, column: 0, type: "top", align: false},
|
410
|
+
keywords: valKeywords,
|
411
|
+
indented: 0
|
412
|
+
};
|
413
|
+
},
|
414
|
+
|
415
|
+
token: function(stream, state) {
|
416
|
+
if (stream.sol()) {
|
417
|
+
if (!state.lexical.hasOwnProperty("align"))
|
418
|
+
state.lexical.align = false;
|
419
|
+
state.indented = stream.indentation();
|
420
|
+
}
|
421
|
+
if (stream.eatSpace()) return null;
|
422
|
+
tcat = content = null;
|
423
|
+
var style = state.tokenize(stream, state);
|
424
|
+
if (style == "comment") return style;
|
425
|
+
if (!state.lexical.hasOwnProperty("align"))
|
426
|
+
state.lexical.align = true;
|
427
|
+
if (tcat == "prefix") return style;
|
428
|
+
if (!content) content = stream.current();
|
429
|
+
return parse(state, stream, style);
|
430
|
+
},
|
431
|
+
|
432
|
+
indent: function(state, textAfter) {
|
433
|
+
if (state.tokenize != tokenBase) return 0;
|
434
|
+
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical,
|
435
|
+
type = lexical.type, closing = firstChar == type;
|
436
|
+
if (type == "stat") return lexical.indented + indentUnit;
|
437
|
+
if (lexical.align) return lexical.column + (closing ? 0 : 1);
|
438
|
+
return lexical.indented + (closing ? 0 : (lexical.info == "alt" ? altIndentUnit : indentUnit));
|
439
|
+
},
|
440
|
+
|
441
|
+
electricChars: "{}",
|
442
|
+
blockCommentStart: "/*",
|
443
|
+
blockCommentEnd: "*/",
|
444
|
+
lineComment: "//",
|
445
|
+
fold: "brace"
|
446
|
+
};
|
447
|
+
});
|
448
|
+
|
449
|
+
CodeMirror.defineMIME("text/x-rustsrc", "rust");
|
450
|
+
|
451
|
+
});
|