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/*2 Language: SQL3 Website: https://en.wikipedia.org/wiki/SQL4 Category: common, database5 */6 7/*8 9Goals:10 11SQL is intended to highlight basic/common SQL keywords and expressions12 13- If pretty much every single SQL server includes supports, then it's a canidate.14- It is NOT intended to include tons of vendor specific keywords (Oracle, MySQL,15 PostgreSQL) although the list of data types is purposely a bit more expansive.16- For more specific SQL grammars please see:17 - PostgreSQL and PL/pgSQL - core18 - T-SQL - https://github.com/highlightjs/highlightjs-tsql19 - sql_more (core)20 21 */22 23function sql(hljs) {24 const regex = hljs.regex;25 const COMMENT_MODE = hljs.COMMENT('--', '$');26 const STRING = {27 scope: 'string',28 variants: [29 {30 begin: /'/,31 end: /'/,32 contains: [ { match: /''/ } ]33 }34 ]35 };36 const QUOTED_IDENTIFIER = {37 begin: /"/,38 end: /"/,39 contains: [ { match: /""/ } ]40 };41 42 const LITERALS = [43 "true",44 "false",45 // Not sure it's correct to call NULL literal, and clauses like IS [NOT] NULL look strange that way.46 // "null",47 "unknown"48 ];49 50 const MULTI_WORD_TYPES = [51 "double precision",52 "large object",53 "with timezone",54 "without timezone"55 ];56 57 const TYPES = [58 'bigint',59 'binary',60 'blob',61 'boolean',62 'char',63 'character',64 'clob',65 'date',66 'dec',67 'decfloat',68 'decimal',69 'float',70 'int',71 'integer',72 'interval',73 'nchar',74 'nclob',75 'national',76 'numeric',77 'real',78 'row',79 'smallint',80 'time',81 'timestamp',82 'varchar',83 'varying', // modifier (character varying)84 'varbinary'85 ];86 87 const NON_RESERVED_WORDS = [88 "add",89 "asc",90 "collation",91 "desc",92 "final",93 "first",94 "last",95 "view"96 ];97 98 // https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#reserved-word99 const RESERVED_WORDS = [100 "abs",101 "acos",102 "all",103 "allocate",104 "alter",105 "and",106 "any",107 "are",108 "array",109 "array_agg",110 "array_max_cardinality",111 "as",112 "asensitive",113 "asin",114 "asymmetric",115 "at",116 "atan",117 "atomic",118 "authorization",119 "avg",120 "begin",121 "begin_frame",122 "begin_partition",123 "between",124 "bigint",125 "binary",126 "blob",127 "boolean",128 "both",129 "by",130 "call",131 "called",132 "cardinality",133 "cascaded",134 "case",135 "cast",136 "ceil",137 "ceiling",138 "char",139 "char_length",140 "character",141 "character_length",142 "check",143 "classifier",144 "clob",145 "close",146 "coalesce",147 "collate",148 "collect",149 "column",150 "commit",151 "condition",152 "connect",153 "constraint",154 "contains",155 "convert",156 "copy",157 "corr",158 "corresponding",159 "cos",160 "cosh",161 "count",162 "covar_pop",163 "covar_samp",164 "create",165 "cross",166 "cube",167 "cume_dist",168 "current",169 "current_catalog",170 "current_date",171 "current_default_transform_group",172 "current_path",173 "current_role",174 "current_row",175 "current_schema",176 "current_time",177 "current_timestamp",178 "current_path",179 "current_role",180 "current_transform_group_for_type",181 "current_user",182 "cursor",183 "cycle",184 "date",185 "day",186 "deallocate",187 "dec",188 "decimal",189 "decfloat",190 "declare",191 "default",192 "define",193 "delete",194 "dense_rank",195 "deref",196 "describe",197 "deterministic",198 "disconnect",199 "distinct",200 "double",201 "drop",202 "dynamic",203 "each",204 "element",205 "else",206 "empty",207 "end",208 "end_frame",209 "end_partition",210 "end-exec",211 "equals",212 "escape",213 "every",214 "except",215 "exec",216 "execute",217 "exists",218 "exp",219 "external",220 "extract",221 "false",222 "fetch",223 "filter",224 "first_value",225 "float",226 "floor",227 "for",228 "foreign",229 "frame_row",230 "free",231 "from",232 "full",233 "function",234 "fusion",235 "get",236 "global",237 "grant",238 "group",239 "grouping",240 "groups",241 "having",242 "hold",243 "hour",244 "identity",245 "in",246 "indicator",247 "initial",248 "inner",249 "inout",250 "insensitive",251 "insert",252 "int",253 "integer",254 "intersect",255 "intersection",256 "interval",257 "into",258 "is",259 "join",260 "json_array",261 "json_arrayagg",262 "json_exists",263 "json_object",264 "json_objectagg",265 "json_query",266 "json_table",267 "json_table_primitive",268 "json_value",269 "lag",270 "language",271 "large",272 "last_value",273 "lateral",274 "lead",275 "leading",276 "left",277 "like",278 "like_regex",279 "listagg",280 "ln",281 "local",282 "localtime",283 "localtimestamp",284 "log",285 "log10",286 "lower",287 "match",288 "match_number",289 "match_recognize",290 "matches",291 "max",292 "member",293 "merge",294 "method",295 "min",296 "minute",297 "mod",298 "modifies",299 "module",300 "month",301 "multiset",302 "national",303 "natural",304 "nchar",305 "nclob",306 "new",307 "no",308 "none",309 "normalize",310 "not",311 "nth_value",312 "ntile",313 "null",314 "nullif",315 "numeric",316 "octet_length",317 "occurrences_regex",318 "of",319 "offset",320 "old",321 "omit",322 "on",323 "one",324 "only",325 "open",326 "or",327 "order",328 "out",329 "outer",330 "over",331 "overlaps",332 "overlay",333 "parameter",334 "partition",335 "pattern",336 "per",337 "percent",338 "percent_rank",339 "percentile_cont",340 "percentile_disc",341 "period",342 "portion",343 "position",344 "position_regex",345 "power",346 "precedes",347 "precision",348 "prepare",349 "primary",350 "procedure",351 "ptf",352 "range",353 "rank",354 "reads",355 "real",356 "recursive",357 "ref",358 "references",359 "referencing",360 "regr_avgx",361 "regr_avgy",362 "regr_count",363 "regr_intercept",364 "regr_r2",365 "regr_slope",366 "regr_sxx",367 "regr_sxy",368 "regr_syy",369 "release",370 "result",371 "return",372 "returns",373 "revoke",374 "right",375 "rollback",376 "rollup",377 "row",378 "row_number",379 "rows",380 "running",381 "savepoint",382 "scope",383 "scroll",384 "search",385 "second",386 "seek",387 "select",388 "sensitive",389 "session_user",390 "set",391 "show",392 "similar",393 "sin",394 "sinh",395 "skip",396 "smallint",397 "some",398 "specific",399 "specifictype",400 "sql",401 "sqlexception",402 "sqlstate",403 "sqlwarning",404 "sqrt",405 "start",406 "static",407 "stddev_pop",408 "stddev_samp",409 "submultiset",410 "subset",411 "substring",412 "substring_regex",413 "succeeds",414 "sum",415 "symmetric",416 "system",417 "system_time",418 "system_user",419 "table",420 "tablesample",421 "tan",422 "tanh",423 "then",424 "time",425 "timestamp",426 "timezone_hour",427 "timezone_minute",428 "to",429 "trailing",430 "translate",431 "translate_regex",432 "translation",433 "treat",434 "trigger",435 "trim",436 "trim_array",437 "true",438 "truncate",439 "uescape",440 "union",441 "unique",442 "unknown",443 "unnest",444 "update",445 "upper",446 "user",447 "using",448 "value",449 "values",450 "value_of",451 "var_pop",452 "var_samp",453 "varbinary",454 "varchar",455 "varying",456 "versioning",457 "when",458 "whenever",459 "where",460 "width_bucket",461 "window",462 "with",463 "within",464 "without",465 "year",466 ];467 468 // these are reserved words we have identified to be functions469 // and should only be highlighted in a dispatch-like context470 // ie, array_agg(...), etc.471 const RESERVED_FUNCTIONS = [472 "abs",473 "acos",474 "array_agg",475 "asin",476 "atan",477 "avg",478 "cast",479 "ceil",480 "ceiling",481 "coalesce",482 "corr",483 "cos",484 "cosh",485 "count",486 "covar_pop",487 "covar_samp",488 "cume_dist",489 "dense_rank",490 "deref",491 "element",492 "exp",493 "extract",494 "first_value",495 "floor",496 "json_array",497 "json_arrayagg",498 "json_exists",499 "json_object",500 "json_objectagg",501 "json_query",502 "json_table",503 "json_table_primitive",504 "json_value",505 "lag",506 "last_value",507 "lead",508 "listagg",509 "ln",510 "log",511 "log10",512 "lower",513 "max",514 "min",515 "mod",516 "nth_value",517 "ntile",518 "nullif",519 "percent_rank",520 "percentile_cont",521 "percentile_disc",522 "position",523 "position_regex",524 "power",525 "rank",526 "regr_avgx",527 "regr_avgy",528 "regr_count",529 "regr_intercept",530 "regr_r2",531 "regr_slope",532 "regr_sxx",533 "regr_sxy",534 "regr_syy",535 "row_number",536 "sin",537 "sinh",538 "sqrt",539 "stddev_pop",540 "stddev_samp",541 "substring",542 "substring_regex",543 "sum",544 "tan",545 "tanh",546 "translate",547 "translate_regex",548 "treat",549 "trim",550 "trim_array",551 "unnest",552 "upper",553 "value_of",554 "var_pop",555 "var_samp",556 "width_bucket",557 ];558 559 // these functions can560 const POSSIBLE_WITHOUT_PARENS = [561 "current_catalog",562 "current_date",563 "current_default_transform_group",564 "current_path",565 "current_role",566 "current_schema",567 "current_transform_group_for_type",568 "current_user",569 "session_user",570 "system_time",571 "system_user",572 "current_time",573 "localtime",574 "current_timestamp",575 "localtimestamp"576 ];577 578 // those exist to boost relevance making these very579 // "SQL like" keyword combos worth +1 extra relevance580 const COMBOS = [581 "create table",582 "insert into",583 "primary key",584 "foreign key",585 "not null",586 "alter table",587 "add constraint",588 "grouping sets",589 "on overflow",590 "character set",591 "respect nulls",592 "ignore nulls",593 "nulls first",594 "nulls last",595 "depth first",596 "breadth first"597 ];598 599 const FUNCTIONS = RESERVED_FUNCTIONS;600 601 const KEYWORDS = [602 ...RESERVED_WORDS,603 ...NON_RESERVED_WORDS604 ].filter((keyword) => {605 return !RESERVED_FUNCTIONS.includes(keyword);606 });607 608 const VARIABLE = {609 scope: "variable",610 match: /@[a-z0-9][a-z0-9_]*/,611 };612 613 const OPERATOR = {614 scope: "operator",615 match: /[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,616 relevance: 0,617 };618 619 const FUNCTION_CALL = {620 match: regex.concat(/\b/, regex.either(...FUNCTIONS), /\s*\(/),621 relevance: 0,622 keywords: { built_in: FUNCTIONS }623 };624 625 // turns a multi-word keyword combo into a regex that doesn't626 // care about extra whitespace etc.627 // input: "START QUERY"628 // output: /\bSTART\s+QUERY\b/629 function kws_to_regex(list) {630 return regex.concat(631 /\b/,632 regex.either(...list.map((kw) => {633 return kw.replace(/\s+/, "\\s+")634 })),635 /\b/636 )637 }638 639 const MULTI_WORD_KEYWORDS = {640 scope: "keyword",641 match: kws_to_regex(COMBOS),642 relevance: 0,643 };644 645 // keywords with less than 3 letters are reduced in relevancy646 function reduceRelevancy(list, {647 exceptions, when648 } = {}) {649 const qualifyFn = when;650 exceptions = exceptions || [];651 return list.map((item) => {652 if (item.match(/\|\d+$/) || exceptions.includes(item)) {653 return item;654 } else if (qualifyFn(item)) {655 return `${item}|0`;656 } else {657 return item;658 }659 });660 }661 662 return {663 name: 'SQL',664 case_insensitive: true,665 // does not include {} or HTML tags `</`666 illegal: /[{}]|<\//,667 keywords: {668 $pattern: /\b[\w\.]+/,669 keyword:670 reduceRelevancy(KEYWORDS, { when: (x) => x.length < 3 }),671 literal: LITERALS,672 type: TYPES,673 built_in: POSSIBLE_WITHOUT_PARENS674 },675 contains: [676 {677 scope: "type",678 match: kws_to_regex(MULTI_WORD_TYPES)679 },680 MULTI_WORD_KEYWORDS,681 FUNCTION_CALL,682 VARIABLE,683 STRING,684 QUOTED_IDENTIFIER,685 hljs.C_NUMBER_MODE,686 hljs.C_BLOCK_COMMENT_MODE,687 COMMENT_MODE,688 OPERATOR689 ]690 };691}692 693module.exports = sql;694 