_qlik_builtins.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. """
  2. pygments.lexers._qlik_builtins
  3. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. Qlik builtins.
  5. :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
  6. :license: BSD, see LICENSE for details.
  7. """
  8. # operators
  9. # see https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/Operators/operators.htm
  10. OPERATORS_LIST = {
  11. "words": [
  12. # Bit operators
  13. "bitnot",
  14. "bitand",
  15. "bitor",
  16. "bitxor",
  17. # Logical operators
  18. "and",
  19. "or",
  20. "not",
  21. "xor",
  22. # Relational operators
  23. "precedes",
  24. "follows",
  25. # String operators
  26. "like",
  27. ],
  28. "symbols": [
  29. # Bit operators
  30. ">>",
  31. "<<",
  32. # Logical operators
  33. # Numeric operators
  34. "+",
  35. "-",
  36. "/",
  37. "*",
  38. # Relational operators
  39. "<",
  40. "<=",
  41. ">",
  42. ">=",
  43. "=",
  44. "<>",
  45. # String operators
  46. "&",
  47. ],
  48. }
  49. # SCRIPT STATEMENTS
  50. # see https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/
  51. STATEMENT_LIST = [
  52. # control statements
  53. "for",
  54. "each",
  55. "in",
  56. "next",
  57. "do",
  58. "while",
  59. "until",
  60. "unless",
  61. "loop",
  62. "return",
  63. "switch",
  64. "case",
  65. "default",
  66. "if",
  67. "else",
  68. "endif",
  69. "then",
  70. "end",
  71. "exit",
  72. "script",
  73. "switch",
  74. # prefixes
  75. "Add",
  76. "Buffer",
  77. "Concatenate",
  78. "Crosstable",
  79. "First",
  80. "Generic",
  81. "Hierarchy",
  82. "HierarchyBelongsTo",
  83. "Inner",
  84. "IntervalMatch",
  85. "Join",
  86. "Keep",
  87. "Left",
  88. "Mapping",
  89. "Merge",
  90. "NoConcatenate",
  91. "Outer",
  92. "Partial reload",
  93. "Replace",
  94. "Right",
  95. "Sample",
  96. "Semantic",
  97. "Unless",
  98. "When",
  99. # regular statements
  100. "Alias", # alias ... as ...
  101. "as",
  102. "AutoNumber",
  103. "Binary",
  104. "Comment field", # comment fields ... using ...
  105. "Comment fields", # comment field ... with ...
  106. "using",
  107. "with",
  108. "Comment table", # comment table ... with ...
  109. "Comment tables", # comment tables ... using ...
  110. "Connect",
  111. "ODBC", # ODBC CONNECT TO ...
  112. "OLEBD", # OLEDB CONNECT TO ...
  113. "CUSTOM", # CUSTOM CONNECT TO ...
  114. "LIB", # LIB CONNECT TO ...
  115. "Declare",
  116. "Derive",
  117. "From",
  118. "explicit",
  119. "implicit",
  120. "Direct Query",
  121. "dimension",
  122. "measure",
  123. "Directory",
  124. "Disconnect",
  125. "Drop field",
  126. "Drop fields",
  127. "Drop table",
  128. "Drop tables",
  129. "Execute",
  130. "FlushLog",
  131. "Force",
  132. "capitalization",
  133. "case upper",
  134. "case lower",
  135. "case mixed",
  136. "Load",
  137. "distinct",
  138. "from",
  139. "inline",
  140. "resident",
  141. "from_field",
  142. "autogenerate",
  143. "extension",
  144. "where",
  145. "group by",
  146. "order by",
  147. "asc",
  148. "desc",
  149. "Let",
  150. "Loosen Table",
  151. "Map",
  152. "NullAsNull",
  153. "NullAsValue",
  154. "Qualify",
  155. "Rem",
  156. "Rename field",
  157. "Rename fields",
  158. "Rename table",
  159. "Rename tables",
  160. "Search",
  161. "include",
  162. "exclude",
  163. "Section",
  164. "access",
  165. "application",
  166. "Select",
  167. "Set",
  168. "Sleep",
  169. "SQL",
  170. "SQLColumns",
  171. "SQLTables",
  172. "SQLTypes",
  173. "Star",
  174. "Store",
  175. "Tag",
  176. "Trace",
  177. "Unmap",
  178. "Unqualify",
  179. "Untag",
  180. # Qualifiers
  181. "total",
  182. ]
  183. # Script functions
  184. # see https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/functions-in-scripts-chart-expressions.htm
  185. SCRIPT_FUNCTIONS = [
  186. # Basic aggregation functions in the data load script
  187. "FirstSortedValue",
  188. "Max",
  189. "Min",
  190. "Mode",
  191. "Only",
  192. "Sum",
  193. # Counter aggregation functions in the data load script
  194. "Count",
  195. "MissingCount",
  196. "NullCount",
  197. "NumericCount",
  198. "TextCount",
  199. # Financial aggregation functions in the data load script
  200. "IRR",
  201. "XIRR",
  202. "NPV",
  203. "XNPV",
  204. # Statistical aggregation functions in the data load script
  205. "Avg",
  206. "Correl",
  207. "Fractile",
  208. "FractileExc",
  209. "Kurtosis",
  210. "LINEST_B" "LINEST_df",
  211. "LINEST_f",
  212. "LINEST_m",
  213. "LINEST_r2",
  214. "LINEST_seb",
  215. "LINEST_sem",
  216. "LINEST_sey",
  217. "LINEST_ssreg",
  218. "Linest_ssresid",
  219. "Median",
  220. "Skew",
  221. "Stdev",
  222. "Sterr",
  223. "STEYX",
  224. # Statistical test functions
  225. "Chi2Test_chi2",
  226. "Chi2Test_df",
  227. "Chi2Test_p",
  228. # Two independent samples t-tests
  229. "ttest_conf",
  230. "ttest_df",
  231. "ttest_dif",
  232. "ttest_lower",
  233. "ttest_sig",
  234. "ttest_sterr",
  235. "ttest_t",
  236. "ttest_upper",
  237. # Two independent weighted samples t-tests
  238. "ttestw_conf",
  239. "ttestw_df",
  240. "ttestw_dif",
  241. "ttestw_lower",
  242. "ttestw_sig",
  243. "ttestw_sterr",
  244. "ttestw_t",
  245. "ttestw_upper",
  246. # One sample t-tests
  247. "ttest1_conf",
  248. "ttest1_df",
  249. "ttest1_dif",
  250. "ttest1_lower",
  251. "ttest1_sig",
  252. "ttest1_sterr",
  253. "ttest1_t",
  254. "ttest1_upper",
  255. # One weighted sample t-tests
  256. "ttest1w_conf",
  257. "ttest1w_df",
  258. "ttest1w_dif",
  259. "ttest1w_lower",
  260. "ttest1w_sig",
  261. "ttest1w_sterr",
  262. "ttest1w_t",
  263. "ttest1w_upper",
  264. # One column format functions
  265. "ztest_conf",
  266. "ztest_dif",
  267. "ztest_sig",
  268. "ztest_sterr",
  269. "ztest_z",
  270. "ztest_lower",
  271. "ztest_upper",
  272. # Weighted two-column format functions
  273. "ztestw_conf",
  274. "ztestw_dif",
  275. "ztestw_lower",
  276. "ztestw_sig",
  277. "ztestw_sterr",
  278. "ztestw_upper",
  279. "ztestw_z",
  280. # String aggregation functions in the data load script
  281. "Concat",
  282. "FirstValue",
  283. "LastValue",
  284. "MaxString",
  285. "MinString",
  286. # Synthetic dimension functions
  287. "ValueList",
  288. "ValueLoop",
  289. # Color functions
  290. "ARGB",
  291. "HSL",
  292. "RGB",
  293. "Color",
  294. "Colormix1",
  295. "Colormix2",
  296. "SysColor",
  297. "ColorMapHue",
  298. "ColorMapJet",
  299. "black",
  300. "blue",
  301. "brown",
  302. "cyan",
  303. "darkgray",
  304. "green",
  305. "lightblue",
  306. "lightcyan",
  307. "lightgray",
  308. "lightgreen",
  309. "lightmagenta",
  310. "lightred",
  311. "magenta",
  312. "red",
  313. "white",
  314. "yellow",
  315. # Conditional functions
  316. "alt",
  317. "class",
  318. "coalesce",
  319. "if",
  320. "match",
  321. "mixmatch",
  322. "pick",
  323. "wildmatch",
  324. # Counter functions
  325. "autonumber",
  326. "autonumberhash128",
  327. "autonumberhash256",
  328. "IterNo",
  329. "RecNo",
  330. "RowNo",
  331. # Integer expressions of time
  332. "second",
  333. "minute",
  334. "hour",
  335. "day",
  336. "week",
  337. "month",
  338. "year",
  339. "weekyear",
  340. "weekday",
  341. # Timestamp functions
  342. "now",
  343. "today",
  344. "LocalTime",
  345. # Make functions
  346. "makedate",
  347. "makeweekdate",
  348. "maketime",
  349. # Other date functions
  350. "AddMonths",
  351. "AddYears",
  352. "yeartodate",
  353. # Timezone functions
  354. "timezone",
  355. "GMT",
  356. "UTC",
  357. "daylightsaving",
  358. "converttolocaltime",
  359. # Set time functions
  360. "setdateyear",
  361. "setdateyearmonth",
  362. # In... functions
  363. "inyear",
  364. "inyeartodate",
  365. "inquarter",
  366. "inquartertodate",
  367. "inmonth",
  368. "inmonthtodate",
  369. "inmonths",
  370. "inmonthstodate",
  371. "inweek",
  372. "inweektodate",
  373. "inlunarweek",
  374. "inlunarweektodate",
  375. "inday",
  376. "indaytotime",
  377. # Start ... end functions
  378. "yearstart",
  379. "yearend",
  380. "yearname",
  381. "quarterstart",
  382. "quarterend",
  383. "quartername",
  384. "monthstart",
  385. "monthend",
  386. "monthname",
  387. "monthsstart",
  388. "monthsend",
  389. "monthsname",
  390. "weekstart",
  391. "weekend",
  392. "weekname",
  393. "lunarweekstart",
  394. "lunarweekend",
  395. "lunarweekname",
  396. "daystart",
  397. "dayend",
  398. "dayname",
  399. # Day numbering functions
  400. "age",
  401. "networkdays",
  402. "firstworkdate",
  403. "lastworkdate",
  404. "daynumberofyear",
  405. "daynumberofquarter",
  406. # Exponential and logarithmic
  407. "exp",
  408. "log",
  409. "log10",
  410. "pow",
  411. "sqr",
  412. "sqrt",
  413. # Count functions
  414. "GetAlternativeCount",
  415. "GetExcludedCount",
  416. "GetNotSelectedCount",
  417. "GetPossibleCount",
  418. "GetSelectedCount",
  419. # Field and selection functions
  420. "GetCurrentSelections",
  421. "GetFieldSelections",
  422. "GetObjectDimension",
  423. "GetObjectField",
  424. "GetObjectMeasure",
  425. # File functions
  426. "Attribute",
  427. "ConnectString",
  428. "FileBaseName",
  429. "FileDir",
  430. "FileExtension",
  431. "FileName",
  432. "FilePath",
  433. "FileSize",
  434. "FileTime",
  435. "GetFolderPath",
  436. "QvdCreateTime",
  437. "QvdFieldName",
  438. "QvdNoOfFields",
  439. "QvdNoOfRecords",
  440. "QvdTableName",
  441. # Financial functions
  442. "FV",
  443. "nPer",
  444. "Pmt",
  445. "PV",
  446. "Rate",
  447. # Formatting functions
  448. "ApplyCodepage",
  449. "Date",
  450. "Dual",
  451. "Interval",
  452. "Money",
  453. "Num",
  454. "Time",
  455. "Timestamp",
  456. # General numeric functions
  457. "bitcount",
  458. "div",
  459. "fabs",
  460. "fact",
  461. "frac",
  462. "sign",
  463. # Combination and permutation functions
  464. "combin",
  465. "permut",
  466. # Modulo functions
  467. "fmod",
  468. "mod",
  469. # Parity functions
  470. "even",
  471. "odd",
  472. # Rounding functions
  473. "ceil",
  474. "floor",
  475. "round",
  476. # Geospatial functions
  477. "GeoAggrGeometry",
  478. "GeoBoundingBox",
  479. "GeoCountVertex",
  480. "GeoInvProjectGeometry",
  481. "GeoProjectGeometry",
  482. "GeoReduceGeometry",
  483. "GeoGetBoundingBox",
  484. "GeoGetPolygonCenter",
  485. "GeoMakePoint",
  486. "GeoProject",
  487. # Interpretation functions
  488. "Date#",
  489. "Interval#",
  490. "Money#",
  491. "Num#",
  492. "Text",
  493. "Time#",
  494. "Timestamp#",
  495. # Field functions
  496. "FieldIndex",
  497. "FieldValue",
  498. "FieldValueCount",
  499. # Inter-record functions in the data load script
  500. "Exists",
  501. "LookUp",
  502. "Peek",
  503. "Previous",
  504. # Logical functions
  505. "IsNum",
  506. "IsText",
  507. # Mapping functions
  508. "ApplyMap",
  509. "MapSubstring",
  510. # Mathematical functions
  511. "e",
  512. "false",
  513. "pi",
  514. "rand",
  515. "true",
  516. # NULL functions
  517. "EmptyIsNull",
  518. "IsNull",
  519. "Null",
  520. # Basic range functions
  521. "RangeMax",
  522. "RangeMaxString",
  523. "RangeMin",
  524. "RangeMinString",
  525. "RangeMode",
  526. "RangeOnly",
  527. "RangeSum",
  528. # Counter range functions
  529. "RangeCount",
  530. "RangeMissingCount",
  531. "RangeNullCount",
  532. "RangeNumericCount",
  533. "RangeTextCount",
  534. # Statistical range functions
  535. "RangeAvg",
  536. "RangeCorrel",
  537. "RangeFractile",
  538. "RangeKurtosis",
  539. "RangeSkew",
  540. "RangeStdev",
  541. # Financial range functions
  542. "RangeIRR",
  543. "RangeNPV",
  544. "RangeXIRR",
  545. "RangeXNPV",
  546. # Statistical distribution
  547. "CHIDIST",
  548. "CHIINV",
  549. "NORMDIST",
  550. "NORMINV",
  551. "TDIST",
  552. "TINV",
  553. "FDIST",
  554. "FINV",
  555. # String functions
  556. "Capitalize",
  557. "Chr",
  558. "Evaluate",
  559. "FindOneOf",
  560. "Hash128",
  561. "Hash160",
  562. "Hash256",
  563. "Index",
  564. "KeepChar",
  565. "Left",
  566. "Len",
  567. "LevenshteinDist",
  568. "Lower",
  569. "LTrim",
  570. "Mid",
  571. "Ord",
  572. "PurgeChar",
  573. "Repeat",
  574. "Replace",
  575. "Right",
  576. "RTrim",
  577. "SubField",
  578. "SubStringCount",
  579. "TextBetween",
  580. "Trim",
  581. "Upper",
  582. # System functions
  583. "Author",
  584. "ClientPlatform",
  585. "ComputerName",
  586. "DocumentName",
  587. "DocumentPath",
  588. "DocumentTitle",
  589. "EngineVersion",
  590. "GetCollationLocale",
  591. "GetObjectField",
  592. "GetRegistryString",
  593. "IsPartialReload",
  594. "OSUser",
  595. "ProductVersion",
  596. "ReloadTime",
  597. "StateName",
  598. # Table functions
  599. "FieldName",
  600. "FieldNumber",
  601. "NoOfFields",
  602. "NoOfRows",
  603. "NoOfTables",
  604. "TableName",
  605. "TableNumber",
  606. ]
  607. # System variables and constants
  608. # see https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/work-with-variables-in-data-load-editor.htm
  609. CONSTANT_LIST = [
  610. # System Variables
  611. "floppy",
  612. "cd",
  613. "include",
  614. "must_include",
  615. "hideprefix",
  616. "hidesuffix",
  617. "qvpath",
  618. "qvroot",
  619. "QvWorkPath",
  620. "QvWorkRoot",
  621. "StripComments",
  622. "Verbatim",
  623. "OpenUrlTimeout",
  624. "WinPath",
  625. "WinRoot",
  626. "CollationLocale",
  627. "CreateSearchIndexOnReload",
  628. # value handling variables
  629. "NullDisplay",
  630. "NullInterpret",
  631. "NullValue",
  632. "OtherSymbol",
  633. # Currency formatting
  634. "MoneyDecimalSep",
  635. "MoneyFormat",
  636. "MoneyThousandSep",
  637. # Number formatting
  638. "DecimalSep",
  639. "ThousandSep",
  640. "NumericalAbbreviation",
  641. # Time formatting
  642. "DateFormat",
  643. "TimeFormat",
  644. "TimestampFormat",
  645. "MonthNames",
  646. "LongMonthNames",
  647. "DayNames",
  648. "LongDayNames",
  649. "FirstWeekDay",
  650. "BrokenWeeks",
  651. "ReferenceDay",
  652. "FirstMonthOfYear",
  653. # Error variables
  654. "errormode",
  655. "scripterror",
  656. "scripterrorcount",
  657. "scripterrorlist",
  658. # Other
  659. "null",
  660. ]