Files
context-continuity/venv.old-py38/lib/python3.9/site-packages/pygments/lexers/vyper.py
T
Master 943acbc573 feat: referentiel projets dynamique + validation nommage by design
Durcit la convention de nommage des projets (dérive constatée : 'Sliding
Automation', 'code_versioning'... au lieu des formes canoniques).

- trilium_api.py : projets_canoniques() lit le référentiel = valeurs du label
  projet sur les notes de type=projet (source unique, pas de constante en dur).
  Note-projet CodeVersioning créée (manquait).
- mcp_server.py : _valider_projet() branché dans les 6 tools de création
  (add_decision/history/backlog, new_conversation, create_entite, add_skill).
  Refuse un projet non canonique (suggestion si faute) ou inconnu (renvoi au
  processus de création de projet). Ne verrouille pas si référentiel illisible.
- lint_audit.py : VAL-nommage aligné sur le référentiel (attrape casse, espace
  ET snake_case ; l'ancien 'contient un espace' ratait code_versioning).
- Données : 79 notes ré-étiquetées vers les 3 formes canoniques.

Quality by design : l'erreur de nommage devient impossible à l'écriture, le
Lint n'est plus que le filet de sécurité.
2026-07-17 14:59:33 +02:00

141 lines
5.5 KiB
Python

"""
pygments.lexers.vyper
~~~~~~~~~~~~~~~~~~~~~
Lexer for the Vyper Smart Contract language.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from pygments.lexer import RegexLexer, bygroups, words
from pygments.token import (Comment, String, Name, Keyword, Number,
Operator, Punctuation, Text, Whitespace)
__all__ = ['VyperLexer']
class VyperLexer(RegexLexer):
"""For the Vyper smart contract language.
"""
name = 'Vyper'
aliases = ['vyper']
filenames = ['*.vy']
url = "https://vyper.readthedocs.io"
version_added = '2.17'
tokens = {
'root': [
# Whitespace
(r'\s+', Whitespace),
# Line continuations
(r'(\\)(\n|\r\n|\r)', bygroups(Text, Whitespace)),
# Comments - inline and multiline
(r'#.*$', Comment.Single),
(r'\"\"\"', Comment.Multiline, 'multiline-comment'),
# Strings - single and double
(r"'", String.Single, 'single-string'),
(r'"', String.Double, 'double-string'),
# Functions (working)
(r'(def)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
bygroups(Keyword, Whitespace, Name.Function)),
# Event and Struct
(r'(event|struct|interface|log)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
bygroups(Keyword, Whitespace, Name.Class)),
# Imports
(r'(from)(\s+)(vyper\.\w+)(\s+)(import)(\s+)(\w+)',
bygroups(Keyword, Whitespace, Name.Namespace, Whitespace,
Keyword, Whitespace, Name.Class)),
# Numeric Literals
(r'\b0x[0-9a-fA-F]+\b', Number.Hex),
(r'\b(\d{1,3}(?:_\d{3})*|\d+)\b', Number.Integer),
(r'\b\d+\.\d*\b', Number.Float),
# Keywords
(words(('def', 'event', 'pass', 'return', 'for', 'while', 'if', 'elif',
'else', 'assert', 'raise', 'import', 'in', 'struct', 'implements',
'interface', 'from', 'indexed', 'log', 'extcall', 'staticcall'),
prefix=r'\b', suffix=r'\b'), Keyword),
# Visibility and State Mutability
(words(('public', 'private', 'view', 'pure', 'constant',
'immutable', 'nonpayable'), prefix=r'\b', suffix=r'\b'),
Keyword.Declaration),
# Built-in Functions
(words(('bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'shift',
'create_minimal_proxy_to', 'create_copy_of', 'create_from_blueprint',
'ecadd', 'ecmul', 'ecrecover', 'keccak256', 'sha256', 'concat', 'convert',
'uint2str', 'extract32', 'slice', 'abs', 'ceil', 'floor', 'max', 'max_value',
'min', 'min_value', 'pow_mod256', 'sqrt', 'isqrt', 'uint256_addmod',
'uint256_mulmod', 'unsafe_add', 'unsafe_sub', 'unsafe_mul', 'unsafe_div',
'as_wei_value', 'blockhash', 'empty', 'len', 'method_id', '_abi_encode',
'_abi_decode', 'print', 'range'), prefix=r'\b', suffix=r'\b'),
Name.Builtin),
# Built-in Variables and Attributes
(words(('msg.sender', 'msg.value', 'block.timestamp', 'block.number', 'msg.gas'),
prefix=r'\b', suffix=r'\b'),
Name.Builtin.Pseudo),
(words(('uint', 'uint8', 'uint16', 'uint32', 'uint64', 'uint128', 'uint256',
'int', 'int8', 'int16', 'int32', 'int64', 'int128', 'int256', 'bool',
'decimal', 'bytes', 'bytes1', 'bytes2', 'bytes3', 'bytes4', 'bytes5',
'bytes6', 'bytes7', 'bytes8', 'bytes9', 'bytes10', 'bytes11',
'bytes12', 'bytes13', 'bytes14', 'bytes15', 'bytes16', 'bytes17',
'bytes18', 'bytes19', 'bytes20', 'bytes21', 'bytes22', 'bytes23',
'bytes24', 'bytes25', 'bytes26', 'bytes27', 'bytes28', 'bytes29',
'bytes30', 'bytes31', 'bytes32', 'string', 'String', 'address',
'enum', 'struct'), prefix=r'\b', suffix=r'\b'),
Keyword.Type),
# indexed keywords
(r'\b(indexed)\b(\s*)(\()(\s*)(\w+)(\s*)(\))',
bygroups(Keyword, Whitespace, Punctuation, Whitespace,
Keyword.Type, Punctuation)),
# Operators and Punctuation
(r'(\+|\-|\*|\/|<=?|>=?|==|!=|=|\||&|%)', Operator),
(r'[.,:;()\[\]{}]', Punctuation),
# Other variable names and types
(r'@[\w.]+', Name.Decorator),
(r'__\w+__', Name.Magic), # Matches double underscores followed by word characters
(r'EMPTY_BYTES32', Name.Constant),
(r'\bERC20\b', Name.Class),
(r'\bself\b', Name.Attribute),
(r'Bytes\[\d+\]', Keyword.Type),
# Generic names and variables
(r'\b[a-zA-Z_]\w*\b:', Name.Variable),
(r'\b[a-zA-Z_]\w*\b', Name),
],
'multiline-comment': [
(r'\"\"\"', Comment.Multiline, '#pop'),
(r'[^"]+', Comment.Multiline),
(r'\"', Comment.Multiline)
],
'single-string': [
(r"[^\\']+", String.Single),
(r"'", String.Single, '#pop'),
(r'\\.', String.Escape),
],
'double-string': [
(r'[^\\"]+', String.Double),
(r'"', String.Double, '#pop'),
(r'\\.', String.Escape),
]
}