ThirdParty/Pygments/pygments/lexers/sql.py

changeset 6651
e8f3b5568b21
parent 5713
6762afd9f963
--- a/ThirdParty/Pygments/pygments/lexers/sql.py	Sat Jan 12 12:11:42 2019 +0100
+++ b/ThirdParty/Pygments/pygments/lexers/sql.py	Sat Jan 12 12:40:14 2019 +0100
@@ -155,7 +155,7 @@
             (r'\s+', Text),
             (r'--.*\n?', Comment.Single),
             (r'/\*', Comment.Multiline, 'multiline-comments'),
-            (r'(' + '|'.join(s.replace(" ", "\s+")
+            (r'(' + '|'.join(s.replace(" ", r"\s+")
                              for s in DATATYPES + PSEUDO_TYPES)
              + r')\b', Name.Builtin),
             (words(KEYWORDS, suffix=r'\b'), Keyword),
@@ -308,14 +308,7 @@
             # and continue until the end of command is detected
             curcode = ''
             insertions = []
-            while 1:
-                try:
-                    line = next(lines)
-                except StopIteration:
-                    # allow the emission of partially collected items
-                    # the repl loop will be broken below
-                    break
-
+            for line in lines:
                 # Identify a shell prompt in case of psql commandline example
                 if line.startswith('$') and not curcode:
                     lexer = get_lexer_by_name('console', **self.options)
@@ -346,8 +339,7 @@
 
             # Emit the output lines
             out_token = Generic.Output
-            while 1:
-                line = next(lines)
+            for line in lines:
                 mprompt = re_prompt.match(line)
                 if mprompt is not None:
                     # push the line back to have it processed by the prompt
@@ -363,6 +355,8 @@
                     yield (mmsg.start(2), out_token, mmsg.group(2))
                 else:
                     yield (0, out_token, line)
+            else:
+                return
 
 
 class SqlLexer(RegexLexer):
@@ -499,7 +493,7 @@
     tokens = {
         'root': [
             (r'\s+', Whitespace),
-            (r'--(?m).*?$\n?', Comment.Single),
+            (r'(?m)--.*?$\n?', Comment.Single),
             (r'/\*', Comment.Multiline, 'multiline-comments'),
             (words(_tsql_builtins.OPERATORS), Operator),
             (words(_tsql_builtins.OPERATOR_WORDS, suffix=r'\b'), Operator.Word),

eric ide

mercurial