From fbaf4c2b596239e2ba2b88e36ac671672d94b1f3 Mon Sep 17 00:00:00 2001 From: Andi Albrecht Date: Sun, 14 Nov 2010 22:03:13 +0100 Subject: Match single line comments at end of string. The bug was reported for CrunchyFrog: http://code.google.com/p/crunchyfrog/issues/detail?id=88 --- sqlparse/lexer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sqlparse') diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py index 305ac66..dc87f94 100644 --- a/sqlparse/lexer.py +++ b/sqlparse/lexer.py @@ -162,7 +162,10 @@ class Lexer: tokens = { 'root': [ - (r'--.*?(\r|\n|\r\n)', tokens.Comment.Single), + (r'--.*?(\r\n|\r|\n)', tokens.Comment.Single), + # $ matches *before* newline, therefore we have two patterns + # to match Comment.Single + (r'--.*?$', tokens.Comment.Single), (r'(\r|\n|\r\n)', tokens.Newline), (r'\s+', tokens.Whitespace), (r'/\*', tokens.Comment.Multiline, 'multiline-comments'), -- cgit v1.2.1