summaryrefslogtreecommitdiff
path: root/pygments
diff options
context:
space:
mode:
authorRob Hoelz <rob@hoelz.ro>2013-03-22 22:57:03 +0100
committerRob Hoelz <rob@hoelz.ro>2013-03-22 22:57:03 +0100
commit1fd088dc8a3d6d2152c6cb3d3c51224759489868 (patch)
tree2590c8fa0850218f1e022f6627f8327f6a22e573 /pygments
parent35b98cf6a2c55e851c571bde916ad8f1c535a624 (diff)
downloadpygments-1fd088dc8a3d6d2152c6cb3d3c51224759489868.tar.gz
Enter a 'pre-token' state after seeing a token keyword (regex, token, or rule)
This is so that any Perl 6 code between the keyword and the opening brace may be properly parsed. Handles code like this: token something(@params) { ... }
Diffstat (limited to 'pygments')
-rw-r--r--pygments/lexers/agile.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py
index f207bcc1..685b622a 100644
--- a/pygments/lexers/agile.py
+++ b/pygments/lexers/agile.py
@@ -2164,7 +2164,7 @@ class Perl6Lexer(ExtendedRegexLexer):
( r'^(\s*)=begin\s+(\w+)\b.*?^\1=end\s+\2', Comment.Multiline ),
( r'^(\s*)=for.*?\n\s*?\n', Comment.Multiline ),
( r'^=.*?\n\s*?\n', Comment.Multiline ),
- ( r'(regex|token|rule)(?![' + PERL6_IDENTIFIER_CHARS + '])(\s*[' + PERL6_IDENTIFIER_CHARS + ']+:sym<.*?>)?(.*?)([{])', bygroups(Keyword, Name, Name, Text), 'token' ),
+ ( r'(regex|token|rule)(?![' + PERL6_IDENTIFIER_CHARS + '])(\s*[' + PERL6_IDENTIFIER_CHARS + ']+:sym<.*?>)?', bygroups(Keyword, Name), 'pre-token' ),
# deal with a special class in the Perl 6 grammar (role q { ... })
( r'(role)(\s*)(q)(\s*)', bygroups(Keyword, Text, Name, Text) ),
( _build_word_match(PERL6_KEYWORDS, PERL6_IDENTIFIER_CHARS), Keyword ),
@@ -2201,6 +2201,11 @@ class Perl6Lexer(ExtendedRegexLexer):
( r'[}]', closing_brace_callback ),
( r'.+?', Text ),
],
+ 'pre-token' : [
+ include('common'),
+ ( r'[{]', Text, ( '#pop', 'token' ) ),
+ ( r'.+?', Text ),
+ ],
# the tokens state rules are defined after the class body, for reasons
# explained below.
}