summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTinnet Coronam <tinnet@coronam.net>2012-10-17 01:39:47 +0200
committerTinnet Coronam <tinnet@coronam.net>2012-10-17 01:39:47 +0200
commitd2b65a6a1bd4093f64c43c92e493b17ef41586ea (patch)
tree0ffb1c15ea95793dcb922d49337b742ff7150fca
parenta65c47f6c5ff7a870dcb4eab85c281b1eb4e854c (diff)
downloadpygments-d2b65a6a1bd4093f64c43c92e493b17ef41586ea.tar.gz
more noncapture and switched to multiline mode to get prettier tokenstream
-rw-r--r--pygments/lexers/monkey.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/pygments/lexers/monkey.py b/pygments/lexers/monkey.py
index 544686e8..b7e4192c 100644
--- a/pygments/lexers/monkey.py
+++ b/pygments/lexers/monkey.py
@@ -33,20 +33,23 @@ class MonkeyLexer(RegexLexer):
name_class = r'[A-Z][a-zA-Z0-9_]*'
name_module = r'[a-z0-9_]*'
- keyword_type = r'(Int|Float|String|Bool|Object|Array|Void)'
+ keyword_type = r'(?:Int|Float|String|Bool|Object|Array|Void)'
# ? == Bool // % == Int // # == Float // $ == String
keyword_type_special = r'[?%#$]'
+ flags = re.MULTILINE
+
tokens = {
'root': [
#Text
(r'\n', Text),
+ (r'\r', Text),
(r'\t+', Text),
(r'\s+', Text),
# Comments
- (r"'.*\n", Comment),
+ (r"'.*", Comment),
(r'(?i)^#rem\b', Comment.Multiline, 'comment'),
- (r'(?i)^(?:#If|#ElseIf|#Else|#End|#EndIf|#Print|#Error)\s?.*?$', Comment.Preproc),
+ (r'(?i)^(?:#If|#ElseIf|#Else|#End|#EndIf|#Print|#Error)\s?.*$', Comment.Preproc),
# String
('"', String.Double, 'string'),
# Numbers
@@ -72,14 +75,14 @@ class MonkeyLexer(RegexLexer):
(r'(?i)(Function|Method)(\s+)', bygroups(Keyword.Reserved, Text), 'funcname'),
(r'(?i)(?:End|Return|Public|Private|Extern|Property|Final|Abstract)\b', Keyword.Reserved),
# Flow Control stuff
- (r'(?i)If|Then|Else|ElseIf|EndIf|'
+ (r'(?i)(?:If|Then|Else|ElseIf|EndIf|'
r'Select|Case|Default|'
r'While|Wend|'
r'Repeat|Until|Forever|'
r'For|To|Until|Step|EachIn|Next|'
- r'Exit|Continue\s+', Keyword.Reserved),
+ r'Exit|Continue)\s+', Keyword.Reserved),
# not used yet
- (r'(?i)\b(Module|Inline)\b', Keyword.Reserved),
+ (r'(?i)\b(?:Module|Inline)\b', Keyword.Reserved),
# Other
(r'<=|>=|<>|[*]=|/=|[+]=|-=|&=|~=|[|]=|[-&*/^+=<>]', Operator),
(r'Not|Mod|Shl|Shr|And|Or', Operator.Word),
@@ -131,8 +134,10 @@ class MonkeyLexer(RegexLexer):
(r'[^"]+', String.Double)
],
'comment' : [
- (r'[^#].*\n', Comment.Multiline),
- (r'(?i)#End.*?\n', Comment.Multiline, "#pop"),
- (r'^#', Comment.Multiline, "#push"),
+ (r'\n', Comment.Multiline),
+ (r'^[^#].*', Comment.Multiline),
+ (r'(?i)^#End.*?', Comment.Multiline, "#pop"),
+ (r'^#\w+\b.*', Comment.Multiline, "#push"),
+ (r'.*', Comment.Multiline),
],
} \ No newline at end of file