|
""" |
|
pygments.lexers.bqn |
|
~~~~~~~~~~~~~~~~~~~ |
|
|
|
Lexer for BQN. |
|
|
|
:copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS. |
|
:license: BSD, see LICENSE for details. |
|
""" |
|
|
|
from pygments.lexer import RegexLexer |
|
from pygments.token import Comment, Operator, Keyword, Name, String, \ |
|
Number, Punctuation, Whitespace |
|
|
|
__all__ = ['BQNLexer'] |
|
|
|
|
|
class BQNLexer(RegexLexer): |
|
""" |
|
A simple BQN lexer. |
|
""" |
|
name = 'BQN' |
|
url = 'https://mlochbaum.github.io/BQN/index.html' |
|
aliases = ['bqn'] |
|
filenames = ['*.bqn'] |
|
mimetypes = [] |
|
version_added = '2.16' |
|
|
|
|
|
|
|
_iwc = r'((?=[^πππ½πΎππ¨π©πππ€π£])\w)' |
|
|
|
tokens = { |
|
'root': [ |
|
|
|
|
|
(r'\s+', Whitespace), |
|
|
|
|
|
|
|
|
|
(r'#.*$', Comment.Single), |
|
|
|
|
|
|
|
(r'\'((\'\')|[^\'])*\'', String.Single), |
|
(r'"(("")|[^"])*"', String.Double), |
|
|
|
|
|
|
|
|
|
(r'@', String.Symbol), |
|
|
|
|
|
|
|
|
|
|
|
(r'[\.β,\[\]β¨β©βΏ]', Punctuation), |
|
|
|
|
|
|
|
|
|
|
|
(r'[\(\)]', String.Regex), |
|
|
|
|
|
|
|
|
|
(r'Β―?[0-9](([0-9]|_)*\.?([0-9]|_)+|([0-9]|_)*)([Ee][Β―]?([0-9]|_)+)?|Β―|β|Ο|Β·', Number), |
|
|
|
|
|
|
|
(r'[a-z]' + _iwc + r'*', Name.Variable), |
|
|
|
|
|
|
|
|
|
(r'[βββΈββΎββΆββββ]', Name.Property), |
|
(r'_(π£|[a-zA-Z0-9]+)_', Name.Property), |
|
|
|
|
|
|
|
(r'[ΛΛΛΒ¨ββΌΒ΄Λ`π£]', Name.Attribute), |
|
(r'_(π£|[a-zA-Z0-9]+)', Name.Attribute), |
|
|
|
|
|
|
|
|
|
|
|
(r'[+\-ΓΓ·\βββββ§β¨Β¬|β€<>β₯=β β‘β’β£β’β₯βΎβββββ«»β½β/ββββββββ·β!πππ½πΎπ]', |
|
Operator), |
|
(r'[A-Z]' + _iwc + r'*|β’' + _iwc + r'+', Operator), |
|
|
|
|
|
|
|
(r'Λ', Name.Constant), |
|
|
|
|
|
|
|
(r'[ββ©β]', Keyword.Declaration), |
|
|
|
|
|
|
|
(r'[{}]', Keyword.Type), |
|
|
|
|
|
|
|
(r'[;:?π¨π©πππ€]', Name.Entity), |
|
|
|
|
|
], |
|
} |
|
|