aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Pygments/py3/pygments/lexers/teal.py
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/python/Pygments/py3/pygments/lexers/teal.py
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/lexers/teal.py')
-rw-r--r--contrib/python/Pygments/py3/pygments/lexers/teal.py87
1 files changed, 87 insertions, 0 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/teal.py b/contrib/python/Pygments/py3/pygments/lexers/teal.py
new file mode 100644
index 0000000000..33088c882b
--- /dev/null
+++ b/contrib/python/Pygments/py3/pygments/lexers/teal.py
@@ -0,0 +1,87 @@
+"""
+ pygments.lexers.teal
+ ~~~~~~~~~~~~~~~~~~~~
+
+ Lexer for TEAL.
+
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+from pygments.lexer import RegexLexer, bygroups, include, words
+from pygments.token import Comment, Name, Number, String, Text, Keyword
+
+__all__ = ['TealLexer']
+
+class TealLexer(RegexLexer):
+ """
+ For the `Transaction Execution Approval Language (TEAL)
+ <https://developer.algorand.org/docs/reference/teal/specification/>`
+
+ For more information about the grammar, see:
+ https://github.com/algorand/go-algorand/blob/master/data/transactions/logic/assembler.go
+
+ .. versionadded:: 2.9
+ """
+ name = 'teal'
+ aliases = ['teal']
+ filenames = ['*.teal']
+
+ keywords = words({
+ 'Sender', 'Fee', 'FirstValid', 'FirstValidTime', 'LastValid', 'Note',
+ 'Lease', 'Receiver', 'Amount', 'CloseRemainderTo', 'VotePK',
+ 'SelectionPK', 'VoteFirst', 'VoteLast', 'VoteKeyDilution', 'Type',
+ 'TypeEnum', 'XferAsset', 'AssetAmount', 'AssetSender', 'AssetReceiver',
+ 'AssetCloseTo', 'GroupIndex', 'TxID', 'ApplicationID', 'OnCompletion',
+ 'ApplicationArgs', 'NumAppArgs', 'Accounts', 'NumAccounts',
+ 'ApprovalProgram', 'ClearStateProgram', 'RekeyTo', 'ConfigAsset',
+ 'ConfigAssetTotal', 'ConfigAssetDecimals', 'ConfigAssetDefaultFrozen',
+ 'ConfigAssetUnitName', 'ConfigAssetName', 'ConfigAssetURL',
+ 'ConfigAssetMetadataHash', 'ConfigAssetManager', 'ConfigAssetReserve',
+ 'ConfigAssetFreeze', 'ConfigAssetClawback', 'FreezeAsset',
+ 'FreezeAssetAccount', 'FreezeAssetFrozen',
+ 'NoOp', 'OptIn', 'CloseOut', 'ClearState', 'UpdateApplication',
+ 'DeleteApplication',
+ 'MinTxnFee', 'MinBalance', 'MaxTxnLife', 'ZeroAddress', 'GroupSize',
+ 'LogicSigVersion', 'Round', 'LatestTimestamp', 'CurrentApplicationID',
+ 'AssetBalance', 'AssetFrozen',
+ 'AssetTotal', 'AssetDecimals', 'AssetDefaultFrozen', 'AssetUnitName',
+ 'AssetName', 'AssetURL', 'AssetMetadataHash', 'AssetManager',
+ 'AssetReserve', 'AssetFreeze', 'AssetClawback',
+ }, suffix = r'\b')
+
+ identifier = r'[^ \t\n]+(?=\/\/)|[^ \t\n]+'
+ newline = r'\r?\n'
+ tokens = {
+ 'root': [
+ include('whitespace'),
+ # pragmas match specifically on the space character
+ (r'^#pragma .*' + newline, Comment.Directive),
+ # labels must be followed by a space,
+ # but anything after that is ignored
+ ('(' + identifier + ':' + ')' + '([ \t].*)',
+ bygroups(Name.Label, Comment.Single)),
+ (identifier, Name.Function, 'function-args'),
+ ],
+ 'function-args': [
+ include('whitespace'),
+ (r'"', String, 'string'),
+ (r'(b(?:ase)?(?:32|64) ?)(\(?[a-zA-Z0-9+/=]+\)?)',
+ bygroups(String.Affix, String.Other)),
+ (r'[A-Z2-7]{58}', Number), # address
+ (r'0x[\da-fA-F]+', Number.Hex),
+ (r'\d+', Number.Integer),
+ (keywords, Keyword),
+ (identifier, Name.Attributes), # branch targets
+ (newline, Text, '#pop'),
+ ],
+ 'string': [
+ (r'\\(?:["nrt\\]|x\d\d)', String.Escape),
+ (r'[^\\\"\n]+', String),
+ (r'"', String, '#pop'),
+ ],
+ 'whitespace': [
+ (r'[ \t]+', Text),
+ (r'//[^\n]+', Comment.Single),
+ ],
+ }