Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pygments/lexers/floscript.py: 91%
11 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:16 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:16 +0000
1"""
2 pygments.lexers.floscript
3 ~~~~~~~~~~~~~~~~~~~~~~~~~
5 Lexer for FloScript
7 :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
8 :license: BSD, see LICENSE for details.
9"""
11from pygments.lexer import RegexLexer, include, bygroups
12from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
13 Number, Punctuation, Whitespace
15__all__ = ['FloScriptLexer']
18class FloScriptLexer(RegexLexer):
19 """
20 For FloScript configuration language source code.
22 .. versionadded:: 2.4
23 """
25 name = 'FloScript'
26 url = 'https://github.com/ioflo/ioflo'
27 aliases = ['floscript', 'flo']
28 filenames = ['*.flo']
30 def innerstring_rules(ttype):
31 return [
32 # the old style '%s' % (...) string formatting
33 (r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?'
34 '[hlL]?[E-GXc-giorsux%]', String.Interpol),
35 # backslashes, quotes and formatting signs must be parsed one at a time
36 (r'[^\\\'"%\n]+', ttype),
37 (r'[\'"\\]', ttype),
38 # unhandled string formatting sign
39 (r'%', ttype),
40 # newlines are an error (use "nl" state)
41 ]
43 tokens = {
44 'root': [
45 (r'\s+', Whitespace),
47 (r'[]{}:(),;[]', Punctuation),
48 (r'(\\)(\n)', bygroups(Text, Whitespace)),
49 (r'\\', Text),
50 (r'(to|by|with|from|per|for|cum|qua|via|as|at|in|of|on|re|is|if|be|into|'
51 r'and|not)\b', Operator.Word),
52 (r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator),
53 (r'(load|init|server|logger|log|loggee|first|over|under|next|done|timeout|'
54 r'repeat|native|benter|enter|recur|exit|precur|renter|rexit|print|put|inc|'
55 r'copy|set|aux|rear|raze|go|let|do|bid|ready|start|stop|run|abort|use|flo|'
56 r'give|take)\b', Name.Builtin),
57 (r'(frame|framer|house)\b', Keyword),
58 ('"', String, 'string'),
60 include('name'),
61 include('numbers'),
62 (r'#.+$', Comment.Single),
63 ],
64 'string': [
65 ('[^"]+', String),
66 ('"', String, '#pop'),
67 ],
68 'numbers': [
69 (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float),
70 (r'\d+[eE][+-]?[0-9]+j?', Number.Float),
71 (r'0[0-7]+j?', Number.Oct),
72 (r'0[bB][01]+', Number.Bin),
73 (r'0[xX][a-fA-F0-9]+', Number.Hex),
74 (r'\d+L', Number.Integer.Long),
75 (r'\d+j?', Number.Integer)
76 ],
78 'name': [
79 (r'@[\w.]+', Name.Decorator),
80 (r'[a-zA-Z_]\w*', Name),
81 ],
82 }