diff --git a/lib/rouge/lexers/lustre.rb b/lib/rouge/lexers/lustre.rb index 73701c1093..65cced8998 100644 --- a/lib/rouge/lexers/lustre.rb +++ b/lib/rouge/lexers/lustre.rb @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# -# adapted from ocaml.rb, hence some ocaml-ism migth remains +# frozen_string_literal: true + module Rouge module Lexers class Lustre < RegexLexer @@ -12,16 +12,16 @@ class Lustre < RegexLexer def self.keywords @keywords ||= Set.new %w( - extern unsafe assert const current enum function - let node operator returns - step struct tel type var model package needs - provides uses is body end include merge + extern unsafe assert const current enum function let node operator + returns step struct tel type var model package needs provides uses is + body end include merge ) end def self.word_operators @word_operators ||= Set.new %w( - div and xor mod or not nor if then else fby pre when with) + div and xor mod or not nor if then else fby pre when with + ) end def self.primitives @@ -32,8 +32,8 @@ def self.primitives id = /[a-z_][\w']*/i state :root do - rule (/\s+/m), Text - rule (/false|true/), Keyword::Constant + rule %r/\s+/m, Text + rule %r/false|true/, Keyword::Constant rule %r(\-\-.*), Comment::Single rule %r(/\*.*?\*/)m, Comment::Multiline rule %r(\(\*.*?\*\))m, Comment::Multiline @@ -50,31 +50,30 @@ def self.primitives end end - rule (/[(){}\[\];]+/), Punctuation + rule %r/[(){}\[\];]+/, Punctuation rule operator, Operator - rule (/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i), Num::Float - rule (/\d[\d_]*/), Num::Integer + rule %r/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float + rule %r/\d[\d_]*/, Num::Integer - rule (/'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/), Str::Char - rule (/'[.]'/), Str::Char - rule (/"/), Str::Double, :string - rule (/[~?]#{id}/), Name::Variable + rule %r/'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/, Str::Char + rule %r/'[.]'/, Str::Char + rule %r/"/, Str::Double, :string + rule %r/[~?]#{id}/, Name::Variable end state :string do - rule (/[^\\"]+/), Str::Double + rule %r/[^\\"]+/, Str::Double mixin :escape_sequence - rule (/\\\n/), Str::Double - rule (/"/), Str::Double, :pop! + rule %r/\\\n/, Str::Double + rule %r/"/, Str::Double, :pop! end state :escape_sequence do - rule (/\\[\\"'ntbr]/), Str::Escape - rule (/\\\d{3}/), Str::Escape - rule (/\\x\h{2}/), Str::Escape + rule %r/\\[\\"'ntbr]/, Str::Escape + rule %r/\\\d{3}/, Str::Escape + rule %r/\\x\h{2}/, Str::Escape end - end end end diff --git a/spec/lexers/lustre_spec.rb b/spec/lexers/lustre_spec.rb index caa26228e0..bba0eec25c 100644 --- a/spec/lexers/lustre_spec.rb +++ b/spec/lexers/lustre_spec.rb @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- # +# frozen_string_literal: true describe Rouge::Lexers::Lustre do let(:subject) { Rouge::Lexers::Lustre.new } @@ -15,4 +16,3 @@ end end end - diff --git a/spec/visual/samples/lustre b/spec/visual/samples/lustre index 855c16ef1c..ab3248d08b 100644 --- a/spec/visual/samples/lustre +++ b/spec/visual/samples/lustre @@ -2,8 +2,8 @@ -- Constants const size = 50; -- size of the sliding windows used to smooth values -const period = 0.1; -- in seconds -const speed_max = 110.0; -- comment with leading whitespace +const period = 0.1; -- in seconds +const speed_max = 110.0; -- comment with leading whitespace -- Types type roof_state = enum { locked, in_motion };