The internal servers have no access to outside package repositories and run Python 3.8/3.9, so the UI moves from hand-drawn curses to Textual 6.2.1 (the last release supporting 3.8.1), vendored with its pure-Python dependencies in vendor/. The launcher puts vendor/ first on sys.path, so a plain checkout runs with no pip and no network. - dsflow/: the single script split into a package (pure moves of the backend sections); action rules moved to ops.py, free of Textual - dsflow/ui/: tabs, detail pane, live sanity-run panel, log viewer, modal dialogs, filter, themes, mouse support - tests/test_ui.py: headless UI tests through Textual's pilot - tools/vendor.py (refresh vendor/), tools/screenshots.py (README images) - README, CLAUDE.md, TODO and the feature doc updated for the new layout, the Python 3.8.1 floor and the vendoring rules Verified: 11 tests green on Python 3.12 and 3.8.20; the shipped file set runs under `python -I -S` on both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
106 lines
3.7 KiB
Python
Vendored
106 lines
3.7 KiB
Python
Vendored
"""
|
|
pygments.lexers.futhark
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Lexer for the Futhark language
|
|
|
|
:copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS.
|
|
:license: BSD, see LICENSE for details.
|
|
"""
|
|
|
|
from pygments.lexer import RegexLexer, bygroups
|
|
from pygments.token import Comment, Operator, Keyword, Name, String, \
|
|
Number, Punctuation, Whitespace
|
|
from pygments import unistring as uni
|
|
|
|
__all__ = ['FutharkLexer']
|
|
|
|
|
|
class FutharkLexer(RegexLexer):
|
|
"""
|
|
A Futhark lexer
|
|
"""
|
|
name = 'Futhark'
|
|
url = 'https://futhark-lang.org/'
|
|
aliases = ['futhark']
|
|
filenames = ['*.fut']
|
|
mimetypes = ['text/x-futhark']
|
|
version_added = '2.8'
|
|
|
|
num_types = ('i8', 'i16', 'i32', 'i64', 'u8', 'u16', 'u32', 'u64', 'f32', 'f64')
|
|
|
|
other_types = ('bool', )
|
|
|
|
reserved = ('if', 'then', 'else', 'def', 'let', 'loop', 'in', 'with',
|
|
'type', 'type~', 'type^',
|
|
'val', 'entry', 'for', 'while', 'do', 'case', 'match',
|
|
'include', 'import', 'module', 'open', 'local', 'assert', '_')
|
|
|
|
ascii = ('NUL', 'SOH', '[SE]TX', 'EOT', 'ENQ', 'ACK',
|
|
'BEL', 'BS', 'HT', 'LF', 'VT', 'FF', 'CR', 'S[OI]', 'DLE',
|
|
'DC[1-4]', 'NAK', 'SYN', 'ETB', 'CAN',
|
|
'EM', 'SUB', 'ESC', '[FGRU]S', 'SP', 'DEL')
|
|
|
|
num_postfix = r'({})?'.format('|'.join(num_types))
|
|
|
|
identifier_re = '[a-zA-Z_][a-zA-Z_0-9\']*'
|
|
|
|
# opstart_re = '+\-\*/%=\!><\|&\^'
|
|
|
|
tokens = {
|
|
'root': [
|
|
(r'--(.*?)$', Comment.Single),
|
|
(r'\s+', Whitespace),
|
|
(r'\(\)', Punctuation),
|
|
(r'\b({})(?!\')\b'.format('|'.join(reserved)), Keyword.Reserved),
|
|
(r'\b({})(?!\')\b'.format('|'.join(num_types + other_types)), Keyword.Type),
|
|
|
|
# Identifiers
|
|
(r'#\[([a-zA-Z_\(\) ]*)\]', Comment.Preproc),
|
|
(rf'[#!]?({identifier_re}\.)*{identifier_re}', Name),
|
|
|
|
(r'\\', Operator),
|
|
(r'[-+/%=!><|&*^][-+/%=!><|&*^.]*', Operator),
|
|
(r'[][(),:;`{}?.\'~^]', Punctuation),
|
|
|
|
# Numbers
|
|
(r'0[xX]_*[\da-fA-F](_*[\da-fA-F])*_*[pP][+-]?\d(_*\d)*' + num_postfix,
|
|
Number.Float),
|
|
(r'0[xX]_*[\da-fA-F](_*[\da-fA-F])*\.[\da-fA-F](_*[\da-fA-F])*'
|
|
r'(_*[pP][+-]?\d(_*\d)*)?' + num_postfix, Number.Float),
|
|
(r'\d(_*\d)*_*[eE][+-]?\d(_*\d)*' + num_postfix, Number.Float),
|
|
(r'\d(_*\d)*\.\d(_*\d)*(_*[eE][+-]?\d(_*\d)*)?' + num_postfix, Number.Float),
|
|
(r'0[bB]_*[01](_*[01])*' + num_postfix, Number.Bin),
|
|
(r'0[xX]_*[\da-fA-F](_*[\da-fA-F])*' + num_postfix, Number.Hex),
|
|
(r'\d(_*\d)*' + num_postfix, Number.Integer),
|
|
|
|
# Character/String Literals
|
|
(r"'", String.Char, 'character'),
|
|
(r'"', String, 'string'),
|
|
# Special
|
|
(r'\[[a-zA-Z_\d]*\]', Keyword.Type),
|
|
(r'\(\)', Name.Builtin),
|
|
],
|
|
'character': [
|
|
# Allows multi-chars, incorrectly.
|
|
(r"[^\\']'", String.Char, '#pop'),
|
|
(r"\\", String.Escape, 'escape'),
|
|
("'", String.Char, '#pop'),
|
|
],
|
|
'string': [
|
|
(r'[^\\"]+', String),
|
|
(r"\\", String.Escape, 'escape'),
|
|
('"', String, '#pop'),
|
|
],
|
|
|
|
'escape': [
|
|
(r'[abfnrtv"\'&\\]', String.Escape, '#pop'),
|
|
(r'\^[][' + uni.Lu + r'@^_]', String.Escape, '#pop'),
|
|
('|'.join(ascii), String.Escape, '#pop'),
|
|
(r'o[0-7]+', String.Escape, '#pop'),
|
|
(r'x[\da-fA-F]+', String.Escape, '#pop'),
|
|
(r'\d+', String.Escape, '#pop'),
|
|
(r'(\s+)(\\)', bygroups(Whitespace, String.Escape), '#pop'),
|
|
],
|
|
}
|