summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2019-05-28 06:45:56 +0200
committerGeorg Brandl <georg@python.org>2019-05-28 06:45:56 +0200
commit85e13c3baefd08d18a0d03baa93db8891d50cbb5 (patch)
treeb4b8f0341e01116bf9edc3c9f437fa511537fa4e
parentb694159eab5a9206b58f126691cde6a9a61311b3 (diff)
downloadpygments-85e13c3baefd08d18a0d03baa93db8891d50cbb5.tar.gz
Boa, SGF: minor fixups
-rw-r--r--pygments/lexers/boa.py46
-rw-r--r--pygments/lexers/sgf.py29
2 files changed, 46 insertions, 29 deletions
diff --git a/pygments/lexers/boa.py b/pygments/lexers/boa.py
index dda31eb4..0ad627d6 100644
--- a/pygments/lexers/boa.py
+++ b/pygments/lexers/boa.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
pygments.lexers.boa
- ~~~~~~~~~~~~~~~~~~~~
+ ~~~~~~~~~~~~~~~~~~~
Lexers for the Boa language.
@@ -12,7 +12,8 @@
import re
from pygments.lexer import RegexLexer, words
-from pygments.token import *
+from pygments.token import String, Comment, Keyword, Name, Number, Text, \
+ Operator, Punctuation
__all__ = ['BoaLexer']
@@ -30,44 +31,53 @@ class BoaLexer(RegexLexer):
filenames = ['*.boa']
reserved = words(
- ('input', 'output', 'of', 'weight', 'before', 'after', 'stop', 'ifall', 'foreach', 'exists', 'function',
- 'break', 'switch', 'case', 'visitor', 'default', 'return', 'visit', 'while', 'if', 'else'),
+ ('input', 'output', 'of', 'weight', 'before', 'after', 'stop',
+ 'ifall', 'foreach', 'exists', 'function', 'break', 'switch', 'case',
+ 'visitor', 'default', 'return', 'visit', 'while', 'if', 'else'),
suffix=r'\b', prefix=r'\b')
keywords = words(
- ('bottom', 'collection', 'maximum', 'mean', 'minimum', 'set', 'sum', 'top', 'string', 'int', 'bool', 'float',
- 'time', 'false', 'true', 'array', 'map', 'stack', 'enum', 'type'), suffix=r'\b', prefix=r'\b')
+ ('bottom', 'collection', 'maximum', 'mean', 'minimum', 'set', 'sum',
+ 'top', 'string', 'int', 'bool', 'float', 'time', 'false', 'true',
+ 'array', 'map', 'stack', 'enum', 'type'), suffix=r'\b', prefix=r'\b')
classes = words(
- ('Project', 'ForgeKind', 'CodeRepository', 'Revision', 'RepositoryKind', 'ChangedFile', 'FileKind', 'ASTRoot',
- 'Namespace', 'Declaration', 'Type', 'Method', 'Variable', 'Statement', 'Expression', 'Modifier',
- 'StatementKind', 'ExpressionKind', 'ModifierKind', 'Visibility', 'TypeKind', 'Person', 'ChangeKind'),
+ ('Project', 'ForgeKind', 'CodeRepository', 'Revision', 'RepositoryKind',
+ 'ChangedFile', 'FileKind', 'ASTRoot', 'Namespace', 'Declaration', 'Type',
+ 'Method', 'Variable', 'Statement', 'Expression', 'Modifier',
+ 'StatementKind', 'ExpressionKind', 'ModifierKind', 'Visibility',
+ 'TypeKind', 'Person', 'ChangeKind'),
suffix=r'\b', prefix=r'\b')
- operators = ('->', ':=', ':', '=', '<<', '!', '++', '||', '&&', '+', '-', '*', ">", "<")
+ operators = ('->', ':=', ':', '=', '<<', '!', '++', '||',
+ '&&', '+', '-', '*', ">", "<")
string_sep = ('`', '\"')
built_in_functions = words(
(
# Array functions
'new', 'sort',
# Date & Time functions
- 'yearof', 'dayofyear', 'hourof', 'minuteof', 'secondof', 'now', 'addday', 'addmonth', 'addweek', 'addyear',
- 'dayofmonth', 'dayofweek', 'dayofyear', 'formattime', 'trunctoday', 'trunctohour', 'trunctominute',
+ 'yearof', 'dayofyear', 'hourof', 'minuteof', 'secondof', 'now',
+ 'addday', 'addmonth', 'addweek', 'addyear', 'dayofmonth', 'dayofweek',
+ 'dayofyear', 'formattime', 'trunctoday', 'trunctohour', 'trunctominute',
'trunctomonth', 'trunctosecond', 'trunctoyear',
# Map functions
'clear', 'haskey', 'keys', 'lookup', 'remove', 'values',
# Math functions
- 'abs', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'cos', 'cosh', 'exp', 'floor',
- 'highbit', 'isfinite', 'isinf', 'isnan', 'isnormal', 'log', 'log10', 'max', 'min', 'nrand', 'pow', 'rand',
- 'round', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc',
+ 'abs', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh',
+ 'ceil', 'cos', 'cosh', 'exp', 'floor', 'highbit', 'isfinite', 'isinf',
+ 'isnan', 'isnormal', 'log', 'log10', 'max', 'min', 'nrand', 'pow',
+ 'rand', 'round', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc',
# Other functions
'def', 'hash', 'len',
# Set functions
'add', 'contains', 'remove',
# String functions
- 'format', 'lowercase', 'match', 'matchposns', 'matchstrs', 'regex', 'split', 'splitall', 'splitn',
- 'strfind', 'strreplace', 'strrfind', 'substring', 'trim', 'uppercase',
+ 'format', 'lowercase', 'match', 'matchposns', 'matchstrs', 'regex',
+ 'split', 'splitall', 'splitn', 'strfind', 'strreplace', 'strrfind',
+ 'substring', 'trim', 'uppercase',
# Type Conversion functions
'bool', 'float', 'int', 'string', 'time',
# Domain-Specific functions
- 'getast', 'getsnapshot', 'hasfiletype', 'isfixingrevision', 'iskind', 'isliteral',
+ 'getast', 'getsnapshot', 'hasfiletype', 'isfixingrevision', 'iskind',
+ 'isliteral',
),
prefix=r'\b',
suffix=r'\(')
diff --git a/pygments/lexers/sgf.py b/pygments/lexers/sgf.py
index aa934b49..b1327919 100644
--- a/pygments/lexers/sgf.py
+++ b/pygments/lexers/sgf.py
@@ -1,28 +1,31 @@
# -*- coding: utf-8 -*-
"""
pygments.lexers.sgf
- ~~~~~~~~~~~~~~~~~~~~
+ ~~~~~~~~~~~~~~~~~~~
Lexer for Smart Game Format (sgf) file format.
- The format is used to store game records of board games for two players
- (mainly Go game).
- For more information about the definition of the format, see:
- https://www.red-bean.com/sgf/
-
:copyright: Copyright 2006-2018 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
-
- .. versionadded:: 2.4
"""
from pygments.lexer import RegexLexer, bygroups
-from pygments.token import *
+from pygments.token import Name, Literal, String, Text, Punctuation
__all__ = ["SmartGameFormatLexer"]
class SmartGameFormatLexer(RegexLexer):
+ """
+ Lexer for Smart Game Format (sgf) file format.
+
+ The format is used to store game records of board games for two players
+ (mainly Go game).
+ For more information about the definition of the format, see:
+ https://www.red-bean.com/sgf/
+
+ .. versionadded:: 2.4
+ """
name = 'SmartGameFormat'
aliases = ['sgf']
filenames = ['*.sgf']
@@ -31,7 +34,11 @@ class SmartGameFormatLexer(RegexLexer):
'root': [
(r'[\s():;]', Punctuation),
# tokens:
- (r'(A[BW]|AE|AN|AP|AR|AS|[BW]L|BM|[BW]R|[BW]S|[BW]T|CA|CH|CP|CR|DD|DM|DO|DT|EL|EV|EX|FF|FG|G[BW]|GC|GM|GN|HA|HO|ID|IP|IT|IY|KM|KO|L|LB|LN|LT|M|MA|MN|N|OB|OM|ON|OP|OT|OV|P[BW]|PC|PL|PM|RE|RG|RO|RU|SO|SC|SE|SI|SL|SO|SQ|ST|SU|SZ|T[BW]|TC|TE|TM|TR|UC|US|V|VW|[BW]|C)',
+ (r'(A[BW]|AE|AN|AP|AR|AS|[BW]L|BM|[BW]R|[BW]S|[BW]T|CA|CH|CP|CR|'
+ r'DD|DM|DO|DT|EL|EV|EX|FF|FG|G[BW]|GC|GM|GN|HA|HO|ID|IP|IT|IY|KM|'
+ r'KO|LB|LN|LT|L|MA|MN|M|N|OB|OM|ON|OP|OT|OV|P[BW]|PC|PL|PM|RE|RG|'
+ r'RO|RU|SO|SC|SE|SI|SL|SO|SQ|ST|SU|SZ|T[BW]|TC|TE|TM|TR|UC|US|VW|'
+ r'V|[BW]|C)',
Name.Builtin),
# number:
(r'(\[)([0-9.]+)(\])',
@@ -50,5 +57,5 @@ class SmartGameFormatLexer(RegexLexer):
bygroups(Punctuation, String, Punctuation)),
(r'(\[)(\s.*)(\])',
bygroups(Punctuation, Text, Punctuation)),
- ],
+ ],
}