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

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

13 statements  

1""" 

2 pygments.lexers.floscript 

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

4 

5 Lexer for FloScript 

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, bygroups 

12from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ 

13 Number, Punctuation, Whitespace 

14 

15__all__ = ['FloScriptLexer'] 

16 

17 

18class FloScriptLexer(RegexLexer): 

19 """ 

20 For FloScript configuration language source code. 

21 """ 

22 

23 name = 'FloScript' 

24 url = 'https://github.com/ioflo/ioflo' 

25 aliases = ['floscript', 'flo'] 

26 filenames = ['*.flo'] 

27 version_added = '2.4' 

28 

29 def innerstring_rules(ttype): 

30 return [ 

31 # the old style '%s' % (...) string formatting 

32 (r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' 

33 '[hlL]?[E-GXc-giorsux%]', String.Interpol), 

34 # backslashes, quotes and formatting signs must be parsed one at a time 

35 (r'[^\\\'"%\n]+', ttype), 

36 (r'[\'"\\]', ttype), 

37 # unhandled string formatting sign 

38 (r'%', ttype), 

39 # newlines are an error (use "nl" state) 

40 ] 

41 

42 tokens = { 

43 'root': [ 

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

45 

46 (r'[]{}:(),;[]', Punctuation), 

47 (r'(\\)(\n)', bygroups(Text, Whitespace)), 

48 (r'\\', Text), 

49 (r'(to|by|with|from|per|for|cum|qua|via|as|at|in|of|on|re|is|if|be|into|' 

50 r'and|not)\b', Operator.Word), 

51 (r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator), 

52 (r'(load|init|server|logger|log|loggee|first|over|under|next|done|timeout|' 

53 r'repeat|native|benter|enter|recur|exit|precur|renter|rexit|print|put|inc|' 

54 r'copy|set|aux|rear|raze|go|let|do|bid|ready|start|stop|run|abort|use|flo|' 

55 r'give|take)\b', Name.Builtin), 

56 (r'(frame|framer|house)\b', Keyword), 

57 ('"', String, 'string'), 

58 

59 include('name'), 

60 include('numbers'), 

61 (r'#.+$', Comment.Single), 

62 ], 

63 'string': [ 

64 ('[^"]+', String), 

65 ('"', String, '#pop'), 

66 ], 

67 'numbers': [ 

68 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float), 

69 (r'\d+[eE][+-]?[0-9]+j?', Number.Float), 

70 (r'0[0-7]+j?', Number.Oct), 

71 (r'0[bB][01]+', Number.Bin), 

72 (r'0[xX][a-fA-F0-9]+', Number.Hex), 

73 (r'\d+L', Number.Integer.Long), 

74 (r'\d+j?', Number.Integer) 

75 ], 

76 

77 'name': [ 

78 (r'@[\w.]+', Name.Decorator), 

79 (r'[a-zA-Z_]\w*', Name), 

80 ], 

81 }