From 18bc9c85d2c48b6a5e74b287ed81fc5d757de91b Mon Sep 17 00:00:00 2001 From: Ben Peachey Higdon Date: Fri, 27 Nov 2020 14:52:21 -0500 Subject: [PATCH 1/5] fix for messages that don't end with ( or ; --- lib/rouge/lexers/jsl.rb | 2 +- spec/visual/samples/jsl | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/rouge/lexers/jsl.rb b/lib/rouge/lexers/jsl.rb index 40571fad35..0bfeb0223f 100644 --- a/lib/rouge/lexers/jsl.rb +++ b/lib/rouge/lexers/jsl.rb @@ -17,7 +17,7 @@ class JSL < RegexLexer rule %r(/\*.*?\*/)m, Comment::Multiline # messages - rule %r/(<<)(.*?)(\(|;)/ do |m| + rule %r/(<<)(.*?)([(),;&|!=<>])/ do |m| groups Operator, Name::Function, Punctuation end diff --git a/spec/visual/samples/jsl b/spec/visual/samples/jsl index 8eeae87ace..7f27aa358b 100644 --- a/spec/visual/samples/jsl +++ b/spec/visual/samples/jsl @@ -20,5 +20,7 @@ date = 01jan00; dateTime = 12dec1999:12:30:00.45; New Window( "Rouge Test", - Text Box( "Syntax highlighting is great!" ) + tb = Text Box( "Syntax highlighting is great!" ) ); + +If(tb << Get Text != "", "I'm still formatted correctly!"); From 2393085d5356b63d69baea3b2750dac3b8b94107 Mon Sep 17 00:00:00 2001 From: Ben Peachey Higdon Date: Fri, 27 Nov 2020 14:53:59 -0500 Subject: [PATCH 2/5] handle nested block comments --- lib/rouge/lexers/jsl.rb | 9 ++++++++- spec/visual/samples/jsl | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/rouge/lexers/jsl.rb b/lib/rouge/lexers/jsl.rb index 0bfeb0223f..b72ef51f8a 100644 --- a/lib/rouge/lexers/jsl.rb +++ b/lib/rouge/lexers/jsl.rb @@ -14,7 +14,7 @@ class JSL < RegexLexer rule %r/\s+/m, Text::Whitespace rule %r(//.*?$), Comment::Single - rule %r(/\*.*?\*/)m, Comment::Multiline + rule %r'/[*].*', Comment::Multiline, :comment # messages rule %r/(<<)(.*?)([(),;&|!=<>])/ do |m| @@ -50,6 +50,13 @@ class JSL < RegexLexer rule %r/"/, Str::Double, :pop! rule %r/[^\\"]+/m, Str::Double end + + state :comment do + rule %r'/[*]', Comment::Multiline, :comment + rule %r'[*]/', Comment::Multiline, :pop! + rule %r'[^/*]+', Comment::Multiline + rule %r'[/*]', Comment::Multiline + end end end end diff --git a/spec/visual/samples/jsl b/spec/visual/samples/jsl index 7f27aa358b..f420de0421 100644 --- a/spec/visual/samples/jsl +++ b/spec/visual/samples/jsl @@ -5,6 +5,14 @@ dt << Distribution( Column( :age ), Histograms Only( 1 ) ); Multi-line comment */ +/* + Nested + /* + Comments + */ + Work +*/ + escapeSequence = "This is an \!b escaped sequence"; escapeQuote = "This is a \!" quotation mark"; escapeStr = "\[This is """"""" an escaped string]\" From 5c37a454e83aafad8ee86778e15187b92724e437 Mon Sep 17 00:00:00 2001 From: Ben Peachey Higdon Date: Fri, 27 Nov 2020 16:56:37 -0500 Subject: [PATCH 3/5] more correct lexing of messages --- lib/rouge/lexers/jsl.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/rouge/lexers/jsl.rb b/lib/rouge/lexers/jsl.rb index b72ef51f8a..560b56fb29 100644 --- a/lib/rouge/lexers/jsl.rb +++ b/lib/rouge/lexers/jsl.rb @@ -17,9 +17,7 @@ class JSL < RegexLexer rule %r'/[*].*', Comment::Multiline, :comment # messages - rule %r/(<<)(.*?)([(),;&|!=<>])/ do |m| - groups Operator, Name::Function, Punctuation - end + rule %r/<]/, Operator, :pop! + end + state :dq do rule %r/\\![btrnNf0\\"]/, Str::Escape rule %r/\\/, Str::Double From dd1644b84f80bc2b63d8e2a2a7d7f16ce9db6d76 Mon Sep 17 00:00:00 2001 From: Ben Peachey Higdon Date: Fri, 4 Dec 2020 12:14:26 -0500 Subject: [PATCH 4/5] add missing operators --- lib/rouge/lexers/jsl.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rouge/lexers/jsl.rb b/lib/rouge/lexers/jsl.rb index 560b56fb29..5c3a8022b2 100644 --- a/lib/rouge/lexers/jsl.rb +++ b/lib/rouge/lexers/jsl.rb @@ -38,7 +38,7 @@ class JSL < RegexLexer end rule %r/"/, Str::Double, :dq - rule %r/[-+*\/!%&<>\|=:]/, Operator + rule %r/[-+*\/!%&<>\|=:`^]/, Operator rule %r/[\[\](){},;]/, Punctuation end From 0add3f6a86ea6105cc76cfa1a46f408c8577380a Mon Sep 17 00:00:00 2001 From: Ben Peachey Higdon Date: Fri, 4 Dec 2020 12:20:13 -0500 Subject: [PATCH 5/5] parse decimals that start with . as nums --- lib/rouge/lexers/jsl.rb | 4 ++-- spec/visual/samples/jsl | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/rouge/lexers/jsl.rb b/lib/rouge/lexers/jsl.rb index 5c3a8022b2..2c435dec96 100644 --- a/lib/rouge/lexers/jsl.rb +++ b/lib/rouge/lexers/jsl.rb @@ -24,10 +24,10 @@ class JSL < RegexLexer groups Keyword, Punctuation end - rule %r/\b[+-]?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+|\.)(?:e[+-]?[0-9]+)?i?\b/i, Num - rule %r/\d{2}(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d{2}(\d{2})?(:\d{2}:\d{2}(:\d{2}(\.\d*)?)?)?/i, Literal::Date + rule %r/-?(?:[0-9]+(?:[.][0-9]+)?|[.][0-9]*)(?:e[+-]?[0-9]+)?i?/i, Num + rule %r/::[a-z_][\w\s'%.\\]*/i, Name::Variable rule %r/:\w+/, Name rule %r/[a-z_][\w\s'%.\\]*/i, Name::Variable diff --git a/spec/visual/samples/jsl b/spec/visual/samples/jsl index f420de0421..54c38a0bd5 100644 --- a/spec/visual/samples/jsl +++ b/spec/visual/samples/jsl @@ -24,6 +24,7 @@ a name with spaces = 5; scientificNotation = 5e9; decimal = 1.234; +missing = .; date = 01jan00; dateTime = 12dec1999:12:30:00.45;