Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pygments/lexers/ride.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 06:16 +0000

1""" 

2 pygments.lexers.ride 

3 ~~~~~~~~~~~~~~~~~~~~ 

4 

5 Lexer for the Ride programming language. 

6 

7 :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS. 

8 :license: BSD, see LICENSE for details. 

9""" 

10 

11from pygments.lexer import RegexLexer, words, include 

12from pygments.token import Comment, Keyword, Name, Number, Punctuation, \ 

13 String, Text 

14 

15__all__ = ['RideLexer'] 

16 

17 

18class 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 }