summaryrefslogtreecommitdiff
path: root/pygments/lexers/arrow.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/arrow.py')
-rw-r--r--pygments/lexers/arrow.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/pygments/lexers/arrow.py b/pygments/lexers/arrow.py
index b1491c62..560d6de6 100644
--- a/pygments/lexers/arrow.py
+++ b/pygments/lexers/arrow.py
@@ -8,16 +8,18 @@
:copyright: Copyright 2020 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from pygments.lexer import RegexLexer, bygroups, include
+
+from pygments.lexer import RegexLexer, bygroups, default, include
from pygments.token import Text, Operator, Keyword, Punctuation, Name, \
- Whitespace, String, Number
+ String, Number
__all__ = ['ArrowLexer']
TYPES = r'\b(int|bool|char)((?:\[\])*)(?=\s+)'
-IDENT = r'([a-zA-Z_][a-zA-Z0-9_]*)'
+IDENT = r'([a-zA-Z_]\w*)'
DECL = TYPES + r'(\s+)' + IDENT
+
class ArrowLexer(RegexLexer):
"""
Lexer for Arrow: https://pypi.org/project/py-arrow-lang/
@@ -38,9 +40,9 @@ class ArrowLexer(RegexLexer):
include('expressions'),
],
'blocks': [
- (r'(function)(\n+)(/-->)(\s*)'
- + DECL # 4 groups
- + r'(\()', bygroups(
+ (r'(function)(\n+)(/-->)(\s*)' +
+ DECL + # 4 groups
+ r'(\()', bygroups(
Keyword.Reserved, Text, Punctuation,
Text, Keyword.Type, Punctuation, Text,
Name.Function, Punctuation
@@ -60,7 +62,7 @@ class ArrowLexer(RegexLexer):
(r'true|false', Keyword.Constant),
(r"'", String.Char, 'char'),
(r'"', String.Double, 'string'),
- (r'{', Punctuation, 'array'),
+ (r'\{', Punctuation, 'array'),
(r'==|!=|<|>|\+|-|\*|/|%', Operator),
(r'and|or|not|length', Operator.Word),
(r'(input)(\s+)(int|char\[\])', bygroups(
@@ -77,7 +79,7 @@ class ArrowLexer(RegexLexer):
'print': [
include('expressions'),
(r',', Punctuation),
- (r'', Text, '#pop'),
+ default('#pop'),
],
'fparams': [
(DECL, bygroups(Keyword.Type, Punctuation, Text, Name.Variable)),