mode-ocaml-uncompressed.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is Ajax.org Code Editor (ACE).
  15. *
  16. * The Initial Developer of the Original Code is
  17. * Ajax.org B.V.
  18. * Portions created by the Initial Developer are Copyright (C) 2010
  19. * the Initial Developer. All Rights Reserved.
  20. *
  21. * Contributor(s):
  22. * Sergi Mansilla <sergi AT ajax DOT org>
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. define('ace/mode/ocaml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/ocaml_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range'], function(require, exports, module) {
  38. "use strict";
  39. var oop = require("../lib/oop");
  40. var TextMode = require("./text").Mode;
  41. var Tokenizer = require("../tokenizer").Tokenizer;
  42. var OcamlHighlightRules = require("./ocaml_highlight_rules").OcamlHighlightRules;
  43. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  44. var Range = require("../range").Range;
  45. var Mode = function() {
  46. this.$tokenizer = new Tokenizer(new OcamlHighlightRules().getRules());
  47. this.$outdent = new MatchingBraceOutdent();
  48. };
  49. oop.inherits(Mode, TextMode);
  50. var indenter = /(?:[({[=:]|[-=]>|\b(?:else|try|with))\s*$/;
  51. (function() {
  52. this.toggleCommentLines = function(state, doc, startRow, endRow) {
  53. var i, line;
  54. var outdent = true;
  55. var re = /^\s*\(\*(.*)\*\)/;
  56. for (i=startRow; i<= endRow; i++) {
  57. if (!re.test(doc.getLine(i))) {
  58. outdent = false;
  59. break;
  60. }
  61. }
  62. var range = new Range(0, 0, 0, 0);
  63. for (i=startRow; i<= endRow; i++) {
  64. line = doc.getLine(i);
  65. range.start.row = i;
  66. range.end.row = i;
  67. range.end.column = line.length;
  68. doc.replace(range, outdent ? line.match(re)[1] : "(*" + line + "*)");
  69. }
  70. };
  71. this.getNextLineIndent = function(state, line, tab) {
  72. var indent = this.$getIndent(line);
  73. var tokens = this.$tokenizer.getLineTokens(line, state).tokens;
  74. if (!(tokens.length && tokens[tokens.length - 1].type === 'comment') &&
  75. state === 'start' && indenter.test(line))
  76. indent += tab;
  77. return indent;
  78. };
  79. this.checkOutdent = function(state, line, input) {
  80. return this.$outdent.checkOutdent(line, input);
  81. };
  82. this.autoOutdent = function(state, doc, row) {
  83. this.$outdent.autoOutdent(doc, row);
  84. };
  85. }).call(Mode.prototype);
  86. exports.Mode = Mode;
  87. });
  88. /* ***** BEGIN LICENSE BLOCK *****
  89. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  90. *
  91. * The contents of this file are subject to the Mozilla Public License Version
  92. * 1.1 (the "License"); you may not use this file except in compliance with
  93. * the License. You may obtain a copy of the License at
  94. * http://www.mozilla.org/MPL/
  95. *
  96. * Software distributed under the License is distributed on an "AS IS" basis,
  97. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  98. * for the specific language governing rights and limitations under the
  99. * License.
  100. *
  101. * The Original Code is Ajax.org Code Editor (ACE).
  102. *
  103. * The Initial Developer of the Original Code is
  104. * Ajax.org B.V.
  105. * Portions created by the Initial Developer are Copyright (C) 2010
  106. * the Initial Developer. All Rights Reserved.
  107. *
  108. * Contributor(s):
  109. * Sergi Mansilla <sergi AT ajax DOT org>
  110. *
  111. * Alternatively, the contents of this file may be used under the terms of
  112. * either the GNU General Public License Version 2 or later (the "GPL"), or
  113. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  114. * in which case the provisions of the GPL or the LGPL are applicable instead
  115. * of those above. If you wish to allow use of your version of this file only
  116. * under the terms of either the GPL or the LGPL, and not to allow others to
  117. * use your version of this file under the terms of the MPL, indicate your
  118. * decision by deleting the provisions above and replace them with the notice
  119. * and other provisions required by the GPL or the LGPL. If you do not delete
  120. * the provisions above, a recipient may use your version of this file under
  121. * the terms of any one of the MPL, the GPL or the LGPL.
  122. *
  123. * ***** END LICENSE BLOCK *****
  124. *
  125. */
  126. define('ace/mode/ocaml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
  127. "use strict";
  128. var oop = require("../lib/oop");
  129. var lang = require("../lib/lang");
  130. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  131. var OcamlHighlightRules = function() {
  132. var keywords = lang.arrayToMap((
  133. "and|as|assert|begin|class|constraint|do|done|downto|else|end|" +
  134. "exception|external|for|fun|function|functor|if|in|include|" +
  135. "inherit|initializer|lazy|let|match|method|module|mutable|new|" +
  136. "object|of|open|or|private|rec|sig|struct|then|to|try|type|val|" +
  137. "virtual|when|while|with").split("|")
  138. );
  139. var builtinConstants = lang.arrayToMap(
  140. ("true|false").split("|")
  141. );
  142. var builtinFunctions = lang.arrayToMap((
  143. "abs|abs_big_int|abs_float|abs_num|abstract_tag|accept|access|acos|add|" +
  144. "add_available_units|add_big_int|add_buffer|add_channel|add_char|" +
  145. "add_initializer|add_int_big_int|add_interfaces|add_num|add_string|" +
  146. "add_substitute|add_substring|alarm|allocated_bytes|allow_only|" +
  147. "allow_unsafe_modules|always|append|appname_get|appname_set|" +
  148. "approx_num_exp|approx_num_fix|arg|argv|arith_status|array|" +
  149. "array1_of_genarray|array2_of_genarray|array3_of_genarray|asin|asr|" +
  150. "assoc|assq|at_exit|atan|atan2|auto_synchronize|background|basename|" +
  151. "beginning_of_input|big_int_of_int|big_int_of_num|big_int_of_string|bind|" +
  152. "bind_class|bind_tag|bits|bits_of_float|black|blit|blit_image|blue|bool|" +
  153. "bool_of_string|bounded_full_split|bounded_split|bounded_split_delim|" +
  154. "bprintf|break|broadcast|bscanf|button_down|c_layout|capitalize|cardinal|" +
  155. "cardinal|catch|catch_break|ceil|ceiling_num|channel|char|char_of_int|" +
  156. "chdir|check|check_suffix|chmod|choose|chop_extension|chop_suffix|chown|" +
  157. "chown|chr|chroot|classify_float|clear|clear_available_units|" +
  158. "clear_close_on_exec|clear_graph|clear_nonblock|clear_parser|" +
  159. "close|close|closeTk|close_box|close_graph|close_in|close_in_noerr|" +
  160. "close_out|close_out_noerr|close_process|close_process|" +
  161. "close_process_full|close_process_in|close_process_out|close_subwindow|" +
  162. "close_tag|close_tbox|closedir|closedir|closure_tag|code|combine|" +
  163. "combine|combine|command|compact|compare|compare_big_int|compare_num|" +
  164. "complex32|complex64|concat|conj|connect|contains|contains_from|contents|" +
  165. "copy|cos|cosh|count|count|counters|create|create_alarm|create_image|" +
  166. "create_matrix|create_matrix|create_matrix|create_object|" +
  167. "create_object_and_run_initializers|create_object_opt|create_process|" +
  168. "create_process|create_process_env|create_process_env|create_table|" +
  169. "current|current_dir_name|current_point|current_x|current_y|curveto|" +
  170. "custom_tag|cyan|data_size|decr|decr_num|default_available_units|delay|" +
  171. "delete_alarm|descr_of_in_channel|descr_of_out_channel|destroy|diff|dim|" +
  172. "dim1|dim2|dim3|dims|dirname|display_mode|div|div_big_int|div_num|" +
  173. "double_array_tag|double_tag|draw_arc|draw_char|draw_circle|draw_ellipse|" +
  174. "draw_image|draw_poly|draw_poly_line|draw_rect|draw_segments|draw_string|" +
  175. "dummy_pos|dummy_table|dump_image|dup|dup2|elements|empty|end_of_input|" +
  176. "environment|eprintf|epsilon_float|eq_big_int|eq_num|equal|err_formatter|" +
  177. "error_message|escaped|establish_server|executable_name|execv|execve|execvp|" +
  178. "execvpe|exists|exists2|exit|exp|failwith|fast_sort|fchmod|fchown|field|" +
  179. "file|file_exists|fill|fill_arc|fill_circle|fill_ellipse|fill_poly|fill_rect|" +
  180. "filter|final_tag|finalise|find|find_all|first_chars|firstkey|flatten|" +
  181. "float|float32|float64|float_of_big_int|float_of_bits|float_of_int|" +
  182. "float_of_num|float_of_string|floor|floor_num|flush|flush_all|flush_input|" +
  183. "flush_str_formatter|fold|fold_left|fold_left2|fold_right|fold_right2|" +
  184. "for_all|for_all2|force|force_newline|force_val|foreground|fork|" +
  185. "format_of_string|formatter_of_buffer|formatter_of_out_channel|" +
  186. "fortran_layout|forward_tag|fprintf|frexp|from|from_channel|from_file|" +
  187. "from_file_bin|from_function|from_string|fscanf|fst|fstat|ftruncate|" +
  188. "full_init|full_major|full_split|gcd_big_int|ge_big_int|ge_num|" +
  189. "genarray_of_array1|genarray_of_array2|genarray_of_array3|get|" +
  190. "get_all_formatter_output_functions|get_approx_printing|get_copy|" +
  191. "get_ellipsis_text|get_error_when_null_denominator|get_floating_precision|" +
  192. "get_formatter_output_functions|get_formatter_tag_functions|get_image|" +
  193. "get_margin|get_mark_tags|get_max_boxes|get_max_indent|get_method|" +
  194. "get_method_label|get_normalize_ratio|get_normalize_ratio_when_printing|" +
  195. "get_print_tags|get_state|get_variable|getcwd|getegid|getegid|getenv|" +
  196. "getenv|getenv|geteuid|geteuid|getgid|getgid|getgrgid|getgrgid|getgrnam|" +
  197. "getgrnam|getgroups|gethostbyaddr|gethostbyname|gethostname|getitimer|" +
  198. "getlogin|getpeername|getpid|getppid|getprotobyname|getprotobynumber|" +
  199. "getpwnam|getpwuid|getservbyname|getservbyport|getsockname|getsockopt|" +
  200. "getsockopt_float|getsockopt_int|getsockopt_optint|gettimeofday|getuid|" +
  201. "global_replace|global_substitute|gmtime|green|grid|group_beginning|" +
  202. "group_end|gt_big_int|gt_num|guard|handle_unix_error|hash|hash_param|" +
  203. "hd|header_size|i|id|ignore|in_channel_length|in_channel_of_descr|incr|" +
  204. "incr_num|index|index_from|inet_addr_any|inet_addr_of_string|infinity|" +
  205. "infix_tag|init|init_class|input|input_binary_int|input_byte|input_char|" +
  206. "input_line|input_value|int|int16_signed|int16_unsigned|int32|int64|" +
  207. "int8_signed|int8_unsigned|int_of_big_int|int_of_char|int_of_float|" +
  208. "int_of_num|int_of_string|integer_num|inter|interactive|inv|invalid_arg|" +
  209. "is_block|is_empty|is_implicit|is_int|is_int_big_int|is_integer_num|" +
  210. "is_relative|iter|iter2|iteri|join|junk|key_pressed|kill|kind|kprintf|" +
  211. "kscanf|land|last_chars|layout|lazy_from_fun|lazy_from_val|lazy_is_val|" +
  212. "lazy_tag|ldexp|le_big_int|le_num|length|lexeme|lexeme_char|lexeme_end|" +
  213. "lexeme_end_p|lexeme_start|lexeme_start_p|lineto|link|list|listen|lnot|" +
  214. "loadfile|loadfile_private|localtime|lock|lockf|log|log10|logand|lognot|" +
  215. "logor|logxor|lor|lower_window|lowercase|lseek|lsl|lsr|lstat|lt_big_int|" +
  216. "lt_num|lxor|magenta|magic|mainLoop|major|major_slice|make|make_formatter|" +
  217. "make_image|make_lexer|make_matrix|make_self_init|map|map2|map_file|mapi|" +
  218. "marshal|match_beginning|match_end|matched_group|matched_string|max|" +
  219. "max_array_length|max_big_int|max_elt|max_float|max_int|max_num|" +
  220. "max_string_length|mem|mem_assoc|mem_assq|memq|merge|min|min_big_int|" +
  221. "min_elt|min_float|min_int|min_num|minor|minus_big_int|minus_num|" +
  222. "minus_one|mkdir|mkfifo|mktime|mod|mod_big_int|mod_float|mod_num|modf|" +
  223. "mouse_pos|moveto|mul|mult_big_int|mult_int_big_int|mult_num|nan|narrow|" +
  224. "nat_of_num|nativeint|neg|neg_infinity|new_block|new_channel|new_method|" +
  225. "new_variable|next|nextkey|nice|nice|no_scan_tag|norm|norm2|not|npeek|" +
  226. "nth|nth_dim|num_digits_big_int|num_dims|num_of_big_int|num_of_int|" +
  227. "num_of_nat|num_of_ratio|num_of_string|O|obj|object_tag|ocaml_version|" +
  228. "of_array|of_channel|of_float|of_int|of_int32|of_list|of_nativeint|" +
  229. "of_string|one|openTk|open_box|open_connection|open_graph|open_hbox|" +
  230. "open_hovbox|open_hvbox|open_in|open_in_bin|open_in_gen|open_out|" +
  231. "open_out_bin|open_out_gen|open_process|open_process_full|open_process_in|" +
  232. "open_process_out|open_subwindow|open_tag|open_tbox|open_temp_file|" +
  233. "open_vbox|opendbm|opendir|openfile|or|os_type|out_channel_length|" +
  234. "out_channel_of_descr|output|output_binary_int|output_buffer|output_byte|" +
  235. "output_char|output_string|output_value|over_max_boxes|pack|params|" +
  236. "parent_dir_name|parse|parse_argv|partition|pause|peek|pipe|pixels|" +
  237. "place|plot|plots|point_color|polar|poll|pop|pos_in|pos_out|pow|" +
  238. "power_big_int_positive_big_int|power_big_int_positive_int|" +
  239. "power_int_positive_big_int|power_int_positive_int|power_num|" +
  240. "pp_close_box|pp_close_tag|pp_close_tbox|pp_force_newline|" +
  241. "pp_get_all_formatter_output_functions|pp_get_ellipsis_text|" +
  242. "pp_get_formatter_output_functions|pp_get_formatter_tag_functions|" +
  243. "pp_get_margin|pp_get_mark_tags|pp_get_max_boxes|pp_get_max_indent|" +
  244. "pp_get_print_tags|pp_open_box|pp_open_hbox|pp_open_hovbox|pp_open_hvbox|" +
  245. "pp_open_tag|pp_open_tbox|pp_open_vbox|pp_over_max_boxes|pp_print_as|" +
  246. "pp_print_bool|pp_print_break|pp_print_char|pp_print_cut|pp_print_float|" +
  247. "pp_print_flush|pp_print_if_newline|pp_print_int|pp_print_newline|" +
  248. "pp_print_space|pp_print_string|pp_print_tab|pp_print_tbreak|" +
  249. "pp_set_all_formatter_output_functions|pp_set_ellipsis_text|" +
  250. "pp_set_formatter_out_channel|pp_set_formatter_output_functions|" +
  251. "pp_set_formatter_tag_functions|pp_set_margin|pp_set_mark_tags|" +
  252. "pp_set_max_boxes|pp_set_max_indent|pp_set_print_tags|pp_set_tab|" +
  253. "pp_set_tags|pred|pred_big_int|pred_num|prerr_char|prerr_endline|" +
  254. "prerr_float|prerr_int|prerr_newline|prerr_string|print|print_as|" +
  255. "print_bool|print_break|print_char|print_cut|print_endline|print_float|" +
  256. "print_flush|print_if_newline|print_int|print_newline|print_space|" +
  257. "print_stat|print_string|print_tab|print_tbreak|printf|prohibit|" +
  258. "public_method_label|push|putenv|quo_num|quomod_big_int|quote|raise|" +
  259. "raise_window|ratio_of_num|rcontains_from|read|read_float|read_int|" +
  260. "read_key|read_line|readdir|readdir|readlink|really_input|receive|recv|" +
  261. "recvfrom|red|ref|regexp|regexp_case_fold|regexp_string|" +
  262. "regexp_string_case_fold|register|register_exception|rem|remember_mode|" +
  263. "remove|remove_assoc|remove_assq|rename|replace|replace_first|" +
  264. "replace_matched|repr|reset|reshape|reshape_1|reshape_2|reshape_3|rev|" +
  265. "rev_append|rev_map|rev_map2|rewinddir|rgb|rhs_end|rhs_end_pos|rhs_start|" +
  266. "rhs_start_pos|rindex|rindex_from|rlineto|rmdir|rmoveto|round_num|" +
  267. "run_initializers|run_initializers_opt|scanf|search_backward|" +
  268. "search_forward|seek_in|seek_out|select|self|self_init|send|sendto|set|" +
  269. "set_all_formatter_output_functions|set_approx_printing|" +
  270. "set_binary_mode_in|set_binary_mode_out|set_close_on_exec|" +
  271. "set_close_on_exec|set_color|set_ellipsis_text|" +
  272. "set_error_when_null_denominator|set_field|set_floating_precision|" +
  273. "set_font|set_formatter_out_channel|set_formatter_output_functions|" +
  274. "set_formatter_tag_functions|set_line_width|set_margin|set_mark_tags|" +
  275. "set_max_boxes|set_max_indent|set_method|set_nonblock|set_nonblock|" +
  276. "set_normalize_ratio|set_normalize_ratio_when_printing|set_print_tags|" +
  277. "set_signal|set_state|set_tab|set_tag|set_tags|set_text_size|" +
  278. "set_window_title|setgid|setgid|setitimer|setitimer|setsid|setsid|" +
  279. "setsockopt|setsockopt|setsockopt_float|setsockopt_float|setsockopt_int|" +
  280. "setsockopt_int|setsockopt_optint|setsockopt_optint|setuid|setuid|" +
  281. "shift_left|shift_left|shift_left|shift_right|shift_right|shift_right|" +
  282. "shift_right_logical|shift_right_logical|shift_right_logical|show_buckets|" +
  283. "shutdown|shutdown|shutdown_connection|shutdown_connection|sigabrt|" +
  284. "sigalrm|sigchld|sigcont|sigfpe|sighup|sigill|sigint|sigkill|sign_big_int|" +
  285. "sign_num|signal|signal|sigpending|sigpending|sigpipe|sigprocmask|" +
  286. "sigprocmask|sigprof|sigquit|sigsegv|sigstop|sigsuspend|sigsuspend|" +
  287. "sigterm|sigtstp|sigttin|sigttou|sigusr1|sigusr2|sigvtalrm|sin|singleton|" +
  288. "sinh|size|size|size_x|size_y|sleep|sleep|sleep|slice_left|slice_left|" +
  289. "slice_left_1|slice_left_2|slice_right|slice_right|slice_right_1|" +
  290. "slice_right_2|snd|socket|socket|socket|socketpair|socketpair|sort|sound|" +
  291. "split|split_delim|sprintf|sprintf|sqrt|sqrt|sqrt_big_int|square_big_int|" +
  292. "square_num|sscanf|stable_sort|stable_sort|stable_sort|stable_sort|stable_sort|" +
  293. "stable_sort|stat|stat|stat|stat|stat|stats|stats|std_formatter|stdbuf|" +
  294. "stderr|stderr|stderr|stdib|stdin|stdin|stdin|stdout|stdout|stdout|" +
  295. "str_formatter|string|string_after|string_before|string_match|" +
  296. "string_of_big_int|string_of_bool|string_of_float|string_of_format|" +
  297. "string_of_inet_addr|string_of_inet_addr|string_of_int|string_of_num|" +
  298. "string_partial_match|string_tag|sub|sub|sub_big_int|sub_left|sub_num|" +
  299. "sub_right|subset|subset|substitute_first|substring|succ|succ|" +
  300. "succ|succ|succ_big_int|succ_num|symbol_end|symbol_end_pos|symbol_start|" +
  301. "symbol_start_pos|symlink|symlink|sync|synchronize|system|system|system|" +
  302. "tag|take|tan|tanh|tcdrain|tcdrain|tcflow|tcflow|tcflush|tcflush|" +
  303. "tcgetattr|tcgetattr|tcsendbreak|tcsendbreak|tcsetattr|tcsetattr|" +
  304. "temp_file|text_size|time|time|time|timed_read|timed_write|times|times|" +
  305. "tl|tl|tl|to_buffer|to_channel|to_float|to_hex|to_int|to_int32|to_list|" +
  306. "to_list|to_list|to_nativeint|to_string|to_string|to_string|to_string|" +
  307. "to_string|top|top|total_size|transfer|transp|truncate|truncate|truncate|" +
  308. "truncate|truncate|truncate|try_lock|umask|umask|uncapitalize|uncapitalize|" +
  309. "uncapitalize|union|union|unit_big_int|unlink|unlink|unlock|unmarshal|" +
  310. "unsafe_blit|unsafe_fill|unsafe_get|unsafe_get|unsafe_set|unsafe_set|" +
  311. "update|uppercase|uppercase|uppercase|uppercase|usage|utimes|utimes|wait|" +
  312. "wait|wait|wait|wait_next_event|wait_pid|wait_read|wait_signal|" +
  313. "wait_timed_read|wait_timed_write|wait_write|waitpid|white|" +
  314. "widen|window_id|word_size|wrap|wrap_abort|write|yellow|yield|zero|zero_big_int|" +
  315. "Arg|Arith_status|Array|Array1|Array2|Array3|ArrayLabels|Big_int|Bigarray|" +
  316. "Buffer|Callback|CamlinternalOO|Char|Complex|Condition|Dbm|Digest|Dynlink|" +
  317. "Event|Filename|Format|Gc|Genarray|Genlex|Graphics|GraphicsX11|Hashtbl|" +
  318. "Int32|Int64|LargeFile|Lazy|Lexing|List|ListLabels|Make|Map|Marshal|" +
  319. "MoreLabels|Mutex|Nativeint|Num|Obj|Oo|Parsing|Pervasives|Printexc|" +
  320. "Printf|Queue|Random|Scanf|Scanning|Set|Sort|Stack|State|StdLabels|Str|" +
  321. "Stream|String|StringLabels|Sys|Thread|ThreadUnix|Tk|Unix|UnixLabels|Weak"
  322. ).split("|"));
  323. var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))";
  324. var octInteger = "(?:0[oO]?[0-7]+)";
  325. var hexInteger = "(?:0[xX][\\dA-Fa-f]+)";
  326. var binInteger = "(?:0[bB][01]+)";
  327. var integer = "(?:" + decimalInteger + "|" + octInteger + "|" + hexInteger + "|" + binInteger + ")";
  328. var exponent = "(?:[eE][+-]?\\d+)";
  329. var fraction = "(?:\\.\\d+)";
  330. var intPart = "(?:\\d+)";
  331. var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
  332. var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + exponent + ")";
  333. var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")";
  334. this.$rules = {
  335. "start" : [
  336. {
  337. token : "comment",
  338. regex : '\\(\\*.*?\\*\\)\\s*?$'
  339. },
  340. {
  341. token : "comment",
  342. merge : true,
  343. regex : '\\(\\*.*',
  344. next : "comment"
  345. },
  346. {
  347. token : "string", // single line
  348. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  349. },
  350. {
  351. token : "string", // single char
  352. regex : "'.'"
  353. },
  354. {
  355. token : "string", // " string
  356. merge : true,
  357. regex : '"',
  358. next : "qstring"
  359. },
  360. {
  361. token : "constant.numeric", // imaginary
  362. regex : "(?:" + floatNumber + "|\\d+)[jJ]\\b"
  363. },
  364. {
  365. token : "constant.numeric", // float
  366. regex : floatNumber
  367. },
  368. {
  369. token : "constant.numeric", // integer
  370. regex : integer + "\\b"
  371. },
  372. {
  373. token : function(value) {
  374. if (keywords.hasOwnProperty(value))
  375. return "keyword";
  376. else if (builtinConstants.hasOwnProperty(value))
  377. return "constant.language";
  378. else if (builtinFunctions.hasOwnProperty(value))
  379. return "support.function";
  380. else
  381. return "identifier";
  382. },
  383. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  384. },
  385. {
  386. token : "keyword.operator",
  387. regex : "\\+\\.|\\-\\.|\\*\\.|\\/\\.|#|;;|\\+|\\-|\\*|\\*\\*\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|<-|="
  388. },
  389. {
  390. token : "paren.lparen",
  391. regex : "[[({]"
  392. },
  393. {
  394. token : "paren.rparen",
  395. regex : "[\\])}]"
  396. },
  397. {
  398. token : "text",
  399. regex : "\\s+"
  400. }
  401. ],
  402. "comment" : [
  403. {
  404. token : "comment", // closing comment
  405. regex : ".*?\\*\\)",
  406. next : "start"
  407. },
  408. {
  409. token : "comment", // comment spanning whole line
  410. merge : true,
  411. regex : ".+"
  412. }
  413. ],
  414. "qstring" : [
  415. {
  416. token : "string",
  417. regex : '"',
  418. next : "start"
  419. }, {
  420. token : "string",
  421. merge : true,
  422. regex : '.+'
  423. }
  424. ]
  425. };
  426. };
  427. oop.inherits(OcamlHighlightRules, TextHighlightRules);
  428. exports.OcamlHighlightRules = OcamlHighlightRules;
  429. });
  430. /* ***** BEGIN LICENSE BLOCK *****
  431. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  432. *
  433. * The contents of this file are subject to the Mozilla Public License Version
  434. * 1.1 (the "License"); you may not use this file except in compliance with
  435. * the License. You may obtain a copy of the License at
  436. * http://www.mozilla.org/MPL/
  437. *
  438. * Software distributed under the License is distributed on an "AS IS" basis,
  439. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  440. * for the specific language governing rights and limitations under the
  441. * License.
  442. *
  443. * The Original Code is Ajax.org Code Editor (ACE).
  444. *
  445. * The Initial Developer of the Original Code is
  446. * Ajax.org B.V.
  447. * Portions created by the Initial Developer are Copyright (C) 2010
  448. * the Initial Developer. All Rights Reserved.
  449. *
  450. * Contributor(s):
  451. * Fabian Jakobs <fabian AT ajax DOT org>
  452. *
  453. * Alternatively, the contents of this file may be used under the terms of
  454. * either the GNU General Public License Version 2 or later (the "GPL"), or
  455. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  456. * in which case the provisions of the GPL or the LGPL are applicable instead
  457. * of those above. If you wish to allow use of your version of this file only
  458. * under the terms of either the GPL or the LGPL, and not to allow others to
  459. * use your version of this file under the terms of the MPL, indicate your
  460. * decision by deleting the provisions above and replace them with the notice
  461. * and other provisions required by the GPL or the LGPL. If you do not delete
  462. * the provisions above, a recipient may use your version of this file under
  463. * the terms of any one of the MPL, the GPL or the LGPL.
  464. *
  465. * ***** END LICENSE BLOCK ***** */
  466. define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
  467. "use strict";
  468. var Range = require("../range").Range;
  469. var MatchingBraceOutdent = function() {};
  470. (function() {
  471. this.checkOutdent = function(line, input) {
  472. if (! /^\s+$/.test(line))
  473. return false;
  474. return /^\s*\}/.test(input);
  475. };
  476. this.autoOutdent = function(doc, row) {
  477. var line = doc.getLine(row);
  478. var match = line.match(/^(\s*\})/);
  479. if (!match) return 0;
  480. var column = match[1].length;
  481. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  482. if (!openBracePos || openBracePos.row == row) return 0;
  483. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  484. doc.replace(new Range(row, 0, row, column-1), indent);
  485. };
  486. this.$getIndent = function(line) {
  487. var match = line.match(/^(\s+)/);
  488. if (match) {
  489. return match[1];
  490. }
  491. return "";
  492. };
  493. }).call(MatchingBraceOutdent.prototype);
  494. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  495. });