codekingpro/portable-devtools
114k
1"""2 pygments.lexers.ride3 ~~~~~~~~~~~~~~~~~~~~4 5 Lexer for the Ride programming language.6 7 :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.8 :license: BSD, see LICENSE for details.9"""10 11from pygments.lexer import RegexLexer, words, include12from pygments.token import Comment, Keyword, Name, Number, Punctuation, \13 String, Text14 15__all__ = ['RideLexer']16 17 18class RideLexer(RegexLexer):19 """20 For Ride source code.21 """22 23 name = 'Ride'24 aliases = ['ride']25 filenames = ['*.ride']26 mimetypes = ['text/x-ride']27 url = 'https://docs.waves.tech/en/ride'28 version_added = '2.6'29 30 validName = r'[a-zA-Z_][a-zA-Z0-9_\']*'31 32 builtinOps = (33 '||', '|', '>=', '>', '==', '!',34 '=', '<=', '<', '::', ':+', ':', '!=', '/',35 '.', '=>', '-', '+', '*', '&&', '%', '++',36 )37 38 globalVariablesName = (39 'NOALG', 'MD5', 'SHA1', 'SHA224', 'SHA256', 'SHA384', 'SHA512',40 'SHA3224', 'SHA3256', 'SHA3384', 'SHA3512', 'nil', 'this', 'unit',41 'height', 'lastBlock', 'Buy', 'Sell', 'CEILING', 'FLOOR', 'DOWN',42 'HALFDOWN', 'HALFEVEN', 'HALFUP', 'UP',43 )44 45 typesName = (46 'Unit', 'Int', 'Boolean', 'ByteVector', 'String', 'Address', 'Alias',47 'Transfer', 'AssetPair', 'DataEntry', 'Order', 'Transaction',48 'GenesisTransaction', 'PaymentTransaction', 'ReissueTransaction',49 'BurnTransaction', 'MassTransferTransaction', 'ExchangeTransaction',50 'TransferTransaction', 'SetAssetScriptTransaction',51 'InvokeScriptTransaction', 'IssueTransaction', 'LeaseTransaction',52 'LeaseCancelTransaction', 'CreateAliasTransaction',53 'SetScriptTransaction', 'SponsorFeeTransaction', 'DataTransaction',54 'WriteSet', 'AttachedPayment', 'ScriptTransfer', 'TransferSet',55 'ScriptResult', 'Invocation', 'Asset', 'BlockInfo', 'Issue', 'Reissue',56 'Burn', 'NoAlg', 'Md5', 'Sha1', 'Sha224', 'Sha256', 'Sha384', 'Sha512',57 'Sha3224', 'Sha3256', 'Sha3384', 'Sha3512', 'BinaryEntry',58 'BooleanEntry', 'IntegerEntry', 'StringEntry', 'List', 'Ceiling',59 'Down', 'Floor', 'HalfDown', 'HalfEven', 'HalfUp', 'Up',60 )61 62 functionsName = (63 'fraction', 'size', 'toBytes', 'take', 'drop', 'takeRight', 'dropRight',64 'toString', 'isDefined', 'extract', 'throw', 'getElement', 'value',65 'cons', 'toUtf8String', 'toInt', 'indexOf', 'lastIndexOf', 'split',66 'parseInt', 'parseIntValue', 'keccak256', 'blake2b256', 'sha256',67 'sigVerify', 'toBase58String', 'fromBase58String', 'toBase64String',68 'fromBase64String', 'transactionById', 'transactionHeightById',69 'getInteger', 'getBoolean', 'getBinary', 'getString',70 'addressFromPublicKey', 'addressFromString', 'addressFromRecipient',71 'assetBalance', 'wavesBalance', 'getIntegerValue', 'getBooleanValue',72 'getBinaryValue', 'getStringValue', 'addressFromStringValue',73 'assetInfo', 'rsaVerify', 'checkMerkleProof', 'median',74 'valueOrElse', 'valueOrErrorMessage', 'contains', 'log', 'pow',75 'toBase16String', 'fromBase16String', 'blockInfoByHeight',76 'transferTransactionById',77 )78 79 reservedWords = words((80 'match', 'case', 'else', 'func', 'if',81 'let', 'then', '@Callable', '@Verifier',82 ), suffix=r'\b')83 84 tokens = {85 'root': [86 # Comments87 (r'#.*', Comment.Single),88 # Whitespace89 (r'\s+', Text),90 # Strings91 (r'"', String, 'doublequote'),92 (r'utf8\'', String, 'utf8quote'),93 (r'base(58|64|16)\'', String, 'singlequote'),94 # Keywords95 (reservedWords, Keyword.Reserved),96 (r'\{-#.*?#-\}', Keyword.Reserved),97 (r'FOLD<\d+>', Keyword.Reserved),98 # Types99 (words(typesName), Keyword.Type),100 # Main101 # (specialName, Keyword.Reserved),102 # Prefix Operators103 (words(builtinOps, prefix=r'\(', suffix=r'\)'), Name.Function),104 # Infix Operators105 (words(builtinOps), Name.Function),106 (words(globalVariablesName), Name.Function),107 (words(functionsName), Name.Function),108 # Numbers109 include('numbers'),110 # Variable Names111 (validName, Name.Variable),112 # Parens113 (r'[,()\[\]{}]', Punctuation),114 ],115 116 'doublequote': [117 (r'\\u[0-9a-fA-F]{4}', String.Escape),118 (r'\\[nrfvb\\"]', String.Escape),119 (r'[^"]', String),120 (r'"', String, '#pop'),121 ],122 123 'utf8quote': [124 (r'\\u[0-9a-fA-F]{4}', String.Escape),125 (r'\\[nrfvb\\\']', String.Escape),126 (r'[^\']', String),127 (r'\'', String, '#pop'),128 ],129 130 'singlequote': [131 (r'[^\']', String),132 (r'\'', String, '#pop'),133 ],134 135 'numbers': [136 (r'_?\d+', Number.Integer),137 ],138 }139 