fastapi-gsap/.venv/lib/python3.12/site-packages/pygments/lexers/qlik.py
Tyler J King e744336385 fix: capability enforcement, credential safety, atomic delegations, input validation
C-6: ConnectorRuntime enforces capability_mask per operation.
     READ-only ACs cannot invoke MUTATE operations (wipe, lock, retire).
C-7: AC validated against database (exists, active, not expired)
     before connector invocation.
C-9: Delegated AC capability bounded by delegator's capability.
C-10: Command counter uses atomic SQL increment with limit check.
M-23: expire_stale() uses same atomic SQL pattern.

H-1: Sensitive credential fields hidden from repr/logs via repr=False.
H-2: Stub backend requires ALLOW_STUB_CREDENTIALS=true to activate.
H-3: Kerberos backend raises CredentialResolutionError instead of
     returning stub ticket.
H-4: Chronicle INTENT emitted before execution, RESULT after.
H-5: device_id validated as UUID before Graph API URL interpolation.
H-8: ConnectorRuntime enforces governance for all connector invocations.

Signed-off-by: Tyler King <tking@guildhouse.dev>
2026-04-14 08:13:27 -04:00

117 lines
3.6 KiB
Python

"""
pygments.lexers.qlik
~~~~~~~~~~~~~~~~~~~~
Lexer for the qlik scripting language
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import re
from pygments.lexer import RegexLexer, include, bygroups, words
from pygments.token import Comment, Keyword, Name, Number, Operator, \
Punctuation, String, Text
from pygments.lexers._qlik_builtins import OPERATORS_LIST, STATEMENT_LIST, \
SCRIPT_FUNCTIONS, CONSTANT_LIST
__all__ = ["QlikLexer"]
class QlikLexer(RegexLexer):
"""
Lexer for qlik code, including .qvs files
"""
name = "Qlik"
aliases = ["qlik", "qlikview", "qliksense", "qlikscript"]
filenames = ["*.qvs", "*.qvw"]
url = "https://qlik.com"
version_added = '2.12'
flags = re.IGNORECASE
tokens = {
# Handle multi-line comments
"comment": [
(r"\*/", Comment.Multiline, "#pop"),
(r"[^*]+", Comment.Multiline),
],
# Handle numbers
"numerics": [
(r"\b\d+\.\d+(e\d+)?[fd]?\b", Number.Float),
(r"\b\d+\b", Number.Integer),
],
# Handle variable names in things
"interp": [
(
r"(\$\()(\w+)(\))",
bygroups(String.Interpol, Name.Variable, String.Interpol),
),
],
# Handle strings
"string": [
(r"'", String, "#pop"),
include("interp"),
(r"[^'$]+", String),
(r"\$", String),
],
#
"assignment": [
(r";", Punctuation, "#pop"),
include("root"),
],
"field_name_quote": [
(r'"', String.Symbol, "#pop"),
include("interp"),
(r"[^\"$]+", String.Symbol),
(r"\$", String.Symbol),
],
"field_name_bracket": [
(r"\]", String.Symbol, "#pop"),
include("interp"),
(r"[^\]$]+", String.Symbol),
(r"\$", String.Symbol),
],
"function": [(r"\)", Punctuation, "#pop"), include("root")],
"root": [
# Whitespace and comments
(r"\s+", Text.Whitespace),
(r"/\*", Comment.Multiline, "comment"),
(r"//.*\n", Comment.Single),
# variable assignment
(r"(let|set)(\s+)", bygroups(Keyword.Declaration, Text.Whitespace),
"assignment"),
# Word operators
(words(OPERATORS_LIST["words"], prefix=r"\b", suffix=r"\b"),
Operator.Word),
# Statements
(words(STATEMENT_LIST, suffix=r"\b"), Keyword),
# Table names
(r"[a-z]\w*:", Keyword.Declaration),
# Constants
(words(CONSTANT_LIST, suffix=r"\b"), Keyword.Constant),
# Functions
(words(SCRIPT_FUNCTIONS, suffix=r"(?=\s*\()"), Name.Builtin,
"function"),
# interpolation - e.g. $(variableName)
include("interp"),
# Quotes denote a field/file name
(r'"', String.Symbol, "field_name_quote"),
# Square brackets denote a field/file name
(r"\[", String.Symbol, "field_name_bracket"),
# Strings
(r"'", String, "string"),
# Numbers
include("numerics"),
# Operator symbols
(words(OPERATORS_LIST["symbols"]), Operator),
# Strings denoted by single quotes
(r"'.+?'", String),
# Words as text
(r"\b\w+\b", Text),
# Basic punctuation
(r"[,;.()\\/]", Punctuation),
],
}