From 9b46a17fa2e45aee9b1e3c19444415f7e237c686 Mon Sep 17 00:00:00 2001 From: Maxime Kjaer Date: Sat, 7 Dec 2019 22:33:55 +0100 Subject: [PATCH 01/12] Fix lexing of Scala comments at EOF --- lib/rouge/lexers/scala.rb | 6 +++--- spec/lexers/scala_spec.rb | 8 ++++++++ spec/visual/samples/scala | 10 ++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/rouge/lexers/scala.rb b/lib/rouge/lexers/scala.rb index ceb70f4ce5..99cb74c43f 100644 --- a/lib/rouge/lexers/scala.rb +++ b/lib/rouge/lexers/scala.rb @@ -43,7 +43,7 @@ class Scala < RegexLexer rule %r/'#{idrest}[^']/, Str::Symbol rule %r/[^\S\n]+/, Text - rule %r(//.*?\n), Comment::Single + rule %r(//.*?$), Comment::Single rule %r(/\*), Comment::Multiline, :comment rule %r/@#{idrest}/, Name::Decorator @@ -117,7 +117,7 @@ class Scala < RegexLexer rule %r/\s+/, Text rule %r/{/, Operator, :pop! rule %r/\(/, Operator, :pop! - rule %r(//.*?\n), Comment::Single, :pop! + rule %r(//.*?$), Comment::Single, :pop! rule %r(#{idrest}|#{op}+|`[^`]+`), Name::Class, :pop! end @@ -142,7 +142,7 @@ class Scala < RegexLexer pop! end - rule %r(//.*?\n), Comment::Single, :pop! + rule %r(//.*?$), Comment::Single, :pop! rule %r/\.|#{idrest}|#{op}+|`[^`]+`/, Keyword::Type end diff --git a/spec/lexers/scala_spec.rb b/spec/lexers/scala_spec.rb index 112d0912e6..3c1dd1e949 100644 --- a/spec/lexers/scala_spec.rb +++ b/spec/lexers/scala_spec.rb @@ -17,4 +17,12 @@ assert_guess :mimetype => 'application/x-scala' end end + + describe 'lexing' do + include Support::Lexing + + it 'recognizes one-line comments not followed by a newline' do + assert_tokens_equal '// comment', ['Comment.Single', '// comment'] + end + end end diff --git a/spec/visual/samples/scala b/spec/visual/samples/scala index c27c8d9af3..c72980b851 100644 --- a/spec/visual/samples/scala +++ b/spec/visual/samples/scala @@ -5,6 +5,8 @@ import foo.bar.{Foo, Bar => Baz} /* This file /* which is totally legal scala */ should be highlighted correcty by rouge */ +// Single-line comments too + object ⌘ { val `interface` = """ A @@ -46,6 +48,12 @@ abstract case class Foo[+A, B <: List[A]](a: A) { def apply[C >: A](c: Foo[C]): Foo[C] } +class // comment 1 + Test(a: // comment 2 + Int) { + +} + class why_would_you_name_a_class_this_way_oh_well_we_need_to_highlight_it(a: Int) extends Foo(a) { def this(b: Float) = this(b.toInt) @@ -55,3 +63,5 @@ class why_would_you_name_a_class_this_way_oh_well_we_need_to_highlight_it(a: Int def longs = 4L def hex = 0x123 } + +// Comment at EOF \ No newline at end of file From f6b53b4b15bd3f056055817398e924eb30853703 Mon Sep 17 00:00:00 2001 From: Maxime Kjaer Date: Sat, 7 Dec 2019 22:50:59 +0100 Subject: [PATCH 02/12] Fix lexing of Verilog comments at EOF --- lib/rouge/lexers/verilog.rb | 2 +- spec/lexers/verilog_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/rouge/lexers/verilog.rb b/lib/rouge/lexers/verilog.rb index ed7a8b97db..820c4350f1 100644 --- a/lib/rouge/lexers/verilog.rb +++ b/lib/rouge/lexers/verilog.rb @@ -100,7 +100,7 @@ def self.keywords_system_task state :whitespace do rule %r/\n+/m, Text, :bol - rule %r(//(\\.|.)*?\n), Comment::Single, :bol + rule %r(//(\\.|.)*?$), Comment::Single, :bol mixin :inline_whitespace end diff --git a/spec/lexers/verilog_spec.rb b/spec/lexers/verilog_spec.rb index 81dfc27de7..da0a8c46f4 100644 --- a/spec/lexers/verilog_spec.rb +++ b/spec/lexers/verilog_spec.rb @@ -18,4 +18,12 @@ assert_guess :mimetype => 'text/x-systemverilog' end end + + describe 'lexing' do + include Support::Lexing + + it 'recognizes one-line comments not followed by a newline' do + assert_tokens_equal '// comment', ['Comment.Single', '// comment'] + end + end end From 67bba236e40332638d7cf12787d8b8c330b7511f Mon Sep 17 00:00:00 2001 From: Maxime Kjaer Date: Sat, 7 Dec 2019 22:54:03 +0100 Subject: [PATCH 03/12] Fix lexing of SQF comments at EOF --- lib/rouge/lexers/sqf.rb | 2 +- spec/lexers/sqf_spec.rb | 8 ++++++++ spec/visual/samples/sqf | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/rouge/lexers/sqf.rb b/lib/rouge/lexers/sqf.rb index 22386a4502..b61dc60c52 100644 --- a/lib/rouge/lexers/sqf.rb +++ b/lib/rouge/lexers/sqf.rb @@ -65,7 +65,7 @@ def self.commands # Preprocessor instructions rule %r"/\*.*?\*/"m, Comment::Multiline - rule %r"//.*\n", Comment::Single + rule %r"//.*$", Comment::Single rule %r"#(define|undef|if(n)?def|else|endif|include)", Comment::Preproc rule %r"\\\r?\n", Comment::Preproc rule %r"__(EVAL|EXEC|LINE__|FILE__)", Name::Builtin diff --git a/spec/lexers/sqf_spec.rb b/spec/lexers/sqf_spec.rb index 15c72724f9..d05dd9d357 100644 --- a/spec/lexers/sqf_spec.rb +++ b/spec/lexers/sqf_spec.rb @@ -11,4 +11,12 @@ assert_guess :filename => 'foo.sqf' end end + + describe 'lexing' do + include Support::Lexing + + it 'recognizes one-line comments not followed by a newline' do + assert_tokens_equal '// comment', ['Comment.Single', '// comment'] + end + end end diff --git a/spec/visual/samples/sqf b/spec/visual/samples/sqf index 06241e1632..ccbb6c3549 100644 --- a/spec/visual/samples/sqf +++ b/spec/visual/samples/sqf @@ -48,3 +48,5 @@ if (_target find "var:" == 0) then { _commandList = _commandList joinString _delimiter; copyToClipboard _commandList; }; + +// comment at eof \ No newline at end of file From 090215db4a6263cad14c8e01b529e9bc5028d279 Mon Sep 17 00:00:00 2001 From: Maxime Kjaer Date: Sat, 7 Dec 2019 22:56:44 +0100 Subject: [PATCH 04/12] Fix lexing of Sieve comments at EOF --- lib/rouge/lexers/sieve.rb | 2 +- spec/lexers/sieve_spec.rb | 8 ++++++++ spec/visual/samples/sieve | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/rouge/lexers/sieve.rb b/lib/rouge/lexers/sieve.rb index db520ede5e..59894f6386 100644 --- a/lib/rouge/lexers/sieve.rb +++ b/lib/rouge/lexers/sieve.rb @@ -58,7 +58,7 @@ def self.tests state :comments_and_whitespace do rule %r/\s+/, Text - rule %r(#.*?\n), Comment::Single + rule %r(#.*?$), Comment::Single rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline end diff --git a/spec/lexers/sieve_spec.rb b/spec/lexers/sieve_spec.rb index d9be367ceb..b996c9d3b4 100644 --- a/spec/lexers/sieve_spec.rb +++ b/spec/lexers/sieve_spec.rb @@ -11,4 +11,12 @@ assert_guess :filename => 'foo.sieve' end end + + describe 'lexing' do + include Support::Lexing + + it 'recognizes one-line comments not followed by a newline' do + assert_tokens_equal '# comment', ['Comment.Single', '# comment'] + end + end end diff --git a/spec/visual/samples/sieve b/spec/visual/samples/sieve index 0d9510d8b0..e2ce433147 100644 --- a/spec/visual/samples/sieve +++ b/spec/visual/samples/sieve @@ -38,3 +38,5 @@ header :matches "Subject" ["*money*","*Viagra*"]) { else { keep; } + +# Comment at EOL \ No newline at end of file From b5733a2565b26270d6f785854f501eafa6c794b7 Mon Sep 17 00:00:00 2001 From: Maxime Kjaer Date: Sat, 7 Dec 2019 23:03:32 +0100 Subject: [PATCH 05/12] Fix lexing of Protobuf comments at EOF --- lib/rouge/lexers/protobuf.rb | 2 +- spec/lexers/protobuf_spec.rb | 8 ++++++++ spec/visual/samples/protobuf | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/rouge/lexers/protobuf.rb b/lib/rouge/lexers/protobuf.rb index 5f5190c938..9ac6c97722 100644 --- a/lib/rouge/lexers/protobuf.rb +++ b/lib/rouge/lexers/protobuf.rb @@ -17,7 +17,7 @@ class Protobuf < RegexLexer state :root do rule %r/[\s]+/, Text rule %r/[,;{}\[\]()]/, Punctuation - rule %r/\/(\\\n)?\/(\n|(.|\n)*?[^\\]\n)/, Comment::Single + rule %r/\/(\\\n)?\/($|(.|\n)*?[^\\]$)/, Comment::Single rule %r/\/(\\\n)?\*(.|\n)*?\*(\\\n)?\//, Comment::Multiline rule kw, Keyword rule datatype, Keyword::Type diff --git a/spec/lexers/protobuf_spec.rb b/spec/lexers/protobuf_spec.rb index 0a0722ef09..44691ce2cd 100644 --- a/spec/lexers/protobuf_spec.rb +++ b/spec/lexers/protobuf_spec.rb @@ -15,4 +15,12 @@ assert_guess :mimetype => 'text/x-proto' end end + + describe 'lexing' do + include Support::Lexing + + it 'recognizes one-line comments not followed by a newline' do + assert_tokens_equal '// comment', ['Comment.Single', '// comment'] + end + end end diff --git a/spec/visual/samples/protobuf b/spec/visual/samples/protobuf index b14829e9c3..72f67e84a4 100644 --- a/spec/visual/samples/protobuf +++ b/spec/visual/samples/protobuf @@ -28,3 +28,5 @@ message Person { message AddressBook { repeated Person person = 1; } + +// \ No newline at end of file From 0648ee07b3be7977b5b586fa8de83563026cbae4 Mon Sep 17 00:00:00 2001 From: Maxime Kjaer Date: Sat, 7 Dec 2019 23:06:52 +0100 Subject: [PATCH 06/12] Fix lexing of Pony comments at EOF --- lib/rouge/lexers/pony.rb | 2 +- spec/lexers/pony_spec.rb | 8 ++++++++ spec/visual/samples/pony | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/rouge/lexers/pony.rb b/lib/rouge/lexers/pony.rb index f97a0eeea6..a411be46ab 100644 --- a/lib/rouge/lexers/pony.rb +++ b/lib/rouge/lexers/pony.rb @@ -46,7 +46,7 @@ class compiler_intrinsic consume continue state :root do mixin :whitespace rule %r/"""/, Str::Doc, :docstring - rule %r{//(.*?)\n}, Comment::Single + rule %r{//(.*?)$}, Comment::Single rule %r{/(\\\n)?[*](.|\n)*?[*](\\\n)?/}, Comment::Multiline rule %r/"/, Str, :string rule %r([~!%^&*+=\|?:<>/-]), Operator diff --git a/spec/lexers/pony_spec.rb b/spec/lexers/pony_spec.rb index a736f1c482..a2541b2daa 100644 --- a/spec/lexers/pony_spec.rb +++ b/spec/lexers/pony_spec.rb @@ -11,4 +11,12 @@ assert_guess :filename => 'foo.pony' end end + + describe 'lexing' do + include Support::Lexing + + it 'recognizes one-line comments not followed by a newline' do + assert_tokens_equal '// comment', ['Comment.Single', '// comment'] + end + end end diff --git a/spec/visual/samples/pony b/spec/visual/samples/pony index a34f2f0071..a26d45d2dc 100644 --- a/spec/visual/samples/pony +++ b/spec/visual/samples/pony @@ -183,3 +183,5 @@ actor Main --output, -o File to write the output to. """ ) + +// Comment at eof \ No newline at end of file From 396d0703dd278b15ad9bd758cc6a648537532ab1 Mon Sep 17 00:00:00 2001 From: Maxime Kjaer Date: Sat, 7 Dec 2019 23:11:42 +0100 Subject: [PATCH 07/12] Fix lexing of Nginx comments at EOF --- lib/rouge/lexers/nginx.rb | 2 +- spec/lexers/nginx_spec.rb | 8 ++++++++ spec/visual/samples/nginx | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/rouge/lexers/nginx.rb b/lib/rouge/lexers/nginx.rb index 701b4fe16c..7aa70bd2f3 100644 --- a/lib/rouge/lexers/nginx.rb +++ b/lib/rouge/lexers/nginx.rb @@ -41,7 +41,7 @@ class Nginx < RegexLexer state :base do rule %r/\s+/, Text - rule %r/#.*?\n/, Comment::Single + rule %r/#.*?$/, Comment::Single rule %r/(?:on|off)\b/, Name::Constant rule %r/[$][\w-]+/, Name::Variable diff --git a/spec/lexers/nginx_spec.rb b/spec/lexers/nginx_spec.rb index 755a27a67a..95654fe873 100644 --- a/spec/lexers/nginx_spec.rb +++ b/spec/lexers/nginx_spec.rb @@ -16,4 +16,12 @@ assert_guess :mimetype => 'text/x-nginx-conf' end end + + describe 'lexing' do + include Support::Lexing + + it 'recognizes one-line comments not followed by a newline' do + assert_tokens_equal '# comment', ['Comment.Single', '# comment'] + end + end end diff --git a/spec/visual/samples/nginx b/spec/visual/samples/nginx index 50bd689776..aed9f1223f 100644 --- a/spec/visual/samples/nginx +++ b/spec/visual/samples/nginx @@ -115,3 +115,5 @@ http { } } + +# comment at eof \ No newline at end of file From 62e294b5d670659191ae940bbba1ad3912f632fb Mon Sep 17 00:00:00 2001 From: Maxime Kjaer Date: Sat, 7 Dec 2019 23:24:27 +0100 Subject: [PATCH 08/12] Fix lexing of m68k comments at EOF --- lib/rouge/lexers/m68k.rb | 4 ++-- spec/lexers/m68k_spec.rb | 18 ++++++++++++++++++ spec/visual/samples/m68k | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 spec/lexers/m68k_spec.rb diff --git a/lib/rouge/lexers/m68k.rb b/lib/rouge/lexers/m68k.rb index 2206fa734f..cb610b7477 100644 --- a/lib/rouge/lexers/m68k.rb +++ b/lib/rouge/lexers/m68k.rb @@ -87,8 +87,8 @@ def self.builtins state :whitespace do rule %r/\n+/m, Text, :expr_bol - rule %r(^\*(\\.|.)*?\n), Comment::Single, :expr_bol - rule %r(;(\\.|.)*?\n), Comment::Single, :expr_bol + rule %r(^\*(\\.|.)*?$), Comment::Single, :expr_bol + rule %r(;(\\.|.)*?$), Comment::Single, :expr_bol mixin :inline_whitespace end diff --git a/spec/lexers/m68k_spec.rb b/spec/lexers/m68k_spec.rb new file mode 100644 index 0000000000..8f17aa63bd --- /dev/null +++ b/spec/lexers/m68k_spec.rb @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- # +# frozen_string_literal: true + +describe Rouge::Lexers::M68k do + let(:subject) { Rouge::Lexers::M68k.new } + + describe 'lexing' do + include Support::Lexing + + it 'recognizes ";" comments not followed by a newline' do + assert_tokens_equal '; comment', ['Comment.Single', '; comment'] + end + + it 'recognizes "*" comments not followed by a newline' do + assert_tokens_equal '* comment', ['Comment.Single', '* comment'] + end + end +end diff --git a/spec/visual/samples/m68k b/spec/visual/samples/m68k index 3018f846d3..225a2764d5 100644 --- a/spec/visual/samples/m68k +++ b/spec/visual/samples/m68k @@ -57,3 +57,5 @@ restore: ; go back into user mode rts oldstack dc.l 0 + +; comment at eof \ No newline at end of file From fc745ee8b34dfd56f6aab1e4eb126ca16889cb7e Mon Sep 17 00:00:00 2001 From: Maxime Kjaer Date: Sat, 7 Dec 2019 23:31:50 +0100 Subject: [PATCH 09/12] Fix lexing of IO comments at EOF --- lib/rouge/lexers/io.rb | 4 ++-- spec/lexers/io_spec.rb | 12 ++++++++++++ spec/visual/samples/io | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/rouge/lexers/io.rb b/lib/rouge/lexers/io.rb index ab919040af..21ef10ba9e 100644 --- a/lib/rouge/lexers/io.rb +++ b/lib/rouge/lexers/io.rb @@ -27,8 +27,8 @@ def self.builtins state :root do rule %r/\s+/m, Text - rule %r(//.*?\n), Comment::Single - rule %r(#.*?\n), Comment::Single + rule %r(//.*?$), Comment::Single + rule %r(#.*?$), Comment::Single rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline rule %r(/[+]), Comment::Multiline, :nested_comment diff --git a/spec/lexers/io_spec.rb b/spec/lexers/io_spec.rb index 7175dba6fd..cd5e8e068a 100644 --- a/spec/lexers/io_spec.rb +++ b/spec/lexers/io_spec.rb @@ -19,4 +19,16 @@ assert_guess :source => '#!/usr/local/bin/io' end end + + describe 'lexing' do + include Support::Lexing + + it 'recognizes one-line "//" comments not followed by a newline' do + assert_tokens_equal '// comment', ['Comment.Single', '// comment'] + end + + it 'recognizes one-line "#" comments not followed by a newline' do + assert_tokens_equal '# comment', ['Comment.Single', '# comment'] + end + end end diff --git a/spec/visual/samples/io b/spec/visual/samples/io index 89ed824b95..4c1059e58f 100644 --- a/spec/visual/samples/io +++ b/spec/visual/samples/io @@ -37,3 +37,5 @@ n := System args at(1) asNumber nsieve( (2^n)*10000 ) nsieve( (2^(n-1))*10000 ) nsieve( (2^(n-2))*10000 ) + +// comment at eof \ No newline at end of file From 6cd1f8a0dfc1b31727679e7bca6614ef9d6ed92f Mon Sep 17 00:00:00 2001 From: Maxime Kjaer Date: Sat, 7 Dec 2019 23:33:45 +0100 Subject: [PATCH 10/12] Fix lexing of Dot comments at EOF --- lib/rouge/lexers/dot.rb | 4 ++-- spec/lexers/dot_spec.rb | 12 ++++++++++++ spec/visual/samples/dot | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/rouge/lexers/dot.rb b/lib/rouge/lexers/dot.rb index 1d4a025fa3..b4be6e333d 100644 --- a/lib/rouge/lexers/dot.rb +++ b/lib/rouge/lexers/dot.rb @@ -17,8 +17,8 @@ class Dot < RegexLexer state :comments_and_whitespace do rule %r/\s+/, Text - rule %r(#.*?\n), Comment::Single - rule %r(//.*?\n), Comment::Single + rule %r(#.*?$), Comment::Single + rule %r(//.*?$), Comment::Single rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline end diff --git a/spec/lexers/dot_spec.rb b/spec/lexers/dot_spec.rb index 14a2d75dfb..d051d2da74 100644 --- a/spec/lexers/dot_spec.rb +++ b/spec/lexers/dot_spec.rb @@ -15,4 +15,16 @@ assert_guess :mimetype => 'text/vnd.graphviz' end end + + describe 'lexing' do + include Support::Lexing + + it 'recognizes one-line "//" comments not followed by a newline' do + assert_tokens_equal '// comment', ['Comment.Single', '// comment'] + end + + it 'recognizes one-line "#" comments not followed by a newline' do + assert_tokens_equal '# comment', ['Comment.Single', '# comment'] + end + end end diff --git a/spec/visual/samples/dot b/spec/visual/samples/dot index 7da56a46da..0c14897501 100644 --- a/spec/visual/samples/dot +++ b/spec/visual/samples/dot @@ -16,3 +16,5 @@ digraph graphname { testing [some=nastyHTML>]; } + +// comment at eof \ No newline at end of file From 5bc2717f17e735adde7c492db084ea149afb3f31 Mon Sep 17 00:00:00 2001 From: Maxime Kjaer Date: Sat, 7 Dec 2019 23:35:33 +0100 Subject: [PATCH 11/12] Fix lexing of D comments at EOF --- lib/rouge/lexers/d.rb | 2 +- spec/lexers/d_spec.rb | 8 ++++++++ spec/visual/samples/d | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/rouge/lexers/d.rb b/lib/rouge/lexers/d.rb index 3603e70877..bc4b6c8082 100644 --- a/lib/rouge/lexers/d.rb +++ b/lib/rouge/lexers/d.rb @@ -48,7 +48,7 @@ module new nothrow out override package pragma state :root do mixin :whitespace # Comments - rule %r(//(.*?)\n), Comment::Single + rule %r(//(.*?)$), Comment::Single rule %r(/(\\\n)?[*](.|\n)*?[*](\\\n)?/), Comment::Multiline rule %r(/\+), Comment::Multiline, :nested_comment # Keywords diff --git a/spec/lexers/d_spec.rb b/spec/lexers/d_spec.rb index 5e9de5dda4..0c76c095cf 100644 --- a/spec/lexers/d_spec.rb +++ b/spec/lexers/d_spec.rb @@ -17,4 +17,12 @@ assert_guess :mimetype => 'application/x-dsrc' end end + + describe 'lexing' do + include Support::Lexing + + it 'recognizes one-line comments not followed by a newline' do + assert_tokens_equal '// comment', ['Comment.Single', '// comment'] + end + end end diff --git a/spec/visual/samples/d b/spec/visual/samples/d index 5883a2315c..83c9eb4edd 100644 --- a/spec/visual/samples/d +++ b/spec/visual/samples/d @@ -1584,3 +1584,5 @@ pure nothrow @safe @nogc unittest testVal = null; assert(testVal.isNull); } + +// comment at eof \ No newline at end of file From cbb49f124cdd8cc9e24ea3c992bfc5d43948287b Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Mon, 9 Dec 2019 08:57:13 +0900 Subject: [PATCH 12/12] Remove unnecessary regex operators --- lib/rouge/lexers/d.rb | 2 +- lib/rouge/lexers/dot.rb | 2 +- lib/rouge/lexers/io.rb | 4 ++-- lib/rouge/lexers/nginx.rb | 2 +- lib/rouge/lexers/pony.rb | 2 +- lib/rouge/lexers/scala.rb | 6 +++--- lib/rouge/lexers/sieve.rb | 2 +- lib/rouge/lexers/sqf.rb | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/rouge/lexers/d.rb b/lib/rouge/lexers/d.rb index bc4b6c8082..527e997c15 100644 --- a/lib/rouge/lexers/d.rb +++ b/lib/rouge/lexers/d.rb @@ -48,7 +48,7 @@ module new nothrow out override package pragma state :root do mixin :whitespace # Comments - rule %r(//(.*?)$), Comment::Single + rule %r(//.*), Comment::Single rule %r(/(\\\n)?[*](.|\n)*?[*](\\\n)?/), Comment::Multiline rule %r(/\+), Comment::Multiline, :nested_comment # Keywords diff --git a/lib/rouge/lexers/dot.rb b/lib/rouge/lexers/dot.rb index b4be6e333d..5742e945dd 100644 --- a/lib/rouge/lexers/dot.rb +++ b/lib/rouge/lexers/dot.rb @@ -17,7 +17,7 @@ class Dot < RegexLexer state :comments_and_whitespace do rule %r/\s+/, Text - rule %r(#.*?$), Comment::Single + rule %r(#.*), Comment::Single rule %r(//.*?$), Comment::Single rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline end diff --git a/lib/rouge/lexers/io.rb b/lib/rouge/lexers/io.rb index 21ef10ba9e..9e049a9ca3 100644 --- a/lib/rouge/lexers/io.rb +++ b/lib/rouge/lexers/io.rb @@ -27,8 +27,8 @@ def self.builtins state :root do rule %r/\s+/m, Text - rule %r(//.*?$), Comment::Single - rule %r(#.*?$), Comment::Single + rule %r(//.*), Comment::Single + rule %r(#.*), Comment::Single rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline rule %r(/[+]), Comment::Multiline, :nested_comment diff --git a/lib/rouge/lexers/nginx.rb b/lib/rouge/lexers/nginx.rb index 7aa70bd2f3..f654762eaf 100644 --- a/lib/rouge/lexers/nginx.rb +++ b/lib/rouge/lexers/nginx.rb @@ -41,7 +41,7 @@ class Nginx < RegexLexer state :base do rule %r/\s+/, Text - rule %r/#.*?$/, Comment::Single + rule %r/#.*/, Comment::Single rule %r/(?:on|off)\b/, Name::Constant rule %r/[$][\w-]+/, Name::Variable diff --git a/lib/rouge/lexers/pony.rb b/lib/rouge/lexers/pony.rb index a411be46ab..b0510b6505 100644 --- a/lib/rouge/lexers/pony.rb +++ b/lib/rouge/lexers/pony.rb @@ -46,7 +46,7 @@ class compiler_intrinsic consume continue state :root do mixin :whitespace rule %r/"""/, Str::Doc, :docstring - rule %r{//(.*?)$}, Comment::Single + rule %r{//.*}, Comment::Single rule %r{/(\\\n)?[*](.|\n)*?[*](\\\n)?/}, Comment::Multiline rule %r/"/, Str, :string rule %r([~!%^&*+=\|?:<>/-]), Operator diff --git a/lib/rouge/lexers/scala.rb b/lib/rouge/lexers/scala.rb index 99cb74c43f..0c34b87d86 100644 --- a/lib/rouge/lexers/scala.rb +++ b/lib/rouge/lexers/scala.rb @@ -43,7 +43,7 @@ class Scala < RegexLexer rule %r/'#{idrest}[^']/, Str::Symbol rule %r/[^\S\n]+/, Text - rule %r(//.*?$), Comment::Single + rule %r(//.*), Comment::Single rule %r(/\*), Comment::Multiline, :comment rule %r/@#{idrest}/, Name::Decorator @@ -117,7 +117,7 @@ class Scala < RegexLexer rule %r/\s+/, Text rule %r/{/, Operator, :pop! rule %r/\(/, Operator, :pop! - rule %r(//.*?$), Comment::Single, :pop! + rule %r(//.*), Comment::Single, :pop! rule %r(#{idrest}|#{op}+|`[^`]+`), Name::Class, :pop! end @@ -142,7 +142,7 @@ class Scala < RegexLexer pop! end - rule %r(//.*?$), Comment::Single, :pop! + rule %r(//.*), Comment::Single, :pop! rule %r/\.|#{idrest}|#{op}+|`[^`]+`/, Keyword::Type end diff --git a/lib/rouge/lexers/sieve.rb b/lib/rouge/lexers/sieve.rb index 59894f6386..08d60327e5 100644 --- a/lib/rouge/lexers/sieve.rb +++ b/lib/rouge/lexers/sieve.rb @@ -58,7 +58,7 @@ def self.tests state :comments_and_whitespace do rule %r/\s+/, Text - rule %r(#.*?$), Comment::Single + rule %r(#.*), Comment::Single rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline end diff --git a/lib/rouge/lexers/sqf.rb b/lib/rouge/lexers/sqf.rb index b61dc60c52..975faf92d5 100644 --- a/lib/rouge/lexers/sqf.rb +++ b/lib/rouge/lexers/sqf.rb @@ -65,7 +65,7 @@ def self.commands # Preprocessor instructions rule %r"/\*.*?\*/"m, Comment::Multiline - rule %r"//.*$", Comment::Single + rule %r"//.*", Comment::Single rule %r"#(define|undef|if(n)?def|else|endif|include)", Comment::Preproc rule %r"\\\r?\n", Comment::Preproc rule %r"__(EVAL|EXEC|LINE__|FILE__)", Name::Builtin