summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2014-05-05 10:36:34 -0700
committerTim Hatch <tim@timhatch.com>2014-05-05 10:36:34 -0700
commitf81d591b4d2deb5edc4b3090a2f72ea62d3a58c6 (patch)
treecfc796f0e72ab9ba73c482e6e7aa7c64fefe033d
parentf16d0dbfaececc1b868c11355f4bca13e06dca53 (diff)
parent9b3c28af7c23dc90e648f439397529b82624d120 (diff)
downloadpygments-f81d591b4d2deb5edc4b3090a2f72ea62d3a58c6.tar.gz
Merged in Oldes/pygments-main/issue-985 (pull request #345)
REBOL comments handling fixed
-rw-r--r--doc/languages.rst3
-rw-r--r--pygments/lexers/other.py32
-rw-r--r--tests/examplefiles/example.reds26
-rw-r--r--tests/examplefiles/test.r334
4 files changed, 70 insertions, 25 deletions
diff --git a/doc/languages.rst b/doc/languages.rst
index 426a576b..3b0db5eb 100644
--- a/doc/languages.rst
+++ b/doc/languages.rst
@@ -65,7 +65,8 @@ Programming languages
* PowerShell
* Prolog
* `Python <http://www.python.org>`_ 2.x and 3.x (incl. console sessions and tracebacks)
-* Rebol
+* `REBOL <http://www.rebol.com>`_
+* `Red <http://www.red-lang.org>`_
* Redcode
* `Ruby <http://www.ruby-lang.org>`_ (incl. irb sessions)
* Rust
diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py
index 454f0e42..01c61513 100644
--- a/pygments/lexers/other.py
+++ b/pygments/lexers/other.py
@@ -1380,7 +1380,7 @@ class RebolLexer(RegexLexer):
"""
name = 'REBOL'
aliases = ['rebol']
- filenames = ['*.r', '*.r3']
+ filenames = ['*.r', '*.r3', '*.reb']
mimetypes = ['text/x-rebol']
flags = re.IGNORECASE | re.MULTILINE
@@ -1506,7 +1506,10 @@ class RebolLexer(RegexLexer):
(r'[a-zA-Z]+[^(\^{"\s:)]*://[^(\^{"\s)]*', Name.Decorator), # url
(r'mailto:[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # url
(r'[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # email
- (r'comment\s', Comment, 'comment'),
+ (r'comment\s"', Comment, 'commentString1'),
+ (r'comment\s{', Comment, 'commentString2'),
+ (r'comment\s\[', Comment, 'commentBlock'),
+ (r'comment\s[^(\s{\"\[]+', Comment),
(r'/[^(\^{^")\s/[\]]*', Name.Attribute),
(r'([^(\^{^")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback),
(r'<[a-zA-Z0-9:._-]*>', Name.Tag),
@@ -1561,12 +1564,6 @@ class RebolLexer(RegexLexer):
(r'([0-1]\s*){8}', Number.Hex),
(r'}', Number.Hex, '#pop'),
],
- 'comment': [
- (r'"', Comment, 'commentString1'),
- (r'{', Comment, 'commentString2'),
- (r'\[', Comment, 'commentBlock'),
- (r'[^(\s{\"\[]+', Comment, '#pop'),
- ],
'commentString1': [
(r'[^(\^")]+', Comment),
(escape_re, Comment),
@@ -1585,7 +1582,9 @@ class RebolLexer(RegexLexer):
'commentBlock': [
(r'\[', Comment, '#push'),
(r'\]', Comment, '#pop'),
- (r'[^(\[\])]+', Comment),
+ (r'"', Comment, "commentString1"),
+ (r'{', Comment, "commentString2"),
+ (r'[^(\[\]\"{)]+', Comment),
],
}
def analyse_text(text):
@@ -4344,7 +4343,10 @@ class RedLexer(RegexLexer):
(r'[a-zA-Z]+[^(\^{"\s:)]*://[^(\^{"\s)]*', Name.Decorator), # url
(r'mailto:[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # url
(r'[^(\^{"@\s)]+@[^(\^{"@\s)]+', Name.Decorator), # email
- (r'comment\s', Comment, 'comment'),
+ (r'comment\s"', Comment, 'commentString1'),
+ (r'comment\s{', Comment, 'commentString2'),
+ (r'comment\s\[', Comment, 'commentBlock'),
+ (r'comment\s[^(\s{\"\[]+', Comment),
(r'/[^(\^{^")\s/[\]]*', Name.Attribute),
(r'([^(\^{^")\s/[\]]+)(?=[:({"\s/\[\]])', word_callback),
(r'<[a-zA-Z0-9:._-]*>', Name.Tag),
@@ -4399,12 +4401,6 @@ class RedLexer(RegexLexer):
(r'([0-1]\s*){8}', Number.Hex),
(r'}', Number.Hex, '#pop'),
],
- 'comment': [
- (r'"', Comment, 'commentString1'),
- (r'{', Comment, 'commentString2'),
- (r'\[', Comment, 'commentBlock'),
- (r'[^(\s{\"\[]+', Comment, '#pop'),
- ],
'commentString1': [
(r'[^(\^")]+', Comment),
(escape_re, Comment),
@@ -4423,6 +4419,8 @@ class RedLexer(RegexLexer):
'commentBlock': [
(r'\[', Comment, '#push'),
(r'\]', Comment, '#pop'),
- (r'[^(\[\])]+', Comment),
+ (r'"', Comment, "commentString1"),
+ (r'{', Comment, "commentString2"),
+ (r'[^(\[\]\"{)]+', Comment),
],
}
diff --git a/tests/examplefiles/example.reds b/tests/examplefiles/example.reds
index dd4ad0f9..eb92310d 100644
--- a/tests/examplefiles/example.reds
+++ b/tests/examplefiles/example.reds
@@ -109,6 +109,32 @@ foo char
;lit-word:
'foo 'foo
+;multiple comment tests...
+1 + 1
+comment "aa"
+2 + 2
+comment {aa}
+3 + 3
+comment {a^{}
+4 + 4
+comment {{}}
+5 + 5
+comment {
+ foo: 6
+}
+6 + 6
+comment [foo: 6]
+7 + 7
+comment [foo: "[" ]
+8 + 8
+comment [foo: {^{} ]
+9 + 9
+comment [foo: {boo} ]
+10 + 10
+comment 5-May-2014/11:17:34+2:00
+11 + 11
+
+
to-integer foo
foo/(a + 1)/b
diff --git a/tests/examplefiles/test.r3 b/tests/examplefiles/test.r3
index cad12a8d..707102db 100644
--- a/tests/examplefiles/test.r3
+++ b/tests/examplefiles/test.r3
@@ -1,3 +1,9 @@
+preface.... everything what is before header is not evaluated
+so this should not be colorized:
+1 + 2
+
+REBOL [] ;<- this is minimal header, everything behind it must be colorized
+
;## String tests ##
print "Hello ^"World" ;<- with escaped char
multiline-string: {
@@ -52,15 +58,29 @@ type? #ff0000 ;== issue!
to integer! (1 + (x / 4.5) * 1E-4)
;## some spec comments
-comment now
-comment 10
+1 + 1
+comment "aa"
+2 + 2
+comment {aa}
+3 + 3
+comment {a^{}
+4 + 4
+comment {{}}
+5 + 5
comment {
- bla
- bla
+ foo: 6
}
-comment [
- quit
-]
+6 + 6
+comment [foo: 6]
+7 + 7
+comment [foo: "[" ]
+8 + 8
+comment [foo: {^{} ]
+9 + 9
+comment [foo: {boo} ]
+10 + 10
+comment 5-May-2014/11:17:34+2:00
+5-May-2014/11:17:34+2:00 11 + 11
;## other tests ##
---: 1