marty 2.4.7 → 2.4.8

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.
Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile.dummy +8 -5
  3. data/Gemfile.lock +1 -1
  4. data/README.md +8 -0
  5. data/app/assets/javascripts/marty/application.js +1 -0
  6. data/app/assets/javascripts/marty/codemirror/codemirror.js +9730 -0
  7. data/app/{components/marty/script_form/client → assets/javascripts/marty/codemirror}/mode/delorean/delorean.js +0 -0
  8. data/app/assets/javascripts/marty/codemirror/mode/javascript/javascript.js +900 -0
  9. data/app/assets/javascripts/marty/codemirror/mode/python/python.js +399 -0
  10. data/app/{components/marty/script_form/client → assets/javascripts/marty/codemirror}/mode/ruby/ruby.js +135 -34
  11. data/app/{components/marty/script_form/client/Ext.ux.form.field.CodeMirror.js → assets/javascripts/marty/extjs/extensions/marty.js} +87 -6
  12. data/app/assets/stylesheets/marty/application.css +1 -13
  13. data/app/assets/stylesheets/marty/codemirror/codemirror.css +346 -0
  14. data/app/{components/marty/script_form/client → assets/stylesheets/marty/codemirror}/delorean.css +0 -0
  15. data/app/components/marty/auth_app/client/auth_app.js +82 -80
  16. data/app/components/marty/data_grid_view.rb +1 -54
  17. data/app/components/marty/data_grid_view/client/data_grid_view.js +49 -0
  18. data/app/components/marty/form.rb +1 -5
  19. data/app/components/marty/form/client/form.js +5 -0
  20. data/app/components/marty/grid.rb +1 -146
  21. data/app/components/marty/grid/client/grid.js +146 -0
  22. data/app/components/marty/import_view.rb +1 -32
  23. data/app/components/marty/import_view/client/import_view.js +32 -0
  24. data/app/components/marty/live_search_grid_panel.rb +1 -21
  25. data/app/components/marty/live_search_grid_panel/client/live_search_grid_panel.js +27 -0
  26. data/app/components/marty/main_auth_app.rb +4 -145
  27. data/app/components/marty/main_auth_app/client/main_auth_app.js +124 -0
  28. data/app/components/marty/mcfly_grid_panel.rb +1 -17
  29. data/app/components/marty/mcfly_grid_panel/client/mcfly_grid_panel.js +37 -0
  30. data/app/components/marty/new_posting_form.rb +1 -6
  31. data/app/components/marty/new_posting_form/client/new_posting_form.js +6 -0
  32. data/app/components/marty/panel.rb +1 -5
  33. data/app/components/marty/panel/client/panel.js +5 -0
  34. data/app/components/marty/posting_grid.rb +4 -55
  35. data/app/components/marty/posting_grid/client/posting_grid.js +50 -0
  36. data/app/components/marty/promise_view.rb +2 -75
  37. data/app/components/marty/promise_view/client/promise_view.css +12 -9
  38. data/app/components/marty/promise_view/client/promise_view.js +57 -0
  39. data/app/components/marty/report_form.rb +3 -69
  40. data/app/components/marty/report_form/client/report_form.js +78 -0
  41. data/app/components/marty/report_select.rb +1 -45
  42. data/app/components/marty/report_select/client/report_select.js +50 -0
  43. data/app/components/marty/reporting.rb +1 -8
  44. data/app/components/marty/reporting/client/reporting.js +8 -0
  45. data/app/components/marty/script_form.rb +2 -63
  46. data/app/components/marty/script_form/client/script_form.js +44 -0
  47. data/app/components/marty/script_tester.rb +1 -7
  48. data/app/components/marty/script_tester/client/script_tester.js +7 -0
  49. data/app/components/marty/scripting.rb +1 -55
  50. data/app/components/marty/scripting/client/scripting.js +62 -0
  51. data/app/components/marty/simple_app/client/simple_app.js +21 -13
  52. data/app/models/marty/promise.rb +22 -1
  53. data/app/views/layouts/marty/application.html.erb +8 -6
  54. data/docker-compose.dummy.yml +2 -0
  55. data/lib/marty/monkey.rb +0 -16
  56. data/lib/marty/version.rb +1 -1
  57. data/spec/dummy/config/initializers/assets.rb +1 -0
  58. data/spec/features/reporting_spec.rb +1 -0
  59. data/spec/features/scripting_spec.rb +4 -4
  60. data/spec/spec_helper.rb +1 -0
  61. data/spec/support/chromedriver.rb +5 -1
  62. data/spec/support/shared_connection_db_helpers.rb +42 -2
  63. metadata +29 -168
  64. data/app/assets/images/marty/.gitkeep +0 -0
  65. data/app/components/marty/mcfly_grid_panel/client/dup_in_form.js +0 -20
  66. data/app/components/marty/script_form/client/codemirror.css +0 -172
  67. data/app/components/marty/script_form/client/codemirror.js +0 -3130
  68. data/app/components/marty/script_form/client/mode/clike/clike.js +0 -284
  69. data/app/components/marty/script_form/client/mode/clike/index.html +0 -102
  70. data/app/components/marty/script_form/client/mode/clike/scala.html +0 -766
  71. data/app/components/marty/script_form/client/mode/clojure/clojure.js +0 -206
  72. data/app/components/marty/script_form/client/mode/clojure/index.html +0 -67
  73. data/app/components/marty/script_form/client/mode/coffeescript/LICENSE +0 -22
  74. data/app/components/marty/script_form/client/mode/coffeescript/coffeescript.js +0 -346
  75. data/app/components/marty/script_form/client/mode/coffeescript/index.html +0 -728
  76. data/app/components/marty/script_form/client/mode/commonlisp/commonlisp.js +0 -101
  77. data/app/components/marty/script_form/client/mode/commonlisp/index.html +0 -165
  78. data/app/components/marty/script_form/client/mode/css/css.js +0 -448
  79. data/app/components/marty/script_form/client/mode/css/index.html +0 -58
  80. data/app/components/marty/script_form/client/mode/css/test.js +0 -501
  81. data/app/components/marty/script_form/client/mode/diff/diff.js +0 -32
  82. data/app/components/marty/script_form/client/mode/diff/index.html +0 -105
  83. data/app/components/marty/script_form/client/mode/ecl/ecl.js +0 -203
  84. data/app/components/marty/script_form/client/mode/ecl/index.html +0 -42
  85. data/app/components/marty/script_form/client/mode/erlang/erlang.js +0 -463
  86. data/app/components/marty/script_form/client/mode/erlang/index.html +0 -63
  87. data/app/components/marty/script_form/client/mode/gfm/gfm.js +0 -150
  88. data/app/components/marty/script_form/client/mode/gfm/index.html +0 -48
  89. data/app/components/marty/script_form/client/mode/go/go.js +0 -170
  90. data/app/components/marty/script_form/client/mode/go/index.html +0 -73
  91. data/app/components/marty/script_form/client/mode/groovy/groovy.js +0 -210
  92. data/app/components/marty/script_form/client/mode/groovy/index.html +0 -72
  93. data/app/components/marty/script_form/client/mode/haskell/haskell.js +0 -242
  94. data/app/components/marty/script_form/client/mode/haskell/index.html +0 -61
  95. data/app/components/marty/script_form/client/mode/haxe/haxe.js +0 -429
  96. data/app/components/marty/script_form/client/mode/haxe/index.html +0 -91
  97. data/app/components/marty/script_form/client/mode/htmlembedded/htmlembedded.js +0 -72
  98. data/app/components/marty/script_form/client/mode/htmlembedded/index.html +0 -50
  99. data/app/components/marty/script_form/client/mode/htmlmixed/htmlmixed.js +0 -84
  100. data/app/components/marty/script_form/client/mode/htmlmixed/index.html +0 -52
  101. data/app/components/marty/script_form/client/mode/javascript/index.html +0 -78
  102. data/app/components/marty/script_form/client/mode/javascript/javascript.js +0 -361
  103. data/app/components/marty/script_form/client/mode/jinja2/index.html +0 -38
  104. data/app/components/marty/script_form/client/mode/jinja2/jinja2.js +0 -42
  105. data/app/components/marty/script_form/client/mode/less/index.html +0 -740
  106. data/app/components/marty/script_form/client/mode/less/less.js +0 -266
  107. data/app/components/marty/script_form/client/mode/lua/index.html +0 -73
  108. data/app/components/marty/script_form/client/mode/lua/lua.js +0 -140
  109. data/app/components/marty/script_form/client/mode/markdown/index.html +0 -343
  110. data/app/components/marty/script_form/client/mode/markdown/markdown.js +0 -382
  111. data/app/components/marty/script_form/client/mode/markdown/test.js +0 -1084
  112. data/app/components/marty/script_form/client/mode/mysql/index.html +0 -42
  113. data/app/components/marty/script_form/client/mode/mysql/mysql.js +0 -186
  114. data/app/components/marty/script_form/client/mode/ntriples/index.html +0 -33
  115. data/app/components/marty/script_form/client/mode/ntriples/ntriples.js +0 -172
  116. data/app/components/marty/script_form/client/mode/ocaml/index.html +0 -130
  117. data/app/components/marty/script_form/client/mode/ocaml/ocaml.js +0 -114
  118. data/app/components/marty/script_form/client/mode/pascal/LICENSE +0 -7
  119. data/app/components/marty/script_form/client/mode/pascal/index.html +0 -49
  120. data/app/components/marty/script_form/client/mode/pascal/pascal.js +0 -94
  121. data/app/components/marty/script_form/client/mode/perl/LICENSE +0 -19
  122. data/app/components/marty/script_form/client/mode/perl/index.html +0 -63
  123. data/app/components/marty/script_form/client/mode/perl/perl.js +0 -816
  124. data/app/components/marty/script_form/client/mode/php/index.html +0 -49
  125. data/app/components/marty/script_form/client/mode/php/php.js +0 -148
  126. data/app/components/marty/script_form/client/mode/pig/index.html +0 -43
  127. data/app/components/marty/script_form/client/mode/pig/pig.js +0 -172
  128. data/app/components/marty/script_form/client/mode/plsql/index.html +0 -63
  129. data/app/components/marty/script_form/client/mode/plsql/plsql.js +0 -217
  130. data/app/components/marty/script_form/client/mode/properties/index.html +0 -41
  131. data/app/components/marty/script_form/client/mode/properties/properties.js +0 -63
  132. data/app/components/marty/script_form/client/mode/python/LICENSE.txt +0 -21
  133. data/app/components/marty/script_form/client/mode/python/index.html +0 -123
  134. data/app/components/marty/script_form/client/mode/python/python.js +0 -338
  135. data/app/components/marty/script_form/client/mode/r/LICENSE +0 -24
  136. data/app/components/marty/script_form/client/mode/r/index.html +0 -74
  137. data/app/components/marty/script_form/client/mode/r/r.js +0 -141
  138. data/app/components/marty/script_form/client/mode/rpm/changes/changes.js +0 -19
  139. data/app/components/marty/script_form/client/mode/rpm/changes/index.html +0 -54
  140. data/app/components/marty/script_form/client/mode/rpm/spec/index.html +0 -100
  141. data/app/components/marty/script_form/client/mode/rpm/spec/spec.css +0 -5
  142. data/app/components/marty/script_form/client/mode/rpm/spec/spec.js +0 -66
  143. data/app/components/marty/script_form/client/mode/rst/index.html +0 -526
  144. data/app/components/marty/script_form/client/mode/rst/rst.js +0 -326
  145. data/app/components/marty/script_form/client/mode/ruby/LICENSE +0 -24
  146. data/app/components/marty/script_form/client/mode/ruby/index.html +0 -172
  147. data/app/components/marty/script_form/client/mode/rust/index.html +0 -49
  148. data/app/components/marty/script_form/client/mode/rust/rust.js +0 -432
  149. data/app/components/marty/script_form/client/mode/scheme/index.html +0 -65
  150. data/app/components/marty/script_form/client/mode/scheme/scheme.js +0 -230
  151. data/app/components/marty/script_form/client/mode/shell/index.html +0 -50
  152. data/app/components/marty/script_form/client/mode/shell/shell.js +0 -118
  153. data/app/components/marty/script_form/client/mode/sieve/LICENSE +0 -23
  154. data/app/components/marty/script_form/client/mode/sieve/index.html +0 -81
  155. data/app/components/marty/script_form/client/mode/sieve/sieve.js +0 -156
  156. data/app/components/marty/script_form/client/mode/smalltalk/index.html +0 -56
  157. data/app/components/marty/script_form/client/mode/smalltalk/smalltalk.js +0 -139
  158. data/app/components/marty/script_form/client/mode/smarty/index.html +0 -83
  159. data/app/components/marty/script_form/client/mode/smarty/smarty.js +0 -148
  160. data/app/components/marty/script_form/client/mode/sparql/index.html +0 -41
  161. data/app/components/marty/script_form/client/mode/sparql/sparql.js +0 -143
  162. data/app/components/marty/script_form/client/mode/stex/index.html +0 -98
  163. data/app/components/marty/script_form/client/mode/stex/stex.js +0 -182
  164. data/app/components/marty/script_form/client/mode/stex/test.js +0 -343
  165. data/app/components/marty/script_form/client/mode/tiddlywiki/index.html +0 -141
  166. data/app/components/marty/script_form/client/mode/tiddlywiki/tiddlywiki.css +0 -14
  167. data/app/components/marty/script_form/client/mode/tiddlywiki/tiddlywiki.js +0 -384
  168. data/app/components/marty/script_form/client/mode/tiki/index.html +0 -83
  169. data/app/components/marty/script_form/client/mode/tiki/tiki.css +0 -26
  170. data/app/components/marty/script_form/client/mode/tiki/tiki.js +0 -309
  171. data/app/components/marty/script_form/client/mode/vb/LICENSE.txt +0 -21
  172. data/app/components/marty/script_form/client/mode/vb/index.html +0 -89
  173. data/app/components/marty/script_form/client/mode/vb/vb.js +0 -260
  174. data/app/components/marty/script_form/client/mode/vbscript/index.html +0 -43
  175. data/app/components/marty/script_form/client/mode/vbscript/vbscript.js +0 -26
  176. data/app/components/marty/script_form/client/mode/velocity/index.html +0 -104
  177. data/app/components/marty/script_form/client/mode/velocity/velocity.js +0 -146
  178. data/app/components/marty/script_form/client/mode/verilog/index.html +0 -211
  179. data/app/components/marty/script_form/client/mode/verilog/verilog.js +0 -194
  180. data/app/components/marty/script_form/client/mode/xml/index.html +0 -45
  181. data/app/components/marty/script_form/client/mode/xml/xml.js +0 -318
  182. data/app/components/marty/script_form/client/mode/xquery/LICENSE +0 -20
  183. data/app/components/marty/script_form/client/mode/xquery/index.html +0 -223
  184. data/app/components/marty/script_form/client/mode/xquery/test/index.html +0 -27
  185. data/app/components/marty/script_form/client/mode/xquery/test/testBase.js +0 -42
  186. data/app/components/marty/script_form/client/mode/xquery/test/testEmptySequenceKeyword.js +0 -16
  187. data/app/components/marty/script_form/client/mode/xquery/test/testMultiAttr.js +0 -16
  188. data/app/components/marty/script_form/client/mode/xquery/test/testNamespaces.js +0 -91
  189. data/app/components/marty/script_form/client/mode/xquery/test/testProcessingInstructions.js +0 -16
  190. data/app/components/marty/script_form/client/mode/xquery/test/testQuotes.js +0 -19
  191. data/app/components/marty/script_form/client/mode/xquery/xquery.js +0 -451
  192. data/app/components/marty/script_form/client/mode/yaml/index.html +0 -68
  193. data/app/components/marty/script_form/client/mode/yaml/yaml.js +0 -95
  194. data/app/components/marty/script_form/client/theme/ambiance.css +0 -81
  195. data/app/components/marty/script_form/client/theme/blackboard.css +0 -25
  196. data/app/components/marty/script_form/client/theme/cobalt.css +0 -18
  197. data/app/components/marty/script_form/client/theme/eclipse.css +0 -25
  198. data/app/components/marty/script_form/client/theme/elegant.css +0 -10
  199. data/app/components/marty/script_form/client/theme/erlang-dark.css +0 -21
  200. data/app/components/marty/script_form/client/theme/lesser-dark.css +0 -44
  201. data/app/components/marty/script_form/client/theme/monokai.css +0 -28
  202. data/app/components/marty/script_form/client/theme/neat.css +0 -9
  203. data/app/components/marty/script_form/client/theme/night.css +0 -21
  204. data/app/components/marty/script_form/client/theme/rubyblue.css +0 -21
  205. data/app/components/marty/script_form/client/theme/vibrant-ink.css +0 -27
  206. data/app/components/marty/script_form/client/theme/xq-dark.css +0 -46
  207. data/app/components/marty/script_form/client/util/closetag.js +0 -164
  208. data/app/components/marty/script_form/client/util/dialog.css +0 -27
  209. data/app/components/marty/script_form/client/util/dialog.js +0 -70
  210. data/app/components/marty/script_form/client/util/foldcode.js +0 -196
  211. data/app/components/marty/script_form/client/util/formatting.js +0 -193
  212. data/app/components/marty/script_form/client/util/javascript-hint.js +0 -134
  213. data/app/components/marty/script_form/client/util/loadmode.js +0 -51
  214. data/app/components/marty/script_form/client/util/match-highlighter.js +0 -44
  215. data/app/components/marty/script_form/client/util/multiplex.js +0 -77
  216. data/app/components/marty/script_form/client/util/overlay.js +0 -54
  217. data/app/components/marty/script_form/client/util/pig-hint.js +0 -123
  218. data/app/components/marty/script_form/client/util/runmode-standalone.js +0 -90
  219. data/app/components/marty/script_form/client/util/runmode.js +0 -53
  220. data/app/components/marty/script_form/client/util/search.js +0 -118
  221. data/app/components/marty/script_form/client/util/searchcursor.js +0 -119
  222. data/app/components/marty/script_form/client/util/simple-hint.css +0 -16
  223. data/app/components/marty/script_form/client/util/simple-hint.js +0 -97
  224. data/app/components/marty/script_form/client/util/xml-hint.js +0 -137
  225. data/lib/marty/javascript/grid_view_in_form.js +0 -81
