Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pygments/lexers/trafficscript.py: 100%
8 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.trafficscript
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 Lexer for RiverBed's TrafficScript (RTS) language.
7 :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
8 :license: BSD, see LICENSE for details.
9"""
11from pygments.lexer import RegexLexer
12from pygments.token import String, Number, Name, Keyword, Operator, Text, Comment
14__all__ = ['RtsLexer']
17class RtsLexer(RegexLexer):
18 """
19 For Riverbed Stingray Traffic Manager
21 .. versionadded:: 2.1
22 """
23 name = 'TrafficScript'
24 aliases = ['trafficscript', 'rts']
25 filenames = ['*.rts']
27 tokens = {
28 'root' : [
29 (r"'(\\\\|\\[^\\]|[^'\\])*'", String),
30 (r'"', String, 'escapable-string'),
31 (r'(0x[0-9a-fA-F]+|\d+)', Number),
32 (r'\d+\.\d+', Number.Float),
33 (r'\$[a-zA-Z](\w|_)*', Name.Variable),
34 (r'(if|else|for(each)?|in|while|do|break|sub|return|import)', Keyword),
35 (r'[a-zA-Z][\w.]*', Name.Function),
36 (r'[-+*/%=,;(){}<>^.!~|&\[\]\?\:]', Operator),
37 (r'(>=|<=|==|!=|'
38 r'&&|\|\||'
39 r'\+=|.=|-=|\*=|/=|%=|<<=|>>=|&=|\|=|\^=|'
40 r'>>|<<|'
41 r'\+\+|--|=>)', Operator),
42 (r'[ \t\r]+', Text),
43 (r'#[^\n]*', Comment),
44 ],
45 'escapable-string' : [
46 (r'\\[tsn]', String.Escape),
47 (r'[^"]', String),
48 (r'"', String, '#pop'),
49 ],
51 }