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

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

11 statements  

1""" 

2 pygments.lexers.fift 

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

4 

5 Lexers for fift. 

6 

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

8 :license: BSD, see LICENSE for details. 

9""" 

10 

11from pygments.lexer import RegexLexer, include 

12from pygments.token import Literal, Comment, Name, String, Number, Whitespace 

13 

14__all__ = ['FiftLexer'] 

15 

16 

17class FiftLexer(RegexLexer): 

18 """ 

19 For Fift source code. 

20 """ 

21 

22 name = 'Fift' 

23 aliases = ['fift', 'fif'] 

24 filenames = ['*.fif'] 

25 url = 'https://ton-blockchain.github.io/docs/fiftbase.pdf' 

26 version_added = '' 

27 

28 tokens = { 

29 'root': [ 

30 (r'\s+', Whitespace), 

31 

32 include('comments'), 

33 

34 (r'[\.+]?\"', String, 'string'), 

35 

36 # numbers 

37 (r'0x[0-9a-fA-F]+', Number.Hex), 

38 (r'0b[01]+', Number.Bin), 

39 (r'-?[0-9]+("/"-?[0-9]+)?', Number.Decimal), 

40 

41 # slices 

42 (r'b\{[01]+\}', Literal), 

43 (r'x\{[0-9a-fA-F_]+\}', Literal), 

44 

45 # byte literal 

46 (r'B\{[0-9a-fA-F_]+\}', Literal), 

47 

48 # treat anything as word 

49 (r'\S+', Name) 

50 ], 

51 

52 'string': [ 

53 (r'\\.', String.Escape), 

54 (r'\"', String, '#pop'), 

55 (r'[^\"\r\n\\]+', String) 

56 ], 

57 

58 'comments': [ 

59 (r'//.*', Comment.Singleline), 

60 (r'/\*', Comment.Multiline, 'comment'), 

61 ], 

62 'comment': [ 

63 (r'[^/*]+', Comment.Multiline), 

64 (r'/\*', Comment.Multiline, '#push'), 

65 (r'\*/', Comment.Multiline, '#pop'), 

66 (r'[*/]', Comment.Multiline), 

67 ], 

68 }