082d72cee51411d39d52d3f0e06eca3b.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. ace.define("ace/mode/raku_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  2. var oop = require("../lib/oop");
  3. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4. var RakuHighlightRules = function () {
  5. var keywords = ("my|our|class|role|grammar|is|does|sub|method|submethod|try|" +
  6. "default|when|if|elsif|else|unless|with|orwith|without|for|given|proceed|" +
  7. "succeed|loop|while|until|repeat|module|use|need|import|require|unit|" +
  8. "constant|enum|multi|return|has|token|rule|make|made|proto|state|augment|" +
  9. "but|anon|supersede|let|subset|gather|returns|return-rw|temp|" +
  10. "BEGIN|CHECK|INIT|END|CLOSE|ENTER|LEAVE|KEEP|UNDO|PRE|POST|FIRST|NEXT|LAST|CATCH|CONTROL|QUIT|DOC");
  11. var types = ("Any|Array|Associative|AST|atomicint|Attribute|Backtrace|Backtrace::Frame|" +
  12. "Bag|Baggy|BagHash|Blob|Block|Bool|Buf|Callable|CallFrame|Cancellation|" +
  13. "Capture|Channel|Code|compiler|Complex|ComplexStr|Cool|CurrentThreadScheduler|" +
  14. "Cursor|Date|Dateish|DateTime|Distro|Duration|Encoding|Exception|Failure|" +
  15. "FatRat|Grammar|Hash|HyperWhatever|Instant|Int|IntStr|IO|IO::ArgFiles|" +
  16. "IO::CatHandle|IO::Handle|IO::Notification|IO::Path|IO::Path::Cygwin|" +
  17. "IO::Path::QNX|IO::Path::Unix|IO::Path::Win32|IO::Pipe|IO::Socket|" +
  18. "IO::Socket::Async|IO::Socket::INET|IO::Spec|IO::Spec::Cygwin|IO::Spec::QNX|" +
  19. "IO::Spec::Unix|IO::Spec::Win32|IO::Special|Iterable|Iterator|Junction|Kernel|" +
  20. "Label|List|Lock|Lock::Async|Macro|Map|Match|Metamodel::AttributeContainer|" +
  21. "Metamodel::C3MRO|Metamodel::ClassHOW|Metamodel::EnumHOW|Metamodel::Finalization|" +
  22. "Metamodel::MethodContainer|Metamodel::MROBasedMethodDispatch|Metamodel::MultipleInheritance|" +
  23. "Metamodel::Naming|Metamodel::Primitives|Metamodel::PrivateMethodContainer|" +
  24. "Metamodel::RoleContainer|Metamodel::Trusting|Method|Mix|MixHash|Mixy|Mu|" +
  25. "NFC|NFD|NFKC|NFKD|Nil|Num|Numeric|NumStr|ObjAt|Order|Pair|Parameter|Perl|" +
  26. "Pod::Block|Pod::Block::Code|Pod::Block::Comment|Pod::Block::Declarator|" +
  27. "Pod::Block::Named|Pod::Block::Para|Pod::Block::Table|Pod::Heading|Pod::Item|" +
  28. "Positional|PositionalBindFailover|Proc|Proc::Async|Promise|Proxy|PseudoStash|" +
  29. "Raku|QuantHash|Range|Rat|Rational|RatStr|Real|Regex|Routine|Scalar|Scheduler|" +
  30. "Semaphore|Seq|Set|SetHash|Setty|Signature|Slip|Stash|Str|StrDistance|Stringy|" +
  31. "Sub|Submethod|Supplier|Supplier::Preserving|Supply|Systemic|Tap|Telemetry|" +
  32. "Telemetry::Instrument::Thread|Telemetry::Instrument::Usage|Telemetry::Period|" +
  33. "Telemetry::Sampler|Thread|ThreadPoolScheduler|UInt|Uni|utf8|Variable|Version|" +
  34. "VM|Whatever|WhateverCode|WrapHandle|int|uint|num|str|" +
  35. "int8|int16|int32|int64|uint8|uint16|uint32|uint64|long|longlong|num32|num64|size_t|bool|CArray|Pointer|" +
  36. "Backtrace|Backtrace::Frame|Exception|Failure|X::AdHoc|X::Anon::Augment|X::Anon::Multi|" +
  37. "X::Assignment::RO|X::Attribute::NoPackage|X::Attribute::Package|X::Attribute::Undeclared|" +
  38. "X::Augment::NoSuchType|X::Bind|X::Bind::NativeType|X::Bind::Slice|X::Caller::NotDynamic|" +
  39. "X::Channel::ReceiveOnClosed|X::Channel::SendOnClosed|X::Comp|X::Composition::NotComposable|" +
  40. "X::Constructor::Positional|X::ControlFlow|X::ControlFlow::Return|X::DateTime::TimezoneClash|" +
  41. "X::Declaration::Scope|X::Declaration::Scope::Multi|X::Does::TypeObject|X::Eval::NoSuchLang|" +
  42. "X::Export::NameClash|X::IO|X::IO::Chdir|X::IO::Chmod|X::IO::Copy|X::IO::Cwd|X::IO::Dir|" +
  43. "X::IO::DoesNotExist|X::IO::Link|X::IO::Mkdir|X::IO::Move|X::IO::Rename|X::IO::Rmdir|X::IO::Symlink|" +
  44. "X::IO::Unlink|X::Inheritance::NotComposed|X::Inheritance::Unsupported|X::Method::InvalidQualifier|" +
  45. "X::Method::NotFound|X::Method::Private::Permission|X::Method::Private::Unqualified|" +
  46. "X::Mixin::NotComposable|X::NYI|X::NoDispatcher|X::Numeric::Real|X::OS|X::Obsolete|X::OutOfRange|" +
  47. "X::Package::Stubbed|X::Parameter::Default|X::Parameter::MultipleTypeConstraints|" +
  48. "X::Parameter::Placeholder|X::Parameter::Twigil|X::Parameter::WrongOrder|X::Phaser::Multiple|" +
  49. "X::Phaser::PrePost|X::Placeholder::Block|X::Placeholder::Mainline|X::Pod|X::Proc::Async|" +
  50. "X::Proc::Async::AlreadyStarted|X::Proc::Async::CharsOrBytes|X::Proc::Async::MustBeStarted|" +
  51. "X::Proc::Async::OpenForWriting|X::Proc::Async::TapBeforeSpawn|X::Proc::Unsuccessful|" +
  52. "X::Promise::CauseOnlyValidOnBroken|X::Promise::Vowed|X::Redeclaration|X::Role::Initialization|" +
  53. "X::Seq::Consumed|X::Sequence::Deduction|X::Signature::NameClash|X::Signature::Placeholder|" +
  54. "X::Str::Numeric|X::StubCode|X::Syntax|X::Syntax::Augment::WithoutMonkeyTyping|" +
  55. "X::Syntax::Comment::Embedded|X::Syntax::Confused|X::Syntax::InfixInTermPosition|" +
  56. "X::Syntax::Malformed|X::Syntax::Missing|X::Syntax::NegatedPair|X::Syntax::NoSelf|" +
  57. "X::Syntax::Number::RadixOutOfRange|X::Syntax::P5|X::Syntax::Regex::Adverb|" +
  58. "X::Syntax::Regex::SolitaryQuantifier|X::Syntax::Reserved|X::Syntax::Self::WithoutObject|" +
  59. "X::Syntax::Signature::InvocantMarker|X::Syntax::Term::MissingInitializer|X::Syntax::UnlessElse|" +
  60. "X::Syntax::Variable::Match|X::Syntax::Variable::Numeric|X::Syntax::Variable::Twigil|X::Temporal|" +
  61. "X::Temporal::InvalidFormat|X::TypeCheck|X::TypeCheck::Assignment|X::TypeCheck::Binding|" +
  62. "X::TypeCheck::Return|X::TypeCheck::Splice|X::Undeclared");
  63. var builtinFunctions = ("abs|abs2rel|absolute|accept|ACCEPTS|accessed|acos|acosec|acosech|acosh|" +
  64. "acotan|acotanh|acquire|act|action|actions|add|add_attribute|add_enum_value|" +
  65. "add_fallback|add_method|add_parent|add_private_method|add_role|add_trustee|" +
  66. "adverb|after|all|allocate|allof|allowed|alternative-names|annotations|antipair|" +
  67. "antipairs|any|anyof|app_lifetime|append|arch|archname|args|arity|asec|asech|" +
  68. "asin|asinh|ASSIGN-KEY|ASSIGN-POS|assuming|ast|at|atan|atan2|atanh|AT-KEY|" +
  69. "atomic-assign|atomic-dec-fetch|atomic-fetch|atomic-fetch-add|atomic-fetch-dec|" +
  70. "atomic-fetch-inc|atomic-fetch-sub|atomic-inc-fetch|AT-POS|attributes|auth|await|" +
  71. "backtrace|Bag|BagHash|base|basename|base-repeating|batch|BIND-KEY|BIND-POS|" +
  72. "bind-stderr|bind-stdin|bind-stdout|bind-udp|bits|bless|block|bool-only|" +
  73. "bounds|break|Bridge|broken|BUILD|build-date|bytes|cache|callframe|calling-package|" +
  74. "CALL-ME|callsame|callwith|can|cancel|candidates|cando|canonpath|caps|caption|" +
  75. "Capture|cas|catdir|categorize|categorize-list|catfile|catpath|cause|ceiling|" +
  76. "cglobal|changed|Channel|chars|chdir|child|child-name|child-typename|chmod|chomp|" +
  77. "chop|chr|chrs|chunks|cis|classify|classify-list|cleanup|clone|close|closed|" +
  78. "close-stdin|code|codes|collate|column|comb|combinations|command|comment|" +
  79. "compiler|Complex|compose|compose_type|composer|condition|config|configure_destroy|" +
  80. "configure_type_checking|conj|connect|constraints|construct|contains|contents|copy|" +
  81. "cos|cosec|cosech|cosh|cotan|cotanh|count|count-only|cpu-cores|cpu-usage|CREATE|" +
  82. "create_type|cross|cue|curdir|curupdir|d|Date|DateTime|day|daycount|day-of-month|" +
  83. "day-of-week|day-of-year|days-in-month|declaration|decode|decoder|deepmap|" +
  84. "defined|DEFINITE|delayed|DELETE-KEY|DELETE-POS|denominator|desc|DESTROY|destroyers|" +
  85. "devnull|did-you-mean|die|dir|dirname|dir-sep|DISTROnames|do|done|duckmap|dynamic|" +
  86. "e|eager|earlier|elems|emit|enclosing|encode|encoder|encoding|end|ends-with|enum_from_value|" +
  87. "enum_value_list|enum_values|enums|eof|EVAL|EVALFILE|exception|excludes-max|excludes-min|" +
  88. "EXISTS-KEY|EXISTS-POS|exit|exitcode|exp|expected|explicitly-manage|expmod|extension|f|" +
  89. "fail|fc|feature|file|filename|find_method|find_method_qualified|finish|first|flat|flatmap|" +
  90. "flip|floor|flush|fmt|format|formatter|freeze|from|from-list|from-loop|from-posix|full|" +
  91. "full-barrier|get|get_value|getc|gist|got|grab|grabpairs|grep|handle|handled|handles|" +
  92. "hardware|has_accessor|head|headers|hh-mm-ss|hidden|hides|hour|how|hyper|id|illegal|" +
  93. "im|in|indent|index|indices|indir|infinite|infix|install_method_cache|" +
  94. "Instant|instead|int-bounds|interval|in-timezone|invalid-str|invert|invocant|IO|" +
  95. "IO::Notification.watch-path|is_trusted|is_type|isa|is-absolute|is-hidden|is-initial-thread|" +
  96. "is-int|is-lazy|is-leap-year|isNaN|is-prime|is-relative|is-routine|is-setting|is-win|item|" +
  97. "iterator|join|keep|kept|KERNELnames|key|keyof|keys|kill|kv|kxxv|l|lang|last|lastcall|later|" +
  98. "lazy|lc|leading|level|line|lines|link|listen|live|local|lock|log|log10|lookup|lsb|" +
  99. "MAIN|match|max|maxpairs|merge|message|method_table|methods|migrate|min|minmax|" +
  100. "minpairs|minute|misplaced|Mix|MixHash|mkdir|mode|modified|month|move|mro|msb|multiness|" +
  101. "name|named|named_names|narrow|nativecast|native-descriptor|nativesizeof|new|new_type|" +
  102. "new-from-daycount|new-from-pairs|next|nextcallee|next-handle|nextsame|nextwith|NFC|NFD|" +
  103. "NFKC|NFKD|nl-in|nl-out|nodemap|none|norm|not|note|now|nude|numerator|Numeric|of|" +
  104. "offset|offset-in-hours|offset-in-minutes|old|on-close|one|on-switch|open|opened|" +
  105. "operation|optional|ord|ords|orig|os-error|osname|out-buffer|pack|package|package-kind|" +
  106. "package-name|packages|pair|pairs|pairup|parameter|params|parent|parent-name|parents|parse|" +
  107. "parse-base|parsefile|parse-names|parts|path|path-sep|payload|peer-host|peer-port|periods|" +
  108. "perl|permutations|phaser|pick|pickpairs|pid|placeholder|plus|polar|poll|polymod|pop|pos|" +
  109. "positional|posix|postfix|postmatch|precomp-ext|precomp-target|pred|prefix|prematch|prepend|" +
  110. "print|printf|print-nl|print-to|private|private_method_table|proc|produce|Promise|prompt|" +
  111. "protect|pull-one|push|push-all|push-at-least|push-exactly|push-until-lazy|put|" +
  112. "qualifier-type|quit|r|race|radix|raku|rand|range|raw|re|read|readchars|readonly|" +
  113. "ready|Real|reallocate|reals|reason|rebless|receive|recv|redispatcher|redo|reduce|" +
  114. "rel2abs|relative|release|rename|repeated|replacement|report|reserved|resolve|" +
  115. "restore|result|resume|rethrow|reverse|right|rindex|rmdir|roles_to_compose|" +
  116. "rolish|roll|rootdir|roots|rotate|rotor|round|roundrobin|routine-type|run|rwx|s|" +
  117. "samecase|samemark|samewith|say|schedule-on|scheduler|scope|sec|sech|second|seek|" +
  118. "self|send|Set|set_hidden|set_name|set_package|set_rw|set_value|SetHash|" +
  119. "set-instruments|setup_finalization|shape|share|shell|shift|sibling|sigil|" +
  120. "sign|signal|signals|signature|sin|sinh|sink|sink-all|skip|skip-at-least|" +
  121. "skip-at-least-pull-one|skip-one|sleep|sleep-timer|sleep-until|Slip|slurp|" +
  122. "slurp-rest|slurpy|snap|snapper|so|socket-host|socket-port|sort|source|" +
  123. "source-package|spawn|SPEC|splice|split|splitdir|splitpath|sprintf|spurt|" +
  124. "sqrt|squish|srand|stable|start|started|starts-with|status|stderr|stdout|" +
  125. "sub_signature|subbuf|subbuf-rw|subname|subparse|subst|subst-mutate|" +
  126. "substr|substr-eq|substr-rw|succ|sum|Supply|symlink|t|tail|take|take-rw|" +
  127. "tan|tanh|tap|target|target-name|tc|tclc|tell|then|throttle|throw|timezone|" +
  128. "tmpdir|to|today|toggle|to-posix|total|trailing|trans|tree|trim|trim-leading|" +
  129. "trim-trailing|truncate|truncated-to|trusts|try_acquire|trying|twigil|type|" +
  130. "type_captures|typename|uc|udp|uncaught_handler|unimatch|uniname|uninames|" +
  131. "uniparse|uniprop|uniprops|unique|unival|univals|unlink|unlock|unpack|unpolar|" +
  132. "unshift|unwrap|updir|USAGE|utc|val|value|values|VAR|variable|verbose-config|" +
  133. "version|VMnames|volume|vow|w|wait|warn|watch|watch-path|week|weekday-of-month|" +
  134. "week-number|week-year|WHAT|WHERE|WHEREFORE|WHICH|WHO|whole-second|WHY|" +
  135. "wordcase|words|workaround|wrap|write|write-to|yada|year|yield|yyyy-mm-dd|" +
  136. "z|zip|zip-latest|" +
  137. "plan|done-testing|bail-out|todo|skip|skip-rest|diag|subtest|pass|flunk|ok|" +
  138. "nok|cmp-ok|is-deeply|isnt|is-approx|like|unlike|use-ok|isa-ok|does-ok|" +
  139. "can-ok|dies-ok|lives-ok|eval-dies-ok|eval-lives-ok|throws-like|fails-like|" +
  140. "rw|required|native|repr|export|symbol");
  141. var constants_ascii = ("pi|Inf|tau|time");
  142. var ops_txt = ("eq|ne|gt|lt|le|ge|div|gcd|lcm|leg|cmp|ff|fff|" +
  143. "x|before|after|Z|X|and|or|andthen|notandthen|orelse|xor");
  144. var keywordMapper = this.createKeywordMapper({
  145. "keyword": keywords,
  146. "storage.type": types,
  147. "constant.language": constants_ascii,
  148. "support.function": builtinFunctions,
  149. "keyword.operator": ops_txt
  150. }, "identifier");
  151. var moduleName = "[a-zA-Z_][a-zA-Z_0-9:-]*\\b";
  152. var hex = { token: "constant.numeric", regex: "0x[0-9a-fA-F]+\\b" };
  153. var num_rat = { token: "constant.numeric", regex: "[+-.]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" };
  154. var num_with_ = { token: "constant.numeric", regex: "(?:\\d+_?\\d+)+\\b" };
  155. var complex_numbers = { token: "constant.numeric", regex: "\\+?\\d+i\\b" };
  156. var booleans = { token: "constant.language.boolean", regex: "(?:True|False)\\b" };
  157. var versions = { token: "constant.other", regex: "v[0-9](?:\\.[a-zA-Z0-9*])*\\b" };
  158. var lang_keywords = { token: keywordMapper, regex: "[a-zA-Z][\\:a-zA-Z0-9_-]*\\b" };
  159. var variables = { token: "variable.language", regex: "[$@%&][?*!.]?[a-zA-Z0-9_-]+\\b" };
  160. var vars_special = { token: "variable.language", regex: "\\$[/|!]?|@\\$/" };
  161. var ops_char = { token: "keyword.operator", regex: "=|<|>|\\+|\\*|-|/|~|%|\\?|!|\\^|\\.|\\:|\\,|" +
  162. "»|«|\\||\\&|⚛|∘" };
  163. var constants_unicode = { token: "constant.language", regex: "𝑒|π|τ|∞" };
  164. var qstrings = { token: "string.quoted.single", regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" };
  165. var word_quoting = { token: "string.quoted.single", regex: "[<](?:[a-zA-Z0-9 ])*[>]" };
  166. var regexp = {
  167. token: "string.regexp",
  168. regex: "[m|rx]?[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
  169. };
  170. this.$rules = {
  171. "start": [
  172. {
  173. token: "comment.block",
  174. regex: "#[`|=]\\(.*\\)"
  175. }, {
  176. token: "comment.block",
  177. regex: "#[`|=]\\[.*\\]"
  178. }, {
  179. token: "comment.doc",
  180. regex: "^=(?:begin)\\b",
  181. next: "block_comment"
  182. }, {
  183. token: "string.unquoted",
  184. regex: "q[x|w]?\\:to/END/;",
  185. next: "qheredoc"
  186. }, {
  187. token: "string.unquoted",
  188. regex: "qq[x|w]?\\:to/END/;",
  189. next: "qqheredoc"
  190. },
  191. regexp,
  192. qstrings,
  193. {
  194. token: "string.quoted.double",
  195. regex: '"',
  196. next: "qqstring"
  197. },
  198. word_quoting,
  199. {
  200. token: ["keyword", "text", "variable.module"],
  201. regex: "(use)(\\s+)((?:" + moduleName + "\\.?)*)"
  202. },
  203. hex,
  204. num_rat,
  205. num_with_,
  206. complex_numbers,
  207. booleans,
  208. versions,
  209. lang_keywords,
  210. variables,
  211. vars_special,
  212. ops_char,
  213. constants_unicode,
  214. {
  215. token: "comment",
  216. regex: "#.*$"
  217. }, {
  218. token: "lparen",
  219. regex: "[[({]"
  220. }, {
  221. token: "rparen",
  222. regex: "[\\])}]"
  223. }, {
  224. token: "text",
  225. regex: "\\s+"
  226. }
  227. ],
  228. "qqstring": [
  229. {
  230. token: "constant.language.escape",
  231. regex: '\\\\(?:[nrtef\\\\"$]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})'
  232. },
  233. variables,
  234. vars_special,
  235. {
  236. token: "lparen",
  237. regex: "{",
  238. next: "qqinterpolation"
  239. }, {
  240. token: "string.quoted.double",
  241. regex: '"',
  242. next: "start"
  243. }, {
  244. defaultToken: "string.quoted.double"
  245. }
  246. ],
  247. "qqinterpolation": [
  248. hex,
  249. num_rat,
  250. num_with_,
  251. complex_numbers,
  252. booleans,
  253. versions,
  254. lang_keywords,
  255. variables,
  256. vars_special,
  257. ops_char,
  258. constants_unicode,
  259. qstrings,
  260. regexp,
  261. {
  262. token: "rparen",
  263. regex: "}",
  264. next: "qqstring"
  265. }
  266. ],
  267. "block_comment": [
  268. {
  269. token: "comment.doc",
  270. regex: "^=end +[a-zA-Z_0-9]*",
  271. next: "start"
  272. },
  273. {
  274. defaultToken: "comment.doc"
  275. }
  276. ],
  277. "qheredoc": [
  278. {
  279. token: "string.unquoted",
  280. regex: "END$",
  281. next: "start"
  282. }, {
  283. defaultToken: "string.unquoted"
  284. }
  285. ],
  286. "qqheredoc": [
  287. variables,
  288. vars_special,
  289. {
  290. token: "lparen",
  291. regex: "{",
  292. next: "qqheredocinterpolation"
  293. }, {
  294. token: "string.unquoted",
  295. regex: "END$",
  296. next: "start"
  297. }, {
  298. defaultToken: "string.unquoted"
  299. }
  300. ],
  301. "qqheredocinterpolation": [
  302. hex,
  303. num_rat,
  304. num_with_,
  305. complex_numbers,
  306. booleans,
  307. versions,
  308. lang_keywords,
  309. variables,
  310. vars_special,
  311. ops_char,
  312. constants_unicode,
  313. qstrings,
  314. regexp,
  315. {
  316. token: "rparen",
  317. regex: "}",
  318. next: "qqheredoc"
  319. }
  320. ]
  321. };
  322. };
  323. oop.inherits(RakuHighlightRules, TextHighlightRules);
  324. exports.RakuHighlightRules = RakuHighlightRules;
  325. });
  326. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  327. var Range = require("../range").Range;
  328. var MatchingBraceOutdent = function () { };
  329. (function () {
  330. this.checkOutdent = function (line, input) {
  331. if (!/^\s+$/.test(line))
  332. return false;
  333. return /^\s*\}/.test(input);
  334. };
  335. this.autoOutdent = function (doc, row) {
  336. var line = doc.getLine(row);
  337. var match = line.match(/^(\s*\})/);
  338. if (!match)
  339. return 0;
  340. var column = match[1].length;
  341. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  342. if (!openBracePos || openBracePos.row == row)
  343. return 0;
  344. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  345. doc.replace(new Range(row, 0, row, column - 1), indent);
  346. };
  347. this.$getIndent = function (line) {
  348. return line.match(/^\s*/)[0];
  349. };
  350. }).call(MatchingBraceOutdent.prototype);
  351. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  352. });
  353. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
  354. var oop = require("../../lib/oop");
  355. var Range = require("../../range").Range;
  356. var BaseFoldMode = require("./fold_mode").FoldMode;
  357. var FoldMode = exports.FoldMode = function (commentRegex) {
  358. if (commentRegex) {
  359. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  360. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  361. }
  362. };
  363. oop.inherits(FoldMode, BaseFoldMode);
  364. (function () {
  365. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  366. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  367. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  368. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  369. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  370. this._getFoldWidgetBase = this.getFoldWidget;
  371. this.getFoldWidget = function (session, foldStyle, row) {
  372. var line = session.getLine(row);
  373. if (this.singleLineBlockCommentRe.test(line)) {
  374. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  375. return "";
  376. }
  377. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  378. if (!fw && this.startRegionRe.test(line))
  379. return "start"; // lineCommentRegionStart
  380. return fw;
  381. };
  382. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  383. var line = session.getLine(row);
  384. if (this.startRegionRe.test(line))
  385. return this.getCommentRegionBlock(session, line, row);
  386. var match = line.match(this.foldingStartMarker);
  387. if (match) {
  388. var i = match.index;
  389. if (match[1])
  390. return this.openingBracketBlock(session, match[1], row, i);
  391. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  392. if (range && !range.isMultiLine()) {
  393. if (forceMultiline) {
  394. range = this.getSectionRange(session, row);
  395. }
  396. else if (foldStyle != "all")
  397. range = null;
  398. }
  399. return range;
  400. }
  401. if (foldStyle === "markbegin")
  402. return;
  403. var match = line.match(this.foldingStopMarker);
  404. if (match) {
  405. var i = match.index + match[0].length;
  406. if (match[1])
  407. return this.closingBracketBlock(session, match[1], row, i);
  408. return session.getCommentFoldRange(row, i, -1);
  409. }
  410. };
  411. this.getSectionRange = function (session, row) {
  412. var line = session.getLine(row);
  413. var startIndent = line.search(/\S/);
  414. var startRow = row;
  415. var startColumn = line.length;
  416. row = row + 1;
  417. var endRow = row;
  418. var maxRow = session.getLength();
  419. while (++row < maxRow) {
  420. line = session.getLine(row);
  421. var indent = line.search(/\S/);
  422. if (indent === -1)
  423. continue;
  424. if (startIndent > indent)
  425. break;
  426. var subRange = this.getFoldWidgetRange(session, "all", row);
  427. if (subRange) {
  428. if (subRange.start.row <= startRow) {
  429. break;
  430. }
  431. else if (subRange.isMultiLine()) {
  432. row = subRange.end.row;
  433. }
  434. else if (startIndent == indent) {
  435. break;
  436. }
  437. }
  438. endRow = row;
  439. }
  440. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  441. };
  442. this.getCommentRegionBlock = function (session, line, row) {
  443. var startColumn = line.search(/\s*$/);
  444. var maxRow = session.getLength();
  445. var startRow = row;
  446. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  447. var depth = 1;
  448. while (++row < maxRow) {
  449. line = session.getLine(row);
  450. var m = re.exec(line);
  451. if (!m)
  452. continue;
  453. if (m[1])
  454. depth--;
  455. else
  456. depth++;
  457. if (!depth)
  458. break;
  459. }
  460. var endRow = row;
  461. if (endRow > startRow) {
  462. return new Range(startRow, startColumn, endRow, line.length);
  463. }
  464. };
  465. }).call(FoldMode.prototype);
  466. });
  467. ace.define("ace/mode/raku",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/raku_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  468. var oop = require("../lib/oop");
  469. var TextMode = require("./text").Mode;
  470. var RakuHighlightRules = require("./raku_highlight_rules").RakuHighlightRules;
  471. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  472. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  473. var Mode = function () {
  474. this.HighlightRules = RakuHighlightRules;
  475. this.$outdent = new MatchingBraceOutdent();
  476. this.foldingRules = new CStyleFoldMode({ start: "^=(begin)\\b", end: "^=(end)\\b" });
  477. this.$behaviour = this.$defaultBehaviour;
  478. };
  479. oop.inherits(Mode, TextMode);
  480. (function () {
  481. this.lineCommentStart = "#";
  482. this.blockComment = [
  483. { start: "=begin", end: "=end", lineStartOnly: true },
  484. { start: "=item", end: "=end", lineStartOnly: true }
  485. ];
  486. this.getNextLineIndent = function (state, line, tab) {
  487. var indent = this.$getIndent(line);
  488. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  489. var tokens = tokenizedLine.tokens;
  490. if (tokens.length && tokens[tokens.length - 1].type == "comment") {
  491. return indent;
  492. }
  493. if (state == "start") {
  494. var match = line.match(/^.*[\{\(\[:]\s*$/);
  495. if (match) {
  496. indent += tab;
  497. }
  498. }
  499. return indent;
  500. };
  501. this.checkOutdent = function (state, line, input) {
  502. return this.$outdent.checkOutdent(line, input);
  503. };
  504. this.autoOutdent = function (state, doc, row) {
  505. this.$outdent.autoOutdent(doc, row);
  506. };
  507. this.$id = "ace/mode/raku";
  508. }).call(Mode.prototype);
  509. exports.Mode = Mode;
  510. }); (function() {
  511. ace.require(["ace/mode/raku"], function(m) {
  512. if (typeof module == "object" && typeof exports == "object" && module) {
  513. module.exports = m;
  514. }
  515. });
  516. })();