Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1/*2Language: Ruby3Description: Ruby is a dynamic, open source programming language with a focus on simplicity and productivity.4Website: https://www.ruby-lang.org/5Author: Anton Kovalyov <anton@kovalyov.net>6Contributors: Peter Leonov <gojpeg@yandex.ru>, Vasily Polovnyov <vast@whiteants.net>, Loren Segal <lsegal@soen.ca>, Pascal Hurni <phi@ruby-reactive.org>, Cedric Sohrauer <sohrauer@googlemail.com>7Category: common, scripting8*/9 10function ruby(hljs) {11 const regex = hljs.regex;12 const RUBY_METHOD_RE = '([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)';13 // TODO: move concepts like CAMEL_CASE into `modes.js`14 const CLASS_NAME_RE = regex.either(15 /\b([A-Z]+[a-z0-9]+)+/,16 // ends in caps17 /\b([A-Z]+[a-z0-9]+)+[A-Z]+/,18 )19 ;20 const CLASS_NAME_WITH_NAMESPACE_RE = regex.concat(CLASS_NAME_RE, /(::\w+)*/);21 // very popular ruby built-ins that one might even assume22 // are actual keywords (despite that not being the case)23 const PSEUDO_KWS = [24 "include",25 "extend",26 "prepend",27 "public",28 "private",29 "protected",30 "raise",31 "throw"32 ];33 const RUBY_KEYWORDS = {34 "variable.constant": [35 "__FILE__",36 "__LINE__",37 "__ENCODING__"38 ],39 "variable.language": [40 "self",41 "super",42 ],43 keyword: [44 "alias",45 "and",46 "begin",47 "BEGIN",48 "break",49 "case",50 "class",51 "defined",52 "do",53 "else",54 "elsif",55 "end",56 "END",57 "ensure",58 "for",59 "if",60 "in",61 "module",62 "next",63 "not",64 "or",65 "redo",66 "require",67 "rescue",68 "retry",69 "return",70 "then",71 "undef",72 "unless",73 "until",74 "when",75 "while",76 "yield",77 ...PSEUDO_KWS78 ],79 built_in: [80 "proc",81 "lambda",82 "attr_accessor",83 "attr_reader",84 "attr_writer",85 "define_method",86 "private_constant",87 "module_function"88 ],89 literal: [90 "true",91 "false",92 "nil"93 ]94 };95 const YARDOCTAG = {96 className: 'doctag',97 begin: '@[A-Za-z]+'98 };99 const IRB_OBJECT = {100 begin: '#<',101 end: '>'102 };103 const COMMENT_MODES = [104 hljs.COMMENT(105 '#',106 '$',107 { contains: [ YARDOCTAG ] }108 ),109 hljs.COMMENT(110 '^=begin',111 '^=end',112 {113 contains: [ YARDOCTAG ],114 relevance: 10115 }116 ),117 hljs.COMMENT('^__END__', hljs.MATCH_NOTHING_RE)118 ];119 const SUBST = {120 className: 'subst',121 begin: /#\{/,122 end: /\}/,123 keywords: RUBY_KEYWORDS124 };125 const STRING = {126 className: 'string',127 contains: [128 hljs.BACKSLASH_ESCAPE,129 SUBST130 ],131 variants: [132 {133 begin: /'/,134 end: /'/135 },136 {137 begin: /"/,138 end: /"/139 },140 {141 begin: /`/,142 end: /`/143 },144 {145 begin: /%[qQwWx]?\(/,146 end: /\)/147 },148 {149 begin: /%[qQwWx]?\[/,150 end: /\]/151 },152 {153 begin: /%[qQwWx]?\{/,154 end: /\}/155 },156 {157 begin: /%[qQwWx]?</,158 end: />/159 },160 {161 begin: /%[qQwWx]?\//,162 end: /\//163 },164 {165 begin: /%[qQwWx]?%/,166 end: /%/167 },168 {169 begin: /%[qQwWx]?-/,170 end: /-/171 },172 {173 begin: /%[qQwWx]?\|/,174 end: /\|/175 },176 // in the following expressions, \B in the beginning suppresses recognition of ?-sequences177 // where ? is the last character of a preceding identifier, as in: `func?4`178 { begin: /\B\?(\\\d{1,3})/ },179 { begin: /\B\?(\\x[A-Fa-f0-9]{1,2})/ },180 { begin: /\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/ },181 { begin: /\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/ },182 { begin: /\B\?\\(c|C-)[\x20-\x7e]/ },183 { begin: /\B\?\\?\S/ },184 // heredocs185 {186 // this guard makes sure that we have an entire heredoc and not a false187 // positive (auto-detect, etc.)188 begin: regex.concat(189 /<<[-~]?'?/,190 regex.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)191 ),192 contains: [193 hljs.END_SAME_AS_BEGIN({194 begin: /(\w+)/,195 end: /(\w+)/,196 contains: [197 hljs.BACKSLASH_ESCAPE,198 SUBST199 ]200 })201 ]202 }203 ]204 };205 206 // Ruby syntax is underdocumented, but this grammar seems to be accurate207 // as of version 2.7.2 (confirmed with (irb and `Ripper.sexp(...)`)208 // https://docs.ruby-lang.org/en/2.7.0/doc/syntax/literals_rdoc.html#label-Numbers209 const decimal = '[1-9](_?[0-9])*|0';210 const digits = '[0-9](_?[0-9])*';211 const NUMBER = {212 className: 'number',213 relevance: 0,214 variants: [215 // decimal integer/float, optionally exponential or rational, optionally imaginary216 { begin: `\\b(${decimal})(\\.(${digits}))?([eE][+-]?(${digits})|r)?i?\\b` },217 218 // explicit decimal/binary/octal/hexadecimal integer,219 // optionally rational and/or imaginary220 { begin: "\\b0[dD][0-9](_?[0-9])*r?i?\\b" },221 { begin: "\\b0[bB][0-1](_?[0-1])*r?i?\\b" },222 { begin: "\\b0[oO][0-7](_?[0-7])*r?i?\\b" },223 { begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b" },224 225 // 0-prefixed implicit octal integer, optionally rational and/or imaginary226 { begin: "\\b0(_?[0-7])+r?i?\\b" }227 ]228 };229 230 const PARAMS = {231 variants: [232 {233 match: /\(\)/,234 },235 {236 className: 'params',237 begin: /\(/,238 end: /(?=\))/,239 excludeBegin: true,240 endsParent: true,241 keywords: RUBY_KEYWORDS,242 }243 ]244 };245 246 const INCLUDE_EXTEND = {247 match: [248 /(include|extend)\s+/,249 CLASS_NAME_WITH_NAMESPACE_RE250 ],251 scope: {252 2: "title.class"253 },254 keywords: RUBY_KEYWORDS255 };256 257 const CLASS_DEFINITION = {258 variants: [259 {260 match: [261 /class\s+/,262 CLASS_NAME_WITH_NAMESPACE_RE,263 /\s+<\s+/,264 CLASS_NAME_WITH_NAMESPACE_RE265 ]266 },267 {268 match: [269 /\b(class|module)\s+/,270 CLASS_NAME_WITH_NAMESPACE_RE271 ]272 }273 ],274 scope: {275 2: "title.class",276 4: "title.class.inherited"277 },278 keywords: RUBY_KEYWORDS279 };280 281 const UPPER_CASE_CONSTANT = {282 relevance: 0,283 match: /\b[A-Z][A-Z_0-9]+\b/,284 className: "variable.constant"285 };286 287 const METHOD_DEFINITION = {288 match: [289 /def/, /\s+/,290 RUBY_METHOD_RE291 ],292 scope: {293 1: "keyword",294 3: "title.function"295 },296 contains: [297 PARAMS298 ]299 };300 301 const OBJECT_CREATION = {302 relevance: 0,303 match: [304 CLASS_NAME_WITH_NAMESPACE_RE,305 /\.new[. (]/306 ],307 scope: {308 1: "title.class"309 }310 };311 312 // CamelCase313 const CLASS_REFERENCE = {314 relevance: 0,315 match: CLASS_NAME_RE,316 scope: "title.class"317 };318 319 const RUBY_DEFAULT_CONTAINS = [320 STRING,321 CLASS_DEFINITION,322 INCLUDE_EXTEND,323 OBJECT_CREATION,324 UPPER_CASE_CONSTANT,325 CLASS_REFERENCE,326 METHOD_DEFINITION,327 {328 // swallow namespace qualifiers before symbols329 begin: hljs.IDENT_RE + '::' },330 {331 className: 'symbol',332 begin: hljs.UNDERSCORE_IDENT_RE + '(!|\\?)?:',333 relevance: 0334 },335 {336 className: 'symbol',337 begin: ':(?!\\s)',338 contains: [339 STRING,340 { begin: RUBY_METHOD_RE }341 ],342 relevance: 0343 },344 NUMBER,345 {346 // negative-look forward attempts to prevent false matches like:347 // @ident@ or $ident$ that might indicate this is not ruby at all348 className: "variable",349 begin: '(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])' + `(?![A-Za-z])(?![@$?'])`350 },351 {352 className: 'params',353 begin: /\|(?!=)/,354 end: /\|/,355 excludeBegin: true,356 excludeEnd: true,357 relevance: 0, // this could be a lot of things (in other languages) other than params358 keywords: RUBY_KEYWORDS359 },360 { // regexp container361 begin: '(' + hljs.RE_STARTERS_RE + '|unless)\\s*',362 keywords: 'unless',363 contains: [364 {365 className: 'regexp',366 contains: [367 hljs.BACKSLASH_ESCAPE,368 SUBST369 ],370 illegal: /\n/,371 variants: [372 {373 begin: '/',374 end: '/[a-z]*'375 },376 {377 begin: /%r\{/,378 end: /\}[a-z]*/379 },380 {381 begin: '%r\\(',382 end: '\\)[a-z]*'383 },384 {385 begin: '%r!',386 end: '![a-z]*'387 },388 {389 begin: '%r\\[',390 end: '\\][a-z]*'391 }392 ]393 }394 ].concat(IRB_OBJECT, COMMENT_MODES),395 relevance: 0396 }397 ].concat(IRB_OBJECT, COMMENT_MODES);398 399 SUBST.contains = RUBY_DEFAULT_CONTAINS;400 PARAMS.contains = RUBY_DEFAULT_CONTAINS;401 402 // >>403 // ?>404 const SIMPLE_PROMPT = "[>?]>";405 // irb(main):001:0>406 const DEFAULT_PROMPT = "[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]";407 const RVM_PROMPT = "(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>";408 409 const IRB_DEFAULT = [410 {411 begin: /^\s*=>/,412 starts: {413 end: '$',414 contains: RUBY_DEFAULT_CONTAINS415 }416 },417 {418 className: 'meta.prompt',419 begin: '^(' + SIMPLE_PROMPT + "|" + DEFAULT_PROMPT + '|' + RVM_PROMPT + ')(?=[ ])',420 starts: {421 end: '$',422 keywords: RUBY_KEYWORDS,423 contains: RUBY_DEFAULT_CONTAINS424 }425 }426 ];427 428 COMMENT_MODES.unshift(IRB_OBJECT);429 430 return {431 name: 'Ruby',432 aliases: [433 'rb',434 'gemspec',435 'podspec',436 'thor',437 'irb'438 ],439 keywords: RUBY_KEYWORDS,440 illegal: /\/\*/,441 contains: [ hljs.SHEBANG({ binary: "ruby" }) ]442 .concat(IRB_DEFAULT)443 .concat(COMMENT_MODES)444 .concat(RUBY_DEFAULT_CONTAINS)445 };446}447 448module.exports = ruby;449 