diff options
author | Matth?us G. Chajdas <dev@anteru.net> | 2019-11-10 13:56:53 +0100 |
---|---|---|
committer | Matth?us G. Chajdas <dev@anteru.net> | 2019-11-10 13:56:53 +0100 |
commit | 1dd3124a9770e11b6684e5dd1e6bc15a0aa3bc67 (patch) | |
tree | 87a171383266dd1f64196589af081bc2f8e497c3 /pygments/lexers/resource.py | |
parent | f1c080e184dc1bbc36eaa7cd729ff3a499de568a (diff) | |
download | pygments-master.tar.gz |
Diffstat (limited to 'pygments/lexers/resource.py')
-rw-r--r-- | pygments/lexers/resource.py | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/pygments/lexers/resource.py b/pygments/lexers/resource.py deleted file mode 100644 index 6cc88b95..00000000 --- a/pygments/lexers/resource.py +++ /dev/null @@ -1,85 +0,0 @@ -# -*- coding: utf-8 -*- -""" - pygments.lexers.resource - ~~~~~~~~~~~~~~~~~~~~~~~~ - - Lexer for resource definition files. - - :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. - :license: BSD, see LICENSE for details. -""" - -import re - -from pygments.lexer import RegexLexer, bygroups, words -from pygments.token import Comment, String, Number, Operator, Text, \ - Keyword, Name - -__all__ = ['ResourceLexer'] - - -class ResourceLexer(RegexLexer): - """Lexer for `ICU Resource bundles - <http://userguide.icu-project.org/locale/resources>`_. - - .. versionadded:: 2.0 - """ - name = 'ResourceBundle' - aliases = ['resource', 'resourcebundle'] - filenames = ['*.txt'] - - _types = (':table', ':array', ':string', ':bin', ':import', ':intvector', - ':int', ':alias') - - flags = re.MULTILINE | re.IGNORECASE - tokens = { - 'root': [ - (r'//.*?$', Comment), - (r'"', String, 'string'), - (r'-?\d+', Number.Integer), - (r'[,{}]', Operator), - (r'([^\s{:]+)(\s*)(%s?)' % '|'.join(_types), - bygroups(Name, Text, Keyword)), - (r'\s+', Text), - (words(_types), Keyword), - ], - 'string': [ - (r'(\\x[0-9a-f]{2}|\\u[0-9a-f]{4}|\\U00[0-9a-f]{6}|' - r'\\[0-7]{1,3}|\\c.|\\[abtnvfre\'"?\\]|\\\{|[^"{\\])+', String), - (r'\{', String.Escape, 'msgname'), - (r'"', String, '#pop') - ], - 'msgname': [ - (r'([^{},]+)(\s*)', bygroups(Name, String.Escape), ('#pop', 'message')) - ], - 'message': [ - (r'\{', String.Escape, 'msgname'), - (r'\}', String.Escape, '#pop'), - (r'(,)(\s*)([a-z]+)(\s*\})', - bygroups(Operator, String.Escape, Keyword, String.Escape), '#pop'), - (r'(,)(\s*)([a-z]+)(\s*)(,)(\s*)(offset)(\s*)(:)(\s*)(-?\d+)(\s*)', - bygroups(Operator, String.Escape, Keyword, String.Escape, Operator, - String.Escape, Operator.Word, String.Escape, Operator, - String.Escape, Number.Integer, String.Escape), 'choice'), - (r'(,)(\s*)([a-z]+)(\s*)(,)(\s*)', - bygroups(Operator, String.Escape, Keyword, String.Escape, Operator, - String.Escape), 'choice'), - (r'\s+', String.Escape) - ], - 'choice': [ - (r'(=|<|>|<=|>=|!=)(-?\d+)(\s*\{)', - bygroups(Operator, Number.Integer, String.Escape), 'message'), - (r'([a-z]+)(\s*\{)', bygroups(Keyword.Type, String.Escape), 'str'), - (r'\}', String.Escape, ('#pop', '#pop')), - (r'\s+', String.Escape) - ], - 'str': [ - (r'\}', String.Escape, '#pop'), - (r'\{', String.Escape, 'msgname'), - (r'[^{}]+', String) - ] - } - - def analyse_text(text): - if text.startswith('root:table'): - return 1.0 |