summaryrefslogtreecommitdiff
path: root/pygments
diff options
context:
space:
mode:
authorAnteru <bitbucket@ca.sh13.net>2019-03-06 19:05:23 +0000
committerAnteru <bitbucket@ca.sh13.net>2019-03-06 19:05:23 +0000
commitf4fb61d43676c6da6c98493de154ef49987d4fda (patch)
tree9a0cf5ea91eceb53853fcad9aa46137193fc6eac /pygments
parente198bea6ac1c3ca535a08f5cb1a5e21cba7faec5 (diff)
parent1f404da40668543d4b3b4493029f75fe732eca9d (diff)
downloadpygments-f4fb61d43676c6da6c98493de154ef49987d4fda.tar.gz
Merged in taboege/pygments-main (pull request #803)
Add Perl 6 to the language list
Diffstat (limited to 'pygments')
-rw-r--r--pygments/lexers/_mapping.py3
-rw-r--r--pygments/lexers/_vbscript_builtins.py279
-rw-r--r--pygments/lexers/basic.py70
-rw-r--r--pygments/lexers/javascript.py6
-rw-r--r--pygments/lexers/lisp.py2
-rw-r--r--pygments/lexers/php.py5
-rw-r--r--pygments/lexers/r.py2
-rw-r--r--pygments/lexers/shell.py2
-rw-r--r--pygments/lexers/typoscript.py6
9 files changed, 356 insertions, 19 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index 331dadf3..f8207e70 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -428,8 +428,9 @@ LEXERS = {
'TypeScriptLexer': ('pygments.lexers.javascript', 'TypeScript', ('ts', 'typescript'), ('*.ts', '*.tsx'), ('text/x-typescript',)),
'TypoScriptCssDataLexer': ('pygments.lexers.typoscript', 'TypoScriptCssData', ('typoscriptcssdata',), (), ()),
'TypoScriptHtmlDataLexer': ('pygments.lexers.typoscript', 'TypoScriptHtmlData', ('typoscripthtmldata',), (), ()),
- 'TypoScriptLexer': ('pygments.lexers.typoscript', 'TypoScript', ('typoscript',), ('*.ts', '*.txt'), ('text/x-typoscript',)),
+ 'TypoScriptLexer': ('pygments.lexers.typoscript', 'TypoScript', ('typoscript',), ('*.typoscript',), ('text/x-typoscript',)),
'UrbiscriptLexer': ('pygments.lexers.urbi', 'UrbiScript', ('urbiscript',), ('*.u',), ('application/x-urbiscript',)),
+ 'VBScriptLexer': ('pygments.lexers.basic', 'VBScript', (), ('*.vbs', '*.VBS'), ()),
'VCLLexer': ('pygments.lexers.varnish', 'VCL', ('vcl',), ('*.vcl',), ('text/x-vclsrc',)),
'VCLSnippetLexer': ('pygments.lexers.varnish', 'VCLSnippets', ('vclsnippets', 'vclsnippet'), (), ('text/x-vclsnippet',)),
'VCTreeStatusLexer': ('pygments.lexers.console', 'VCTreeStatus', ('vctreestatus',), (), ()),
diff --git a/pygments/lexers/_vbscript_builtins.py b/pygments/lexers/_vbscript_builtins.py
new file mode 100644
index 00000000..7d514790
--- /dev/null
+++ b/pygments/lexers/_vbscript_builtins.py
@@ -0,0 +1,279 @@
+# -*- coding: utf-8 -*-
+"""
+ pygments.lexers._vbscript_builtins
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ These are manually translated lists from
+ http://www.indusoft.com/pdf/VBScript%20Reference.pdf.
+
+ :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+KEYWORDS = [
+ 'ByRef',
+ 'ByVal',
+ # dim: special rule
+ 'call',
+ 'case',
+ 'class',
+ # const: special rule
+ 'do',
+ 'each',
+ 'else',
+ 'elseif',
+ 'end',
+ 'erase',
+ 'execute',
+ 'function',
+ 'exit',
+ 'for',
+ 'function',
+ 'GetRef',
+ 'global',
+ 'if',
+ 'let',
+ 'loop',
+ 'next',
+ 'new',
+ # option: special rule
+ 'private',
+ 'public',
+ 'redim',
+ 'select',
+ 'set',
+ 'sub',
+ 'then',
+ 'wend',
+ 'while',
+ 'with',
+]
+
+BUILTIN_FUNCTIONS = [
+ 'Abs',
+ 'Array',
+ 'Asc',
+ 'Atn',
+ 'CBool',
+ 'CByte',
+ 'CCur',
+ 'CDate',
+ 'CDbl',
+ 'Chr',
+ 'CInt',
+ 'CLng',
+ 'Cos',
+ 'CreateObject',
+ 'CSng',
+ 'CStr',
+ 'Date',
+ 'DateAdd',
+ 'DateDiff',
+ 'DatePart',
+ 'DateSerial',
+ 'DateValue',
+ 'Day',
+ 'Eval',
+ 'Exp',
+ 'Filter',
+ 'Fix',
+ 'FormatCurrency',
+ 'FormatDateTime',
+ 'FormatNumber',
+ 'FormatPercent',
+ 'GetObject',
+ 'GetLocale',
+ 'Hex',
+ 'Hour',
+ 'InStr',
+ 'inStrRev',
+ 'Int',
+ 'IsArray',
+ 'IsDate',
+ 'IsEmpty',
+ 'IsNull',
+ 'IsNumeric',
+ 'IsObject',
+ 'Join',
+ 'LBound',
+ 'LCase',
+ 'Left',
+ 'Len',
+ 'LoadPicture',
+ 'Log',
+ 'LTrim',
+ 'Mid',
+ 'Minute',
+ 'Month',
+ 'MonthName',
+ 'MsgBox',
+ 'Now',
+ 'Oct',
+ 'Randomize',
+ 'RegExp',
+ 'Replace',
+ 'RGB',
+ 'Right',
+ 'Rnd',
+ 'Round',
+ 'RTrim',
+ 'ScriptEngine',
+ 'ScriptEngineBuildVersion',
+ 'ScriptEngineMajorVersion',
+ 'ScriptEngineMinorVersion',
+ 'Second',
+ 'SetLocale',
+ 'Sgn',
+ 'Space',
+ 'Split',
+ 'Sqr',
+ 'StrComp',
+ 'String',
+ 'StrReverse',
+ 'Tan',
+ 'Time',
+ 'Timer',
+ 'TimeSerial',
+ 'TimeValue',
+ 'Trim',
+ 'TypeName',
+ 'UBound',
+ 'UCase',
+ 'VarType',
+ 'Weekday',
+ 'WeekdayName',
+ 'Year',
+]
+
+BUILTIN_VARIABLES = [
+ 'Debug',
+ 'Dictionary',
+ 'Drive',
+ 'Drives',
+ 'Err',
+ 'File',
+ 'Files',
+ 'FileSystemObject',
+ 'Folder',
+ 'Folders',
+ 'Match',
+ 'Matches',
+ 'RegExp',
+ 'Submatches',
+ 'TextStream',
+]
+
+OPERATORS = [
+ '+',
+ '-',
+ '*',
+ '/',
+ '\\',
+ '^',
+ '|',
+ '<',
+ '<=',
+ '>',
+ '>=',
+ '=',
+ '<>',
+ '&',
+ '$',
+]
+
+OPERATOR_WORDS = [
+ 'mod',
+ 'and',
+ 'or',
+ 'xor',
+ 'eqv',
+ 'imp',
+ 'is',
+ 'not',
+]
+
+BUILTIN_CONSTANTS = [
+ 'False',
+ 'True',
+ 'vbAbort',
+ 'vbAbortRetryIgnore',
+ 'vbApplicationModal',
+ 'vbArray',
+ 'vbBinaryCompare',
+ 'vbBlack',
+ 'vbBlue',
+ 'vbBoole',
+ 'vbByte',
+ 'vbCancel',
+ 'vbCr',
+ 'vbCritical',
+ 'vbCrLf',
+ 'vbCurrency',
+ 'vbCyan',
+ 'vbDataObject',
+ 'vbDate',
+ 'vbDefaultButton1',
+ 'vbDefaultButton2',
+ 'vbDefaultButton3',
+ 'vbDefaultButton4',
+ 'vbDouble',
+ 'vbEmpty',
+ 'vbError',
+ 'vbExclamation',
+ 'vbFalse',
+ 'vbFirstFullWeek',
+ 'vbFirstJan1',
+ 'vbFormFeed',
+ 'vbFriday',
+ 'vbGeneralDate',
+ 'vbGreen',
+ 'vbIgnore',
+ 'vbInformation',
+ 'vbInteger',
+ 'vbLf',
+ 'vbLong',
+ 'vbLongDate',
+ 'vbLongTime',
+ 'vbMagenta',
+ 'vbMonday',
+ 'vbMsgBoxHelpButton',
+ 'vbMsgBoxRight',
+ 'vbMsgBoxRtlReading',
+ 'vbMsgBoxSetForeground',
+ 'vbNewLine',
+ 'vbNo',
+ 'vbNull',
+ 'vbNullChar',
+ 'vbNullString',
+ 'vbObject',
+ 'vbObjectError',
+ 'vbOK',
+ 'vbOKCancel',
+ 'vbOKOnly',
+ 'vbQuestion',
+ 'vbRed',
+ 'vbRetry',
+ 'vbRetryCancel',
+ 'vbSaturday',
+ 'vbShortDate',
+ 'vbShortTime',
+ 'vbSingle',
+ 'vbString',
+ 'vbSunday',
+ 'vbSystemModal',
+ 'vbTab',
+ 'vbTextCompare',
+ 'vbThursday',
+ 'vbTrue',
+ 'vbTuesday',
+ 'vbUseDefault',
+ 'vbUseSystem',
+ 'vbUseSystem',
+ 'vbVariant',
+ 'vbVerticalTab',
+ 'vbWednesday',
+ 'vbWhite',
+ 'vbYellow',
+ 'vbYes',
+ 'vbYesNo',
+ 'vbYesNoCancel',
+] \ No newline at end of file
diff --git a/pygments/lexers/basic.py b/pygments/lexers/basic.py
index e6545ee6..f5f0498e 100644
--- a/pygments/lexers/basic.py
+++ b/pygments/lexers/basic.py
@@ -12,11 +12,13 @@
import re
from pygments.lexer import RegexLexer, bygroups, default, words, include
-from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
- Number, Punctuation
+from pygments.token import Comment, Error, Keyword, Name, Number, \
+ Punctuation, Operator, String, Text, Whitespace
+from pygments.lexers import _vbscript_builtins
+
__all__ = ['BlitzBasicLexer', 'BlitzMaxLexer', 'MonkeyLexer', 'CbmBasicV2Lexer',
- 'QBasicLexer']
+ 'QBasicLexer', 'VBScriptLexer']
class BlitzMaxLexer(RegexLexer):
@@ -498,3 +500,65 @@ class QBasicLexer(RegexLexer):
def analyse_text(text):
if '$DYNAMIC' in text or '$STATIC' in text:
return 0.9
+
+
+class VBScriptLexer(RegexLexer):
+ """
+ VBScript is scripting language that is modeled on Visual Basic.
+
+ .. versionadded:: 2.4
+ """
+ name = 'VBScript'
+ aliases = []
+ filenames = ['*.vbs', '*.VBS']
+ flags = re.IGNORECASE
+
+ tokens = {
+ 'root': [
+ (r"'[^\n]*", Comment.Single),
+ (r'\s+', Whitespace),
+ ('"', String.Double, 'string'),
+ ('&h[0-9a-f]+', Number.Hex),
+ # Float variant 1, for example: 1., 1.e2, 1.2e3
+ (r'[0-9]+\.[0-9]*(e[+-]?[0-9]+)?', Number.Float),
+ (r'\.[0-9]+(e[+-]?[0-9]+)?', Number.Float), # Float variant 2, for example: .1, .1e2
+ (r'[0-9]+e[+-]?[0-9]+', Number.Float), # Float variant 3, for example: 123e45
+ ('\d+', Number.Integer),
+ ('#.+#', String), # date or time value
+ (r'(dim)(\s+)([a-z_][a-z0-9_]*)',
+ bygroups(Keyword.Declaration, Whitespace, Name.Variable), 'dim_more'),
+ (r'(function|sub)(\s+)([a-z_][a-z0-9_]*)',
+ bygroups(Keyword.Declaration, Whitespace, Name.Function)),
+ (r'(class)(\s+)([a-z_][a-z0-9_]*)', bygroups(Keyword.Declaration, Whitespace, Name.Class)),
+ (r'(const)(\s+)([a-z_][a-z0-9_]*)', bygroups(Keyword.Declaration, Whitespace, Name.Constant)),
+ (r'(end)(\s+)(class|function|if|property|sub|with)', bygroups(Keyword, Whitespace, Keyword)),
+ (r'(on)(\s+)(error)(\s+)(goto)(\s+)(0)',
+ bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword, Whitespace, Number.Integer)),
+ (r'(on)(\s+)(error)(\s+)(resume)(\s+)(next)',
+ bygroups(Keyword, Whitespace, Keyword, Whitespace, Keyword, Whitespace, Keyword)),
+ (r'(option)(\s+)(explicit)', bygroups(Keyword, Whitespace, Keyword)),
+ (r'(property)(\s+)(get|let|set)(\s+)([a-z_][a-z0-9_]*)',
+ bygroups(Keyword.Declaration, Whitespace, Keyword.Declaration, Whitespace, Name.Property)),
+ (r'rem\s.*[^\n]*', Comment.Single),
+ (words(_vbscript_builtins.KEYWORDS, suffix=r'\b'), Keyword),
+ (words(_vbscript_builtins.OPERATORS), Operator),
+ (words(_vbscript_builtins.OPERATOR_WORDS, suffix=r'\b'), Operator.Word),
+ (words(_vbscript_builtins.BUILTIN_CONSTANTS, suffix=r'\b'), Name.Constant),
+ (words(_vbscript_builtins.BUILTIN_FUNCTIONS, suffix=r'\b'), Name.Builtin),
+ (words(_vbscript_builtins.BUILTIN_VARIABLES, suffix=r'\b'), Name.Builtin),
+ (r'[a-z_][a-z0-9_]*', Name),
+ (r'\b_\n', Operator),
+ (words(r'(),.:'), Punctuation),
+ ('.+(\n)?', Error)
+ ],
+ 'dim_more': [
+ (r'(\s*)(,)(\s*)([a-z_][a-z0-9]*)', bygroups(Whitespace, Punctuation, Whitespace, Name.Variable)),
+ default('#pop'),
+ ],
+ 'string': [
+ (r'[^"\n]+', String.Double),
+ (r'\"\"', String.Double),
+ (r'"', String.Double, '#pop'),
+ (r'\n', Error, '#pop'), # Unterminated string
+ ],
+ } \ No newline at end of file
diff --git a/pygments/lexers/javascript.py b/pygments/lexers/javascript.py
index 87c4af2d..0507375f 100644
--- a/pygments/lexers/javascript.py
+++ b/pygments/lexers/javascript.py
@@ -538,12 +538,6 @@ class TypeScriptLexer(RegexLexer):
],
}
- def analyse_text(text):
- if re.search(r'^(import.+(from\s+)?["\']|'
- r'(export\s*)?(interface|class|function)\s+)',
- text, re.MULTILINE):
- return 1.0
-
class LassoLexer(RegexLexer):
"""
diff --git a/pygments/lexers/lisp.py b/pygments/lexers/lisp.py
index ba3fd403..3bfc83a6 100644
--- a/pygments/lexers/lisp.py
+++ b/pygments/lexers/lisp.py
@@ -1400,7 +1400,7 @@ class RacketLexer(RegexLexer):
class NewLispLexer(RegexLexer):
"""
- For `newLISP. <www.newlisp.org>`_ source code (version 10.3.0).
+ For `newLISP. <http://www.newlisp.org/>`_ source code (version 10.3.0).
.. versionadded:: 1.5
"""
diff --git a/pygments/lexers/php.py b/pygments/lexers/php.py
index f959fb1f..440d9d81 100644
--- a/pygments/lexers/php.py
+++ b/pygments/lexers/php.py
@@ -15,7 +15,8 @@ from pygments.lexer import RegexLexer, include, bygroups, default, using, \
this, words
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
Number, Punctuation, Other
-from pygments.util import get_bool_opt, get_list_opt, iteritems
+from pygments.util import get_bool_opt, get_list_opt, iteritems, \
+ shebang_matches
__all__ = ['ZephirLexer', 'PhpLexer']
@@ -261,6 +262,8 @@ class PhpLexer(RegexLexer):
yield index, token, value
def analyse_text(text):
+ if shebang_matches(text, r'php'):
+ return True
rv = 0.0
if re.search(r'<\?(?!xml)', text):
rv += 0.3
diff --git a/pygments/lexers/r.py b/pygments/lexers/r.py
index 0829ae6e..66d6402c 100644
--- a/pygments/lexers/r.py
+++ b/pygments/lexers/r.py
@@ -161,7 +161,7 @@ class RdLexer(RegexLexer):
This is a very minimal implementation, highlighting little more
than the macros. A description of Rd syntax is found in `Writing R
Extensions <http://cran.r-project.org/doc/manuals/R-exts.html>`_
- and `Parsing Rd files <developer.r-project.org/parseRd.pdf>`_.
+ and `Parsing Rd files <http://developer.r-project.org/parseRd.pdf>`_.
.. versionadded:: 1.6
"""
diff --git a/pygments/lexers/shell.py b/pygments/lexers/shell.py
index 86d8c37a..31bc7e94 100644
--- a/pygments/lexers/shell.py
+++ b/pygments/lexers/shell.py
@@ -76,7 +76,7 @@ class BashLexer(RegexLexer):
(r'&&|\|\|', Operator),
],
'data': [
- (r'(?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\$])*"', String.Double),
+ (r'(?s)\$?"(\\.|[^"\\$])*"', String.Double),
(r'"', String.Double, 'string'),
(r"(?s)\$'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
(r"(?s)'.*?'", String.Single),
diff --git a/pygments/lexers/typoscript.py b/pygments/lexers/typoscript.py
index 6e1c3155..f75a6f02 100644
--- a/pygments/lexers/typoscript.py
+++ b/pygments/lexers/typoscript.py
@@ -108,7 +108,7 @@ class TypoScriptLexer(RegexLexer):
name = 'TypoScript'
aliases = ['typoscript']
- filenames = ['*.ts', '*.txt']
+ filenames = ['*.typoscript']
mimetypes = ['text/x-typoscript']
flags = re.DOTALL | re.MULTILINE
@@ -220,7 +220,3 @@ class TypoScriptLexer(RegexLexer):
(r'[\w"\-!/&;]+', Text),
],
}
-
- def analyse_text(text):
- if '<INCLUDE_TYPOSCRIPT:' in text:
- return 1.0