@@ -1,49 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>CodeMirror: Rust mode</title>
6
- <link rel="stylesheet" href="../../lib/codemirror.css">
7
- <script src="../../lib/codemirror.js"></script>
8
- <script src="rust.js"></script>
9
- <link rel="stylesheet" href="../../doc/docs.css">
10
- <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11
- </head>
12
- <body>
13
- <h1>CodeMirror: Rust mode</h1>
14
-
15
- <div><textarea id="code" name="code">
16
- // Demo code.
17
-
18
- type foo<T> = int;
19
- enum bar {
20
- some(int, foo<float>),
21
- none
22
- }
23
-
24
- fn check_crate(x: int) {
25
- let v = 10;
26
- alt foo {
27
- 1 to 3 {
28
- print_foo();
29
- if x {
30
- blah() + 10;
31
- }
32
- }
33
- (x, y) { "bye" }
34
- _ { "hi" }
35
- }
36
- }
37
- </textarea></div>
38
-
39
- <script>
40
- var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
41
- lineNumbers: true,
42
- matchBrackets: true,
43
- tabMode: "indent"
44
- });
45
- </script>
46
-
47
- <p><strong>MIME types defined:</strong> <code>text/x-rustsrc</code>.</p>
48
- </body>
49
- </html>
@@ -1,432 +0,0 @@
1
- CodeMirror.defineMode("rust", function() {
2
- var indentUnit = 4, altIndentUnit = 2;
3
- var valKeywords = {
4
- "if": "if-style", "while": "if-style", "else": "else-style",
5
- "do": "else-style", "ret": "else-style", "fail": "else-style",
6
- "break": "atom", "cont": "atom", "const": "let", "resource": "fn",
7
- "let": "let", "fn": "fn", "for": "for", "alt": "alt", "iface": "iface",
8
- "impl": "impl", "type": "type", "enum": "enum", "mod": "mod",
9
- "as": "op", "true": "atom", "false": "atom", "assert": "op", "check": "op",
10
- "claim": "op", "native": "ignore", "unsafe": "ignore", "import": "else-style",
11
- "export": "else-style", "copy": "op", "log": "op", "log_err": "op",
12
- "use": "op", "bind": "op", "self": "atom"
13
- };
14
- var typeKeywords = function() {
15
- var keywords = {"fn": "fn", "block": "fn", "obj": "obj"};
16
- var atoms = "bool uint int i8 i16 i32 i64 u8 u16 u32 u64 float f32 f64 str char".split(" ");
17
- for (var i = 0, e = atoms.length; i < e; ++i) keywords[atoms[i]] = "atom";
18
- return keywords;
19
- }();
20
- var operatorChar = /[+\-*&%=<>!?|\.@]/;
21
-
22
- // Tokenizer
23
-
24
- // Used as scratch variable to communicate multiple values without
25
- // consing up tons of objects.
26
- var tcat, content;
27
- function r(tc, style) {
28
- tcat = tc;
29
- return style;
30
- }
31
-
32
- function tokenBase(stream, state) {
33
- var ch = stream.next();
34
- if (ch == '"') {
35
- state.tokenize = tokenString;
36
- return state.tokenize(stream, state);
37
- }
38
- if (ch == "'") {
39
- tcat = "atom";
40
- if (stream.eat("\\")) {
41
- if (stream.skipTo("'")) { stream.next(); return "string"; }
42
- else { return "error"; }
43
- } else {
44
- stream.next();
45
- return stream.eat("'") ? "string" : "error";
46
- }
47
- }
48
- if (ch == "/") {
49
- if (stream.eat("/")) { stream.skipToEnd(); return "comment"; }
50
- if (stream.eat("*")) {
51
- state.tokenize = tokenComment(1);
52
- return state.tokenize(stream, state);
53
- }
54
- }
55
- if (ch == "#") {
56
- if (stream.eat("[")) { tcat = "open-attr"; return null; }
57
- stream.eatWhile(/\w/);
58
- return r("macro", "meta");
59
- }
60
- if (ch == ":" && stream.match(":<")) {
61
- return r("op", null);
62
- }
63
- if (ch.match(/\d/) || (ch == "." && stream.eat(/\d/))) {
64
- var flp = false;
65
- if (!stream.match(/^x[\da-f]+/i) && !stream.match(/^b[01]+/)) {
66
- stream.eatWhile(/\d/);
67
- if (stream.eat(".")) { flp = true; stream.eatWhile(/\d/); }
68
- if (stream.match(/^e[+\-]?\d+/i)) { flp = true; }
69
- }
70
- if (flp) stream.match(/^f(?:32|64)/);
71
- else stream.match(/^[ui](?:8|16|32|64)/);
72
- return r("atom", "number");
73
- }
74
- if (ch.match(/[()\[\]{}:;,]/)) return r(ch, null);
75
- if (ch == "-" && stream.eat(">")) return r("->", null);
76
- if (ch.match(operatorChar)) {
77
- stream.eatWhile(operatorChar);
78
- return r("op", null);
79
- }
80
- stream.eatWhile(/\w/);
81
- content = stream.current();
82
- if (stream.match(/^::\w/)) {
83
- stream.backUp(1);
84
- return r("prefix", "variable-2");
85
- }
86
- if (state.keywords.propertyIsEnumerable(content))
87
- return r(state.keywords[content], content.match(/true|false/) ? "atom" : "keyword");
88
- return r("name", "variable");
89
- }
90
-
91
- function tokenString(stream, state) {
92
- var ch, escaped = false;
93
- while (ch = stream.next()) {
94
- if (ch == '"' && !escaped) {
95
- state.tokenize = tokenBase;
96
- return r("atom", "string");
97
- }
98
- escaped = !escaped && ch == "\\";
99
- }
100
- // Hack to not confuse the parser when a string is split in
101
- // pieces.
102
- return r("op", "string");
103
- }
104
-
105
- function tokenComment(depth) {
106
- return function(stream, state) {
107
- var lastCh = null, ch;
108
- while (ch = stream.next()) {
109
- if (ch == "/" && lastCh == "*") {
110
- if (depth == 1) {
111
- state.tokenize = tokenBase;
112
- break;
113
- } else {
114
- state.tokenize = tokenComment(depth - 1);
115
- return state.tokenize(stream, state);
116
- }
117
- }
118
- if (ch == "*" && lastCh == "/") {
119
- state.tokenize = tokenComment(depth + 1);
120
- return state.tokenize(stream, state);
121
- }
122
- lastCh = ch;
123
- }
124
- return "comment";
125
- };
126
- }
127
-
128
- // Parser
129
-
130
- var cx = {state: null, stream: null, marked: null, cc: null};
131
- function pass() {
132
- for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
133
- }
134
- function cont() {
135
- pass.apply(null, arguments);
136
- return true;
137
- }
138
-
139
- function pushlex(type, info) {
140
- var result = function() {
141
- var state = cx.state;
142
- state.lexical = {indented: state.indented, column: cx.stream.column(),
143
- type: type, prev: state.lexical, info: info};
144
- };
145
- result.lex = true;
146
- return result;
147
- }
148
- function poplex() {
149
- var state = cx.state;
150
- if (state.lexical.prev) {
151
- if (state.lexical.type == ")")
152
- state.indented = state.lexical.indented;
153
- state.lexical = state.lexical.prev;
154
- }
155
- }
156
- function typecx() { cx.state.keywords = typeKeywords; }
157
- function valcx() { cx.state.keywords = valKeywords; }
158
- poplex.lex = typecx.lex = valcx.lex = true;
159
-
160
- function commasep(comb, end) {
161
- function more(type) {
162
- if (type == ",") return cont(comb, more);
163
- if (type == end) return cont();
164
- return cont(more);
165
- }
166
- return function(type) {
167
- if (type == end) return cont();
168
- return pass(comb, more);
169
- };
170
- }
171
-
172
- function stat_of(comb, tag) {
173
- return cont(pushlex("stat", tag), comb, poplex, block);
174
- }
175
- function block(type) {
176
- if (type == "}") return cont();
177
- if (type == "let") return stat_of(letdef1, "let");
178
- if (type == "fn") return stat_of(fndef);
179
- if (type == "type") return cont(pushlex("stat"), tydef, endstatement, poplex, block);
180
- if (type == "enum") return stat_of(enumdef);
181
- if (type == "mod") return stat_of(mod);
182
- if (type == "iface") return stat_of(iface);
183
- if (type == "impl") return stat_of(impl);
184
- if (type == "open-attr") return cont(pushlex("]"), commasep(expression, "]"), poplex);
185
- if (type == "ignore" || type.match(/[\]\);,]/)) return cont(block);
186
- return pass(pushlex("stat"), expression, poplex, endstatement, block);
187
- }
188
- function endstatement(type) {
189
- if (type == ";") return cont();
190
- return pass();
191
- }
192
- function expression(type) {
193
- if (type == "atom" || type == "name") return cont(maybeop);
194
- if (type == "{") return cont(pushlex("}"), exprbrace, poplex);
195
- if (type.match(/[\[\(]/)) return matchBrackets(type, expression);
196
- if (type.match(/[\]\)\};,]/)) return pass();
197
- if (type == "if-style") return cont(expression, expression);
198
- if (type == "else-style" || type == "op") return cont(expression);
199
- if (type == "for") return cont(pattern, maybetype, inop, expression, expression);
200
- if (type == "alt") return cont(expression, altbody);
201
- if (type == "fn") return cont(fndef);
202
- if (type == "macro") return cont(macro);
203
- return cont();
204
- }
205
- function maybeop(type) {
206
- if (content == ".") return cont(maybeprop);
207
- if (content == "::<"){return cont(typarams, maybeop);}
208
- if (type == "op" || content == ":") return cont(expression);
209
- if (type == "(" || type == "[") return matchBrackets(type, expression);
210
- return pass();
211
- }
212
- function maybeprop(type) {
213
- if (content.match(/^\w+$/)) {cx.marked = "variable"; return cont(maybeop);}
214
- return pass(expression);
215
- }
216
- function exprbrace(type) {
217
- if (type == "op") {
218
- if (content == "|") return cont(blockvars, poplex, pushlex("}", "block"), block);
219
- if (content == "||") return cont(poplex, pushlex("}", "block"), block);
220
- }
221
- if (content == "mutable" || (content.match(/^\w+$/) && cx.stream.peek() == ":"
222
- && !cx.stream.match("::", false)))
223
- return pass(record_of(expression));
224
- return pass(block);
225
- }
226
- function record_of(comb) {
227
- function ro(type) {
228
- if (content == "mutable" || content == "with") {cx.marked = "keyword"; return cont(ro);}
229
- if (content.match(/^\w*$/)) {cx.marked = "variable"; return cont(ro);}
230
- if (type == ":") return cont(comb, ro);
231
- if (type == "}") return cont();
232
- return cont(ro);
233
- }
234
- return ro;
235
- }
236
- function blockvars(type) {
237
- if (type == "name") {cx.marked = "def"; return cont(blockvars);}
238
- if (type == "op" && content == "|") return cont();
239
- return cont(blockvars);
240
- }
241
-
242
- function letdef1(type) {
243
- if (type.match(/[\]\)\};]/)) return cont();
244
- if (content == "=") return cont(expression, letdef2);
245
- if (type == ",") return cont(letdef1);
246
- return pass(pattern, maybetype, letdef1);
247
- }
248
- function letdef2(type) {
249
- if (type.match(/[\]\)\};,]/)) return pass(letdef1);
250
- else return pass(expression, letdef2);
251
- }
252
- function maybetype(type) {
253
- if (type == ":") return cont(typecx, rtype, valcx);
254
- return pass();
255
- }
256
- function inop(type) {
257
- if (type == "name" && content == "in") {cx.marked = "keyword"; return cont();}
258
- return pass();
259
- }
260
- function fndef(type) {
261
- if (content == "@" || content == "~") {cx.marked = "keyword"; return cont(fndef);}
262
- if (type == "name") {cx.marked = "def"; return cont(fndef);}
263
- if (content == "<") return cont(typarams, fndef);
264
- if (type == "{") return pass(expression);
265
- if (type == "(") return cont(pushlex(")"), commasep(argdef, ")"), poplex, fndef);
266
- if (type == "->") return cont(typecx, rtype, valcx, fndef);
267
- if (type == ";") return cont();
268
- return cont(fndef);
269
- }
270
- function tydef(type) {
271
- if (type == "name") {cx.marked = "def"; return cont(tydef);}
272
- if (content == "<") return cont(typarams, tydef);
273
- if (content == "=") return cont(typecx, rtype, valcx);
274
- return cont(tydef);
275
- }
276
- function enumdef(type) {
277
- if (type == "name") {cx.marked = "def"; return cont(enumdef);}
278
- if (content == "<") return cont(typarams, enumdef);
279
- if (content == "=") return cont(typecx, rtype, valcx, endstatement);
280
- if (type == "{") return cont(pushlex("}"), typecx, enumblock, valcx, poplex);
281
- return cont(enumdef);
282
- }
283
- function enumblock(type) {
284
- if (type == "}") return cont();
285
- if (type == "(") return cont(pushlex(")"), commasep(rtype, ")"), poplex, enumblock);
286
- if (content.match(/^\w+$/)) cx.marked = "def";
287
- return cont(enumblock);
288
- }
289
- function mod(type) {
290
- if (type == "name") {cx.marked = "def"; return cont(mod);}
291
- if (type == "{") return cont(pushlex("}"), block, poplex);
292
- return pass();
293
- }
294
- function iface(type) {
295
- if (type == "name") {cx.marked = "def"; return cont(iface);}
296
- if (content == "<") return cont(typarams, iface);
297
- if (type == "{") return cont(pushlex("}"), block, poplex);
298
- return pass();
299
- }
300
- function impl(type) {
301
- if (content == "<") return cont(typarams, impl);
302
- if (content == "of" || content == "for") {cx.marked = "keyword"; return cont(rtype, impl);}
303
- if (type == "name") {cx.marked = "def"; return cont(impl);}
304
- if (type == "{") return cont(pushlex("}"), block, poplex);
305
- return pass();
306
- }
307
- function typarams(type) {
308
- if (content == ">") return cont();
309
- if (content == ",") return cont(typarams);
310
- if (content == ":") return cont(rtype, typarams);
311
- return pass(rtype, typarams);
312
- }
313
- function argdef(type) {
314
- if (type == "name") {cx.marked = "def"; return cont(argdef);}
315
- if (type == ":") return cont(typecx, rtype, valcx);
316
- return pass();
317
- }
318
- function rtype(type) {
319
- if (type == "name") {cx.marked = "variable-3"; return cont(rtypemaybeparam); }
320
- if (content == "mutable") {cx.marked = "keyword"; return cont(rtype);}
321
- if (type == "atom") return cont(rtypemaybeparam);
322
- if (type == "op" || type == "obj") return cont(rtype);
323
- if (type == "fn") return cont(fntype);
324
- if (type == "{") return cont(pushlex("{"), record_of(rtype), poplex);
325
- return matchBrackets(type, rtype);
326
- }
327
- function rtypemaybeparam(type) {
328
- if (content == "<") return cont(typarams);
329
- return pass();
330
- }
331
- function fntype(type) {
332
- if (type == "(") return cont(pushlex("("), commasep(rtype, ")"), poplex, fntype);
333
- if (type == "->") return cont(rtype);
334
- return pass();
335
- }
336
- function pattern(type) {
337
- if (type == "name") {cx.marked = "def"; return cont(patternmaybeop);}
338
- if (type == "atom") return cont(patternmaybeop);
339
- if (type == "op") return cont(pattern);
340
- if (type.match(/[\]\)\};,]/)) return pass();
341
- return matchBrackets(type, pattern);
342
- }
343
- function patternmaybeop(type) {
344
- if (type == "op" && content == ".") return cont();
345
- if (content == "to") {cx.marked = "keyword"; return cont(pattern);}
346
- else return pass();
347
- }
348
- function altbody(type) {
349
- if (type == "{") return cont(pushlex("}", "alt"), altblock1, poplex);
350
- return pass();
351
- }
352
- function altblock1(type) {
353
- if (type == "}") return cont();
354
- if (type == "|") return cont(altblock1);
355
- if (content == "when") {cx.marked = "keyword"; return cont(expression, altblock2);}
356
- if (type.match(/[\]\);,]/)) return cont(altblock1);
357
- return pass(pattern, altblock2);
358
- }
359
- function altblock2(type) {
360
- if (type == "{") return cont(pushlex("}", "alt"), block, poplex, altblock1);
361
- else return pass(altblock1);
362
- }
363
-
364
- function macro(type) {
365
- if (type.match(/[\[\(\{]/)) return matchBrackets(type, expression);
366
- return pass();
367
- }
368
- function matchBrackets(type, comb) {
369
- if (type == "[") return cont(pushlex("]"), commasep(comb, "]"), poplex);
370
- if (type == "(") return cont(pushlex(")"), commasep(comb, ")"), poplex);
371
- if (type == "{") return cont(pushlex("}"), commasep(comb, "}"), poplex);
372
- return cont();
373
- }
374
-
375
- function parse(state, stream, style) {
376
- var cc = state.cc;
377
- // Communicate our context to the combinators.
378
- // (Less wasteful than consing up a hundred closures on every call.)
379
- cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
380
-
381
- while (true) {
382
- var combinator = cc.length ? cc.pop() : block;
383
- if (combinator(tcat)) {
384
- while(cc.length && cc[cc.length - 1].lex)
385
- cc.pop()();
386
- return cx.marked || style;
387
- }
388
- }
389
- }
390
-
391
- return {
392
- startState: function() {
393
- return {
394
- tokenize: tokenBase,
395
- cc: [],
396
- lexical: {indented: -indentUnit, column: 0, type: "top", align: false},
397
- keywords: valKeywords,
398
- indented: 0
399
- };
400
- },
401
-
402
- token: function(stream, state) {
403
- if (stream.sol()) {
404
- if (!state.lexical.hasOwnProperty("align"))
405
- state.lexical.align = false;
406
- state.indented = stream.indentation();
407
- }
408
- if (stream.eatSpace()) return null;
409
- tcat = content = null;
410
- var style = state.tokenize(stream, state);
411
- if (style == "comment") return style;
412
- if (!state.lexical.hasOwnProperty("align"))
413
- state.lexical.align = true;
414
- if (tcat == "prefix") return style;
415
- if (!content) content = stream.current();
416
- return parse(state, stream, style);
417
- },
418
-
419
- indent: function(state, textAfter) {
420
- if (state.tokenize != tokenBase) return 0;
421
- var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical,
422
- type = lexical.type, closing = firstChar == type;
423
- if (type == "stat") return lexical.indented + indentUnit;
424
- if (lexical.align) return lexical.column + (closing ? 0 : 1);
425
- return lexical.indented + (closing ? 0 : (lexical.info == "alt" ? altIndentUnit : indentUnit));
426
- },
427
-
428
- electricChars: "{}"
429
- };
430
- });
431
-
432
- CodeMirror.defineMIME("text/x-rustsrc", "rust");