ThirdParty/Pygments/pygments/lexers/configs.py

changeset 6651
e8f3b5568b21
parent 5713
6762afd9f963
equal deleted inserted replaced
6650:1dd52aa8897c 6651:e8f3b5568b21
13 13
14 from pygments.lexer import RegexLexer, default, words, bygroups, include, using 14 from pygments.lexer import RegexLexer, default, words, bygroups, include, using
15 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ 15 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
16 Number, Punctuation, Whitespace, Literal 16 Number, Punctuation, Whitespace, Literal
17 from pygments.lexers.shell import BashLexer 17 from pygments.lexers.shell import BashLexer
18 from pygments.lexers.data import JsonLexer
18 19
19 __all__ = ['IniLexer', 'RegeditLexer', 'PropertiesLexer', 'KconfigLexer', 20 __all__ = ['IniLexer', 'RegeditLexer', 'PropertiesLexer', 'KconfigLexer',
20 'Cfengine3Lexer', 'ApacheConfLexer', 'SquidConfLexer', 21 'Cfengine3Lexer', 'ApacheConfLexer', 'SquidConfLexer',
21 'NginxConfLexer', 'LighttpdConfLexer', 'DockerLexer', 22 'NginxConfLexer', 'LighttpdConfLexer', 'DockerLexer',
22 'TerraformLexer', 'TermcapLexer', 'TerminfoLexer', 23 'TerraformLexer', 'TermcapLexer', 'TerminfoLexer',
537 name = 'Docker' 538 name = 'Docker'
538 aliases = ['docker', 'dockerfile'] 539 aliases = ['docker', 'dockerfile']
539 filenames = ['Dockerfile', '*.docker'] 540 filenames = ['Dockerfile', '*.docker']
540 mimetypes = ['text/x-dockerfile-config'] 541 mimetypes = ['text/x-dockerfile-config']
541 542
542 _keywords = (r'(?:FROM|MAINTAINER|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|' 543 _keywords = (r'(?:FROM|MAINTAINER|EXPOSE|WORKDIR|USER|STOPSIGNAL)')
543 r'VOLUME|WORKDIR)') 544 _bash_keywords = (r'(?:RUN|CMD|ENTRYPOINT|ENV|ARG|LABEL|ADD|COPY)')
544 545 _lb = r'(?:\s*\\?\s*)' # dockerfile line break regex
545 flags = re.IGNORECASE | re.MULTILINE 546 flags = re.IGNORECASE | re.MULTILINE
546 547
547 tokens = { 548 tokens = {
548 'root': [ 549 'root': [
549 (r'^(ONBUILD)(\s+)(%s)\b' % (_keywords,),
550 bygroups(Name.Keyword, Whitespace, Keyword)),
551 (r'^(%s)\b(.*)' % (_keywords,), bygroups(Keyword, String)),
552 (r'#.*', Comment), 550 (r'#.*', Comment),
553 (r'RUN', Keyword), # Rest of line falls through 551 (r'(ONBUILD)(%s)' % (_lb,), bygroups(Keyword, using(BashLexer))),
552 (r'(HEALTHCHECK)((%s--\w+=\w+%s)*)' % (_lb, _lb),
553 bygroups(Keyword, using(BashLexer))),
554 (r'(VOLUME|ENTRYPOINT|CMD|SHELL)(%s)(\[.*?\])' % (_lb,),
555 bygroups(Keyword, using(BashLexer), using(JsonLexer))),
556 (r'(LABEL|ENV|ARG)((%s\w+=\w+%s)*)' % (_lb, _lb),
557 bygroups(Keyword, using(BashLexer))),
558 (r'(%s|VOLUME)\b(.*)' % (_keywords), bygroups(Keyword, String)),
559 (r'(%s)' % (_bash_keywords,), Keyword),
554 (r'(.*\\\n)*.+', using(BashLexer)), 560 (r'(.*\\\n)*.+', using(BashLexer)),
555 ], 561 ]
556 } 562 }
557 563
558 564
559 class TerraformLexer(RegexLexer): 565 class TerraformLexer(RegexLexer):
560 """ 566 """
582 (r'\s*/\*', Comment.Multiline, 'comment'), 588 (r'\s*/\*', Comment.Multiline, 'comment'),
583 (r'\s*#.*\n', Comment.Single), 589 (r'\s*#.*\n', Comment.Single),
584 (r'(.*?)(\s*)(=)', bygroups(Name.Attribute, Text, Operator)), 590 (r'(.*?)(\s*)(=)', bygroups(Name.Attribute, Text, Operator)),
585 (words(('variable', 'resource', 'provider', 'provisioner', 'module'), 591 (words(('variable', 'resource', 'provider', 'provisioner', 'module'),
586 prefix=r'\b', suffix=r'\b'), Keyword.Reserved, 'function'), 592 prefix=r'\b', suffix=r'\b'), Keyword.Reserved, 'function'),
587 (words(('ingress', 'egress', 'listener', 'default', 'connection'), 593 (words(('ingress', 'egress', 'listener', 'default', 'connection', 'alias'),
588 prefix=r'\b', suffix=r'\b'), Keyword.Declaration), 594 prefix=r'\b', suffix=r'\b'), Keyword.Declaration),
589 ('\$\{', String.Interpol, 'var_builtin'), 595 (r'\$\{', String.Interpol, 'var_builtin'),
590 ], 596 ],
591 'function': [ 597 'function': [
592 (r'(\s+)(".*")(\s+)', bygroups(Text, String, Text)), 598 (r'(\s+)(".*")(\s+)', bygroups(Text, String, Text)),
593 include('punctuation'), 599 include('punctuation'),
594 include('curly'), 600 include('curly'),

eric ide

mercurial