mode-perl6.js 25 KB

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