codekingpro/portable-devtools
114k
1"""2 pygments.lexers.fift3 ~~~~~~~~~~~~~~~~~~~~4 5 Lexers for fift.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, include12from pygments.token import Literal, Comment, Name, String, Number, Whitespace13 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 # numbers37 (r'0x[0-9a-fA-F]+', Number.Hex),38 (r'0b[01]+', Number.Bin),39 (r'-?[0-9]+("/"-?[0-9]+)?', Number.Decimal),40 41 # slices42 (r'b\{[01]+\}', Literal),43 (r'x\{[0-9a-fA-F_]+\}', Literal),44 45 # byte literal46 (r'B\{[0-9a-fA-F_]+\}', Literal),47 48 # treat anything as word49 (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 }69 