lib/rouge/lexers/sml.rb in rouge-3.4.1 vs lib/rouge/lexers/sml.rb in rouge-3.5.0

- old
+ new

@@ -28,29 +28,29 @@ id = /[\w']+/i symbol = %r([!%&$#/:<=>?@\\~`^|*+-]+) state :whitespace do - rule /\s+/m, Text - rule /[(][*]/, Comment, :comment + rule %r/\s+/m, Text + rule %r/[(][*]/, Comment, :comment end state :delimiters do - rule /[(\[{]/, Punctuation, :main - rule /[)\]}]/, Punctuation, :pop! + rule %r/[(\[{]/, Punctuation, :main + rule %r/[)\]}]/, Punctuation, :pop! - rule /\b(let|if|local)\b(?!')/ do + rule %r/\b(let|if|local)\b(?!')/ do token Keyword::Reserved push; push end - rule /\b(struct|sig|while)\b(?!')/ do + rule %r/\b(struct|sig|while)\b(?!')/ do token Keyword::Reserved push end - rule /\b(do|else|end|in|then)\b(?!')/, Keyword::Reserved, :pop! + rule %r/\b(do|else|end|in|then)\b(?!')/, Keyword::Reserved, :pop! end def token_for_id_with_dot(id) if self.class.keywords.include? id Error @@ -76,32 +76,32 @@ Name end end state :core do - rule /[()\[\]{},;_]|[.][.][.]/, Punctuation - rule /#"/, Str::Char, :char - rule /"/, Str::Double, :string - rule /~?0x[0-9a-fA-F]+/, Num::Hex - rule /0wx[0-9a-fA-F]+/, Num::Hex - rule /0w\d+/, Num::Integer - rule /~?\d+([.]\d+)?[eE]~?\d+/, Num::Float - rule /~?\d+[.]\d+/, Num::Float - rule /~?\d+/, Num::Integer + rule %r/[()\[\]{},;_]|[.][.][.]/, Punctuation + rule %r/#"/, Str::Char, :char + rule %r/"/, Str::Double, :string + rule %r/~?0x[0-9a-fA-F]+/, Num::Hex + rule %r/0wx[0-9a-fA-F]+/, Num::Hex + rule %r/0w\d+/, Num::Integer + rule %r/~?\d+([.]\d+)?[eE]~?\d+/, Num::Float + rule %r/~?\d+[.]\d+/, Num::Float + rule %r/~?\d+/, Num::Integer - rule /#\s*[1-9][0-9]*/, Name::Label - rule /#\s*#{id}/, Name::Label - rule /#\s+#{symbol}/, Name::Label + rule %r/#\s*[1-9][0-9]*/, Name::Label + rule %r/#\s*#{id}/, Name::Label + rule %r/#\s+#{symbol}/, Name::Label - rule /\b(datatype|abstype)\b(?!')/, Keyword::Reserved, :dname + rule %r/\b(datatype|abstype)\b(?!')/, Keyword::Reserved, :dname rule(/(?=\bexception\b(?!'))/) { push :ename } - rule /\b(functor|include|open|signature|structure)\b(?!')/, + rule %r/\b(functor|include|open|signature|structure)\b(?!')/, Keyword::Reserved, :sname - rule /\b(type|eqtype)\b(?!')/, Keyword::Reserved, :tname + rule %r/\b(type|eqtype)\b(?!')/, Keyword::Reserved, :tname - rule /'#{id}/, Name::Decorator - rule /(#{id})([.])/ do |m| + rule %r/'#{id}/, Name::Decorator + rule %r/(#{id})([.])/ do |m| groups(token_for_id_with_dot(m[1]), Punctuation) push :dotted end rule id do |m| @@ -112,11 +112,11 @@ token token_for_id(m[0]) end end state :dotted do - rule /(#{id})([.])/ do |m| + rule %r/(#{id})([.])/ do |m| groups(token_for_id_with_dot(m[1]), Punctuation) end rule id do |m| token token_for_id(m[0]) @@ -128,19 +128,19 @@ pop! end end state :root do - rule /#!.*?\n/, Comment::Preproc + rule %r/#!.*?\n/, Comment::Preproc rule(//) { push :main } end state :main do mixin :whitespace - rule /\b(val|and)\b(?!')/, Keyword::Reserved, :vname - rule /\b(fun)\b(?!')/ do + rule %r/\b(val|and)\b(?!')/, Keyword::Reserved, :vname + rule %r/\b(fun)\b(?!')/ do token Keyword::Reserved goto :main_fun push :fname end @@ -148,49 +148,49 @@ mixin :core end state :main_fun do mixin :whitespace - rule /\b(fun|and)\b(?!')/, Keyword::Reserved, :fname - rule /\bval\b(?!')/ do + rule %r/\b(fun|and)\b(?!')/, Keyword::Reserved, :fname + rule %r/\bval\b(?!')/ do token Keyword::Reserved goto :main push :vname end - rule /[|]/, Punctuation, :fname - rule /\b(case|handle)\b(?!')/ do + rule %r/[|]/, Punctuation, :fname + rule %r/\b(case|handle)\b(?!')/ do token Keyword::Reserved goto :main end mixin :delimiters mixin :core end state :has_escapes do - rule /\\[\\"abtnvfr]/, Str::Escape - rule /\\\^[\x40-\x5e]/, Str::Escape - rule /\\[0-9]{3}/, Str::Escape - rule /\\u\h{4}/, Str::Escape - rule /\\\s+\\/, Str::Interpol + rule %r/\\[\\"abtnvfr]/, Str::Escape + rule %r/\\\^[\x40-\x5e]/, Str::Escape + rule %r/\\[0-9]{3}/, Str::Escape + rule %r/\\u\h{4}/, Str::Escape + rule %r/\\\s+\\/, Str::Interpol end state :string do - rule /[^"\\]+/, Str::Double - rule /"/, Str::Double, :pop! + rule %r/[^"\\]+/, Str::Double + rule %r/"/, Str::Double, :pop! mixin :has_escapes end state :char do - rule /[^"\\]+/, Str::Char - rule /"/, Str::Char, :pop! + rule %r/[^"\\]+/, Str::Char + rule %r/"/, Str::Char, :pop! mixin :has_escapes end state :breakout do - rule /(?=\b(#{SML.keywords.to_a.join('|')})\b(?!'))/ do + rule %r/(?=\b(#{SML.keywords.to_a.join('|')})\b(?!'))/ do pop! end end state :sname do @@ -199,12 +199,12 @@ rule id, Name::Namespace rule(//) { pop! } end state :has_annotations do - rule /'[\w']*/, Name::Decorator - rule /[(]/, Punctuation, :tyvarseq + rule %r/'[\w']*/, Name::Decorator + rule %r/[(]/, Punctuation, :tyvarseq end state :fname do mixin :whitespace mixin :has_annotations @@ -215,16 +215,16 @@ state :vname do mixin :whitespace mixin :has_annotations - rule /(#{id})(\s*)(=(?!#{symbol}))/m do + rule %r/(#{id})(\s*)(=(?!#{symbol}))/m do groups Name::Variable, Text, Punctuation pop! end - rule /(#{symbol})(\s*)(=(?!#{symbol}))/m do + rule %r/(#{symbol})(\s*)(=(?!#{symbol}))/m do groups Name::Variable, Text, Punctuation end rule id, Name::Variable, :pop! rule symbol, Name::Variable, :pop! @@ -235,12 +235,12 @@ state :tname do mixin :whitespace mixin :breakout mixin :has_annotations - rule /'[\w']*/, Name::Decorator - rule /[(]/, Punctuation, :tyvarseq + rule %r/'[\w']*/, Name::Decorator + rule %r/[(]/, Punctuation, :tyvarseq rule %r(=(?!#{symbol})) do token Punctuation goto :typbind end @@ -250,11 +250,11 @@ end state :typbind do mixin :whitespace - rule /\b(and)\b(?!')/ do + rule %r/\b(and)\b(?!')/ do token Keyword::Reserved goto :tname end mixin :breakout @@ -264,11 +264,11 @@ state :dname do mixin :whitespace mixin :breakout mixin :has_annotations - rule /(=)(\s*)(datatype)\b/ do + rule %r/(=)(\s*)(datatype)\b/ do groups Punctuation, Text, Keyword::Reserved pop! end rule %r(=(?!#{symbol})) do @@ -281,40 +281,40 @@ rule symbol, Keyword::Type end state :datbind do mixin :whitespace - rule /\b(and)\b(?!')/ do + rule %r/\b(and)\b(?!')/ do token Keyword::Reserved; goto :dname end - rule /\b(withtype)\b(?!')/ do + rule %r/\b(withtype)\b(?!')/ do token Keyword::Reserved; goto :tname end - rule /\bof\b(?!')/, Keyword::Reserved - rule /([|])(\s*)(#{id})/ do + rule %r/\bof\b(?!')/, Keyword::Reserved + rule %r/([|])(\s*)(#{id})/ do groups(Punctuation, Text, Name::Class) end - rule /([|])(\s+)(#{symbol})/ do + rule %r/([|])(\s+)(#{symbol})/ do groups(Punctuation, Text, Name::Class) end mixin :breakout mixin :core end state :ename do mixin :whitespace - rule /(exception|and)(\s+)(#{id})/ do + rule %r/(exception|and)(\s+)(#{id})/ do groups Keyword::Reserved, Text, Name::Class end - rule /(exception|and)(\s*)(#{symbol})/ do + rule %r/(exception|and)(\s*)(#{symbol})/ do groups Keyword::Reserved, Text, Name::Class end - rule /\b(of)\b(?!')/, Keyword::Reserved + rule %r/\b(of)\b(?!')/, Keyword::Reserved mixin :breakout mixin :core end state :datcon do @@ -323,23 +323,23 @@ rule symbol, Name::Class, :pop! end state :tyvarseq do mixin :whitespace - rule /'[\w']*/, Name::Decorator + rule %r/'[\w']*/, Name::Decorator rule id, Name - rule /,/, Punctuation - rule /[)]/, Punctuation, :pop! + rule %r/,/, Punctuation + rule %r/[)]/, Punctuation, :pop! rule symbol, Name end state :comment do - rule /[^(*)]+/, Comment::Multiline - rule /[(][*]/ do + rule %r/[^(*)]+/, Comment::Multiline + rule %r/[(][*]/ do token Comment::Multiline; push end - rule /[*][)]/, Comment::Multiline, :pop! - rule /[(*)]/, Comment::Multiline + rule %r/[*][)]/, Comment::Multiline, :pop! + rule %r/[(*)]/, Comment::Multiline end end end end