mode-ocaml.js 21 KB

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