From 9db37af14bfdaae6b31b57e5c78d4c3ceb1eeab5 Mon Sep 17 00:00:00 2001 From: Sebastian Engel Date: Sat, 1 Jan 2022 21:08:50 +0100 Subject: Ws token kal lexer --- pygments/lexers/javascript.py | 69 ++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 24 deletions(-) (limited to 'pygments/lexers/javascript.py') diff --git a/pygments/lexers/javascript.py b/pygments/lexers/javascript.py index 6b46c502..e35af2f5 100644 --- a/pygments/lexers/javascript.py +++ b/pygments/lexers/javascript.py @@ -189,18 +189,20 @@ class KalLexer(RegexLexer): flags = re.DOTALL tokens = { 'commentsandwhitespace': [ - (r'\s+', Text), + (r'\s+', Whitespace), (r'###[^#].*?###', Comment.Multiline), - (r'#(?!##[^#]).*?\n', Comment.Single), + (r'(#(?!##[^#]).*?)(\n)', bygroups(Comment.Single, Whitespace)), ], 'functiondef': [ - (r'[$a-zA-Z_][\w$]*\s*', Name.Function, '#pop'), + (r'([$a-zA-Z_][\w$]*)(\s*)', bygroups(Name.Function, Whitespace), + '#pop'), include('commentsandwhitespace'), ], 'classdef': [ - (r'\binherits\s+from\b', Keyword), - (r'[$a-zA-Z_][\w$]*\s*\n', Name.Class, '#pop'), - (r'[$a-zA-Z_][\w$]*\s*', Name.Class), + (r'\b(inherits)(\s+)(from)\b', + bygroups(Keyword, Whitespace, Keyword)), + (r'([$a-zA-Z_][\w$]*)(?=\s*\n)', Name.Class, '#pop'), + (r'[$a-zA-Z_][\w$]*\b', Name.Class), include('commentsandwhitespace'), ], 'listcomprehension': [ @@ -209,7 +211,7 @@ class KalLexer(RegexLexer): include('root'), ], 'waitfor': [ - (r'\n', Punctuation, '#pop'), + (r'\n', Whitespace, '#pop'), (r'\bfrom\b', Keyword), include('root'), ], @@ -221,29 +223,48 @@ class KalLexer(RegexLexer): Operator), (r'\b(and|or|isnt|is|not|but|bitwise|mod|\^|xor|exists|' r'doesnt\s+exist)\b', Operator.Word), - (r'(?:\([^()]+\))?\s*>', Name.Function), + (r'(?:\([^()]+\))?(\s*)(>)', + bygroups(Name.Function, Whitespace, Punctuation)), (r'[{(]', Punctuation), (r'\[', Punctuation, 'listcomprehension'), (r'[})\].,]', Punctuation), (r'\b(function|method|task)\b', Keyword.Declaration, 'functiondef'), (r'\bclass\b', Keyword.Declaration, 'classdef'), - (r'\b(safe\s+)?wait\s+for\b', Keyword, 'waitfor'), + (r'\b(safe(?=\s))?(\s*)(wait(?=\s))(\s+)(for)\b', + bygroups(Keyword, Whitespace, Keyword, Whitespace, + Keyword), 'waitfor'), (r'\b(me|this)(\.[$a-zA-Z_][\w.$]*)?\b', Name.Variable.Instance), - (r'(?