summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--pygments/lexers/_mapping.py1
-rw-r--r--pygments/lexers/textedit.py46
-rw-r--r--tests/examplefiles/sed/all_sorts_of_syntax.sed18
-rw-r--r--tests/examplefiles/sed/all_sorts_of_syntax.sed.output62
-rw-r--r--tests/examplefiles/sed/count_words.sed44
-rw-r--r--tests/examplefiles/sed/count_words.sed.output329
-rw-r--r--tests/examplefiles/sed/increment_number.sed26
-rw-r--r--tests/examplefiles/sed/increment_number.sed.output169
-rw-r--r--tests/examplefiles/sed/reverse.sed18
-rw-r--r--tests/examplefiles/sed/reverse.sed.output59
11 files changed, 767 insertions, 6 deletions
diff --git a/AUTHORS b/AUTHORS
index 9fc03933..d9eba8ad 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -246,5 +246,6 @@ Other contributors, listed alphabetically, are:
* Fabian Neumann -- CDDL lexer
* Thomas Duboucher -- CDDL lexer
* Philipp Imhof -- Pango Markup formatter
+* Thomas Voss -- Sed lexer
Many thanks for all contributions!
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index fee7ff29..d259ccf0 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -423,6 +423,7 @@ LEXERS = {
'SchemeLexer': ('pygments.lexers.lisp', 'Scheme', ('scheme', 'scm'), ('*.scm', '*.ss'), ('text/x-scheme', 'application/x-scheme')),
'ScilabLexer': ('pygments.lexers.matlab', 'Scilab', ('scilab',), ('*.sci', '*.sce', '*.tst'), ('text/scilab',)),
'ScssLexer': ('pygments.lexers.css', 'SCSS', ('scss',), ('*.scss',), ('text/x-scss',)),
+ 'SedLexer': ('pygments.lexers.textedit', 'Sed', ('sed', 'gsed', 'ssed'), ('*.sed', '*.[gs]sed'), ('text/x-sed',)),
'ShExCLexer': ('pygments.lexers.rdf', 'ShExC', ('shexc', 'shex'), ('*.shex',), ('text/shex',)),
'ShenLexer': ('pygments.lexers.lisp', 'Shen', ('shen',), ('*.shen',), ('text/x-shen', 'application/x-shen')),
'SieveLexer': ('pygments.lexers.sieve', 'Sieve', ('sieve',), ('*.siv', '*.sieve'), ()),
diff --git a/pygments/lexers/textedit.py b/pygments/lexers/textedit.py
index 24fbe2e4..d374114d 100644
--- a/pygments/lexers/textedit.py
+++ b/pygments/lexers/textedit.py
@@ -11,13 +11,12 @@
import re
from bisect import bisect
-from pygments.lexer import RegexLexer, include, default, bygroups, using, this
-from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
- Number, Punctuation
-
+from pygments.lexer import RegexLexer, bygroups, default, include, this, using
from pygments.lexers.python import PythonLexer
+from pygments.token import Comment, Error, Keyword, Name, Number, Operator, \
+ Punctuation, String, Text, Whitespace
-__all__ = ['AwkLexer', 'VimLexer']
+__all__ = ['AwkLexer', 'SedLexer', 'VimLexer']
class AwkLexer(RegexLexer):
@@ -74,6 +73,41 @@ class AwkLexer(RegexLexer):
}
+class SedLexer(RegexLexer):
+ """
+ Lexer for Sed script files.
+ """
+ name = 'Sed'
+ aliases = ['sed', 'gsed', 'ssed']
+ filenames = ['*.sed', '*.[gs]sed']
+ mimetypes = ['text/x-sed']
+ flags = re.MULTILINE
+
+ # Match the contents within delimeters such as /<contents>/
+ _inside_delims = r'((?:(?:\\[^\n]|[^\\])*?\\\n)*?(?:\\.|[^\\])*?)'
+
+ tokens = {
+ 'root': [
+ (r'\s+', Whitespace),
+ (r'#.*$', Comment.Single),
+ (r'[0-9]+', Number.Integer),
+ (r'\$', Operator),
+ (r'[{};,!]', Punctuation),
+ (r'[dDFgGhHlnNpPqQxz=]', Keyword),
+ (r'([berRtTvwW:])([^;\n]*)', bygroups(Keyword, String.Single)),
+ (r'([aci])((?:.*?\\\n)*(?:.*?[^\\]$))', bygroups(Keyword, String.Double)),
+ (r'([qQ])([0-9]*)', bygroups(Keyword, Number.Integer)),
+ (r'(/)' + _inside_delims + r'(/)', bygroups(Punctuation, String.Regex, Punctuation)),
+ (r'(\\(.))' + _inside_delims + r'(\2)',
+ bygroups(Punctuation, None, String.Regex, Punctuation)),
+ (r'(y)(.)' + _inside_delims + r'(\2)' + _inside_delims + r'(\2)',
+ bygroups(Keyword, Punctuation, String.Single, Punctuation, String.Single, Punctuation)),
+ (r'(s)(.)' + _inside_delims + r'(\2)' + _inside_delims + r'(\2)((?:[gpeIiMm]|[0-9])*)',
+ bygroups(Keyword, Punctuation, String.Regex, Punctuation, String.Single, Punctuation,
+ Keyword))
+ ]
+ }
+
class VimLexer(RegexLexer):
"""
Lexer for VimL script files.
@@ -120,7 +154,7 @@ class VimLexer(RegexLexer):
}
def __init__(self, **options):
- from pygments.lexers._vim_builtins import command, option, auto
+ from pygments.lexers._vim_builtins import auto, command, option
self._cmd = command
self._opt = option
self._aut = auto
diff --git a/tests/examplefiles/sed/all_sorts_of_syntax.sed b/tests/examplefiles/sed/all_sorts_of_syntax.sed
new file mode 100644
index 00000000..433923f8
--- /dev/null
+++ b/tests/examplefiles/sed/all_sorts_of_syntax.sed
@@ -0,0 +1,18 @@
+#!/usr/bin/sed -f
+
+819,$ {
+ p; x
+ z
+ a Hello World!
+ i \
+ Testy \
+ test
+}
+
+/START/,/END/ {
+ 10 y_123456789_abcdefghi_
+}
+
+\@[0-9]+@s/[aeiou]*/-\
+&\
+-/pegw output.txt
diff --git a/tests/examplefiles/sed/all_sorts_of_syntax.sed.output b/tests/examplefiles/sed/all_sorts_of_syntax.sed.output
new file mode 100644
index 00000000..df362530
--- /dev/null
+++ b/tests/examplefiles/sed/all_sorts_of_syntax.sed.output
@@ -0,0 +1,62 @@
+'#!/usr/bin/sed -f' Comment.Single
+'\n\n' Text.Whitespace
+
+'819' Literal.Number.Integer
+',' Punctuation
+'$' Operator
+' ' Text.Whitespace
+'{' Punctuation
+'\n\t' Text.Whitespace
+'p' Keyword
+';' Punctuation
+' ' Text.Whitespace
+'x' Keyword
+'\n\t' Text.Whitespace
+'z' Keyword
+'\n\t' Text.Whitespace
+'a' Keyword
+' Hello World!' Literal.String.Double
+'\n\t' Text.Whitespace
+'i' Keyword
+' \\\n\tTesty \\\n\ttest' Literal.String.Double
+'\n' Text.Whitespace
+
+'}' Punctuation
+'\n\n' Text.Whitespace
+
+'/' Punctuation
+'START' Literal.String.Regex
+'/' Punctuation
+',' Punctuation
+'/' Punctuation
+'END' Literal.String.Regex
+'/' Punctuation
+' ' Text.Whitespace
+'{' Punctuation
+'\n\t' Text.Whitespace
+'10' Literal.Number.Integer
+' ' Text.Whitespace
+'y' Keyword
+'_' Punctuation
+'123456789' Literal.String.Single
+'_' Punctuation
+'abcdefghi' Literal.String.Single
+'_' Punctuation
+'\n' Text.Whitespace
+
+'}' Punctuation
+'\n\n' Text.Whitespace
+
+'\\@' Punctuation
+'[0-9]+' Literal.String.Regex
+'@' Punctuation
+'s' Keyword
+'/' Punctuation
+'[aeiou]*' Literal.String.Regex
+'/' Punctuation
+'-\\\n&\\\n-' Literal.String.Single
+'/' Punctuation
+'peg' Keyword
+'w' Keyword
+' output.txt' Literal.String.Single
+'\n' Text.Whitespace
diff --git a/tests/examplefiles/sed/count_words.sed b/tests/examplefiles/sed/count_words.sed
new file mode 100644
index 00000000..b97c2cf4
--- /dev/null
+++ b/tests/examplefiles/sed/count_words.sed
@@ -0,0 +1,44 @@
+#!/usr/bin/sed -nf
+
+# Add n+1 a's to hold space (+1 is for the newline)
+s/./a/g
+H
+x
+s/\n/a/
+
+# Do the carry. The t's and b's are not necessary,
+# but they do speed up the thing
+t a
+: a; s/aaaaaaaaaa/b/g; t b; b done
+: b; s/bbbbbbbbbb/c/g; t c; b done
+: c; s/cccccccccc/d/g; t d; b done
+: d; s/dddddddddd/e/g; t e; b done
+: e; s/eeeeeeeeee/f/g; t f; b done
+: f; s/ffffffffff/g/g; t g; b done
+: g; s/gggggggggg/h/g; t h; b done
+: h; s/hhhhhhhhhh//g
+
+: done
+$! {
+ h
+ b
+}
+
+# On the last line, convert back to decimal
+
+: loop
+/a/! s/[b-h]*/&0/
+s/aaaaaaaaa/9/
+s/aaaaaaaa/8/
+s/aaaaaaa/7/
+s/aaaaaa/6/
+s/aaaaa/5/
+s/aaaa/4/
+s/aaa/3/
+s/aa/2/
+s/a/1/
+
+: next
+y/bcdefgh/abcdefg/
+/[a-h]/ b loop
+p
diff --git a/tests/examplefiles/sed/count_words.sed.output b/tests/examplefiles/sed/count_words.sed.output
new file mode 100644
index 00000000..e61e29b0
--- /dev/null
+++ b/tests/examplefiles/sed/count_words.sed.output
@@ -0,0 +1,329 @@
+'#!/usr/bin/sed -nf' Comment.Single
+'\n\n' Text.Whitespace
+
+"# Add n+1 a's to hold space (+1 is for the newline)" Comment.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'.' Literal.String.Regex
+'/' Punctuation
+'a' Literal.String.Single
+'/' Punctuation
+'g' Keyword
+'\n' Text.Whitespace
+
+'H' Keyword
+'\n' Text.Whitespace
+
+'x' Keyword
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'\\n' Literal.String.Regex
+'/' Punctuation
+'a' Literal.String.Single
+'/' Punctuation
+'\n\n' Text.Whitespace
+
+"# Do the carry. The t's and b's are not necessary," Comment.Single
+'\n' Text.Whitespace
+
+'# but they do speed up the thing' Comment.Single
+'\n' Text.Whitespace
+
+'t' Keyword
+' a' Literal.String.Single
+'\n' Text.Whitespace
+
+':' Keyword
+' a' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'s' Keyword
+'/' Punctuation
+'aaaaaaaaaa' Literal.String.Regex
+'/' Punctuation
+'b' Literal.String.Single
+'/' Punctuation
+'g' Keyword
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+' b' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'b' Keyword
+' done' Literal.String.Single
+'\n' Text.Whitespace
+
+':' Keyword
+' b' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'s' Keyword
+'/' Punctuation
+'bbbbbbbbbb' Literal.String.Regex
+'/' Punctuation
+'c' Literal.String.Single
+'/' Punctuation
+'g' Keyword
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+' c' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'b' Keyword
+' done' Literal.String.Single
+'\n' Text.Whitespace
+
+':' Keyword
+' c' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'s' Keyword
+'/' Punctuation
+'cccccccccc' Literal.String.Regex
+'/' Punctuation
+'d' Literal.String.Single
+'/' Punctuation
+'g' Keyword
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+' d' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'b' Keyword
+' done' Literal.String.Single
+'\n' Text.Whitespace
+
+':' Keyword
+' d' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'s' Keyword
+'/' Punctuation
+'dddddddddd' Literal.String.Regex
+'/' Punctuation
+'e' Literal.String.Single
+'/' Punctuation
+'g' Keyword
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+' e' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'b' Keyword
+' done' Literal.String.Single
+'\n' Text.Whitespace
+
+':' Keyword
+' e' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'s' Keyword
+'/' Punctuation
+'eeeeeeeeee' Literal.String.Regex
+'/' Punctuation
+'f' Literal.String.Single
+'/' Punctuation
+'g' Keyword
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+' f' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'b' Keyword
+' done' Literal.String.Single
+'\n' Text.Whitespace
+
+':' Keyword
+' f' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'s' Keyword
+'/' Punctuation
+'ffffffffff' Literal.String.Regex
+'/' Punctuation
+'g' Literal.String.Single
+'/' Punctuation
+'g' Keyword
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+' g' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'b' Keyword
+' done' Literal.String.Single
+'\n' Text.Whitespace
+
+':' Keyword
+' g' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'s' Keyword
+'/' Punctuation
+'gggggggggg' Literal.String.Regex
+'/' Punctuation
+'h' Literal.String.Single
+'/' Punctuation
+'g' Keyword
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+' h' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'b' Keyword
+' done' Literal.String.Single
+'\n' Text.Whitespace
+
+':' Keyword
+' h' Literal.String.Single
+';' Punctuation
+' ' Text.Whitespace
+'s' Keyword
+'/' Punctuation
+'hhhhhhhhhh' Literal.String.Regex
+'/' Punctuation
+'/' Punctuation
+'g' Keyword
+'\n\n' Text.Whitespace
+
+':' Keyword
+' done' Literal.String.Single
+'\n' Text.Whitespace
+
+'$' Operator
+'!' Punctuation
+' ' Text.Whitespace
+'{' Punctuation
+'\n ' Text.Whitespace
+'h' Keyword
+'\n ' Text.Whitespace
+'b' Keyword
+'\n' Text.Whitespace
+
+'}' Punctuation
+'\n\n' Text.Whitespace
+
+'# On the last line, convert back to decimal' Comment.Single
+'\n\n' Text.Whitespace
+
+':' Keyword
+' loop' Literal.String.Single
+'\n' Text.Whitespace
+
+'/' Punctuation
+'a' Literal.String.Regex
+'/' Punctuation
+'!' Punctuation
+' ' Text.Whitespace
+'s' Keyword
+'/' Punctuation
+'[b-h]*' Literal.String.Regex
+'/' Punctuation
+'&0' Literal.String.Single
+'/' Punctuation
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'aaaaaaaaa' Literal.String.Regex
+'/' Punctuation
+'9' Literal.String.Single
+'/' Punctuation
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'aaaaaaaa' Literal.String.Regex
+'/' Punctuation
+'8' Literal.String.Single
+'/' Punctuation
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'aaaaaaa' Literal.String.Regex
+'/' Punctuation
+'7' Literal.String.Single
+'/' Punctuation
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'aaaaaa' Literal.String.Regex
+'/' Punctuation
+'6' Literal.String.Single
+'/' Punctuation
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'aaaaa' Literal.String.Regex
+'/' Punctuation
+'5' Literal.String.Single
+'/' Punctuation
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'aaaa' Literal.String.Regex
+'/' Punctuation
+'4' Literal.String.Single
+'/' Punctuation
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'aaa' Literal.String.Regex
+'/' Punctuation
+'3' Literal.String.Single
+'/' Punctuation
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'aa' Literal.String.Regex
+'/' Punctuation
+'2' Literal.String.Single
+'/' Punctuation
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'a' Literal.String.Regex
+'/' Punctuation
+'1' Literal.String.Single
+'/' Punctuation
+'\n\n' Text.Whitespace
+
+':' Keyword
+' next' Literal.String.Single
+'\n' Text.Whitespace
+
+'y' Keyword
+'/' Punctuation
+'bcdefgh' Literal.String.Single
+'/' Punctuation
+'abcdefg' Literal.String.Single
+'/' Punctuation
+'\n' Text.Whitespace
+
+'/' Punctuation
+'[a-h]' Literal.String.Regex
+'/' Punctuation
+' ' Text.Whitespace
+'b' Keyword
+' loop' Literal.String.Single
+'\n' Text.Whitespace
+
+'p' Keyword
+'\n' Text.Whitespace
diff --git a/tests/examplefiles/sed/increment_number.sed b/tests/examplefiles/sed/increment_number.sed
new file mode 100644
index 00000000..d2fb2310
--- /dev/null
+++ b/tests/examplefiles/sed/increment_number.sed
@@ -0,0 +1,26 @@
+#!/usr/bin/sed -f
+
+/[^0-9]/ d
+
+# replace all trailing 9s by _ (any other character except digits, could
+# be used)
+:d
+s/9\(_*\)$/_\1/
+td
+
+# incr last digit only. The first line adds a most-significant
+# digit of 1 if we have to add a digit.
+
+s/^\(_*\)$/1\1/; tn
+s/8\(_*\)$/9\1/; tn
+s/7\(_*\)$/8\1/; tn
+s/6\(_*\)$/7\1/; tn
+s/5\(_*\)$/6\1/; tn
+s/4\(_*\)$/5\1/; tn
+s/3\(_*\)$/4\1/; tn
+s/2\(_*\)$/3\1/; tn
+s/1\(_*\)$/2\1/; tn
+s/0\(_*\)$/1\1/; tn
+
+:n
+y/_/0/
diff --git a/tests/examplefiles/sed/increment_number.sed.output b/tests/examplefiles/sed/increment_number.sed.output
new file mode 100644
index 00000000..d093086e
--- /dev/null
+++ b/tests/examplefiles/sed/increment_number.sed.output
@@ -0,0 +1,169 @@
+'#!/usr/bin/sed -f' Comment.Single
+'\n\n' Text.Whitespace
+
+'/' Punctuation
+'[^0-9]' Literal.String.Regex
+'/' Punctuation
+' ' Text.Whitespace
+'d' Keyword
+'\n\n' Text.Whitespace
+
+'# replace all trailing 9s by _ (any other character except digits, could' Comment.Single
+'\n' Text.Whitespace
+
+'# be used)' Comment.Single
+'\n' Text.Whitespace
+
+':' Keyword
+'d' Literal.String.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'9\\(_*\\)$' Literal.String.Regex
+'/' Punctuation
+'_\\1' Literal.String.Single
+'/' Punctuation
+'\n' Text.Whitespace
+
+'t' Keyword
+'d' Literal.String.Single
+'\n\n' Text.Whitespace
+
+'# incr last digit only. The first line adds a most-significant' Comment.Single
+'\n' Text.Whitespace
+
+'# digit of 1 if we have to add a digit.' Comment.Single
+'\n\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'^\\(_*\\)$' Literal.String.Regex
+'/' Punctuation
+'1\\1' Literal.String.Single
+'/' Punctuation
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+'n' Literal.String.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'8\\(_*\\)$' Literal.String.Regex
+'/' Punctuation
+'9\\1' Literal.String.Single
+'/' Punctuation
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+'n' Literal.String.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'7\\(_*\\)$' Literal.String.Regex
+'/' Punctuation
+'8\\1' Literal.String.Single
+'/' Punctuation
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+'n' Literal.String.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'6\\(_*\\)$' Literal.String.Regex
+'/' Punctuation
+'7\\1' Literal.String.Single
+'/' Punctuation
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+'n' Literal.String.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'5\\(_*\\)$' Literal.String.Regex
+'/' Punctuation
+'6\\1' Literal.String.Single
+'/' Punctuation
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+'n' Literal.String.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'4\\(_*\\)$' Literal.String.Regex
+'/' Punctuation
+'5\\1' Literal.String.Single
+'/' Punctuation
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+'n' Literal.String.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'3\\(_*\\)$' Literal.String.Regex
+'/' Punctuation
+'4\\1' Literal.String.Single
+'/' Punctuation
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+'n' Literal.String.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'2\\(_*\\)$' Literal.String.Regex
+'/' Punctuation
+'3\\1' Literal.String.Single
+'/' Punctuation
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+'n' Literal.String.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'1\\(_*\\)$' Literal.String.Regex
+'/' Punctuation
+'2\\1' Literal.String.Single
+'/' Punctuation
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+'n' Literal.String.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'0\\(_*\\)$' Literal.String.Regex
+'/' Punctuation
+'1\\1' Literal.String.Single
+'/' Punctuation
+';' Punctuation
+' ' Text.Whitespace
+'t' Keyword
+'n' Literal.String.Single
+'\n\n' Text.Whitespace
+
+':' Keyword
+'n' Literal.String.Single
+'\n' Text.Whitespace
+
+'y' Keyword
+'/' Punctuation
+'_' Literal.String.Single
+'/' Punctuation
+'0' Literal.String.Single
+'/' Punctuation
+'\n' Text.Whitespace
diff --git a/tests/examplefiles/sed/reverse.sed b/tests/examplefiles/sed/reverse.sed
new file mode 100644
index 00000000..718bb47e
--- /dev/null
+++ b/tests/examplefiles/sed/reverse.sed
@@ -0,0 +1,18 @@
+#!/usr/bin/sed -f
+
+/../! b
+
+# Reverse a line. Begin embedding the line between two newlines
+s/^.*$/\
+&\
+/
+
+# Move first character at the end. The regexp matches until
+# there are zero or one characters between the markers
+tx
+:x
+s/\(\n.\)\(.*\)\(.\n\)/\3\2\1/
+tx
+
+# Remove the newline markers
+s/\n//g
diff --git a/tests/examplefiles/sed/reverse.sed.output b/tests/examplefiles/sed/reverse.sed.output
new file mode 100644
index 00000000..29ee5da2
--- /dev/null
+++ b/tests/examplefiles/sed/reverse.sed.output
@@ -0,0 +1,59 @@
+'#!/usr/bin/sed -f' Comment.Single
+'\n\n' Text.Whitespace
+
+'/' Punctuation
+'..' Literal.String.Regex
+'/' Punctuation
+'!' Punctuation
+' ' Text.Whitespace
+'b' Keyword
+'\n\n' Text.Whitespace
+
+'# Reverse a line. Begin embedding the line between two newlines' Comment.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'^.*$' Literal.String.Regex
+'/' Punctuation
+'\\\n&\\\n' Literal.String.Single
+
+'/' Punctuation
+'\n\n' Text.Whitespace
+
+'# Move first character at the end. The regexp matches until' Comment.Single
+'\n' Text.Whitespace
+
+'# there are zero or one characters between the markers' Comment.Single
+'\n' Text.Whitespace
+
+'t' Keyword
+'x' Literal.String.Single
+'\n' Text.Whitespace
+
+':' Keyword
+'x' Literal.String.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'\\(\\n.\\)\\(.*\\)\\(.\\n\\)' Literal.String.Regex
+'/' Punctuation
+'\\3\\2\\1' Literal.String.Single
+'/' Punctuation
+'\n' Text.Whitespace
+
+'t' Keyword
+'x' Literal.String.Single
+'\n\n' Text.Whitespace
+
+'# Remove the newline markers' Comment.Single
+'\n' Text.Whitespace
+
+'s' Keyword
+'/' Punctuation
+'\\n' Literal.String.Regex
+'/' Punctuation
+'/' Punctuation
+'g' Keyword
+'\n' Text.Whitespace