eric6/ThirdParty/Pygments/pygments/lexers/ride.py

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

eric ide

mercurial