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

- old
+ new

@@ -177,114 +177,114 @@ | \.\^ | \.\\ | \.\/ | \\ | < | > | รท | >: | : | === | !== | => /x - PUNCTUATION = / [ \[ \] { } \( \) , ; ] /x + PUNCTUATION = /[\[\]{}\(\),;]/ state :root do - rule /\n/, Text - rule /[^\S\n]+/, Text - rule /#=/, Comment::Multiline, :blockcomment - rule /#.*$/, Comment + rule %r/\n/, Text + rule %r/[^\S\n]+/, Text + rule %r/#=/, Comment::Multiline, :blockcomment + rule %r/#.*$/, Comment rule OPERATORS, Operator - rule /\\\n/, Text - rule /\\/, Text + rule %r/\\\n/, Text + rule %r/\\/, Text # functions and macros - rule /(function|macro)((?:\s|\\\s)+)/ do + rule %r/(function|macro)((?:\s|\\\s)+)/ do groups Keyword, Name::Function push :funcname end # types - rule /((mutable )?struct|(abstract|primitive) type)((?:\s|\\\s)+)/ do + rule %r/((mutable )?struct|(abstract|primitive) type)((?:\s|\\\s)+)/ do groups Keyword, Name::Class push :typename end rule TYPES, Keyword::Type # keywords - rule /(local|global|const)\b/, Keyword::Declaration + rule %r/(local|global|const)\b/, Keyword::Declaration rule KEYWORDS, Keyword # TODO: end is a builtin when inside of an indexing expression rule BUILTINS, Name::Builtin # TODO: symbols # backticks - rule /`.*?`/, Literal::String::Backtick + rule %r/`.*?`/, Literal::String::Backtick # chars - rule /'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,3}|\\u[a-fA-F0-9]{1,4}|\\U[a-fA-F0-9]{1,6}|[^\\\'\n])'/, Literal::String::Char + rule %r/'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,3}|\\u[a-fA-F0-9]{1,4}|\\U[a-fA-F0-9]{1,6}|[^\\\'\n])'/, Literal::String::Char # try to match trailing transpose - rule /(?<=[.\w)\]])\'+/, Operator + rule %r/(?<=[.\w)\]])\'+/, Operator # strings # TODO: triple quoted string literals # TODO: Detect string interpolation - rule /(?:[IL])"/, Literal::String, :string - rule /[E]?"/, Literal::String, :string + rule %r/(?:[IL])"/, Literal::String, :string + rule %r/[E]?"/, Literal::String, :string # names - rule /@[\w.]+/, Name::Decorator - rule /(?:[a-zA-Z_\u00A1-\uffff]|[\u1000-\u10ff])(?:[a-zA-Z_0-9\u00A1-\uffff]|[\u1000-\u10ff])*!*/, Name + rule %r/@[\w.]+/, Name::Decorator + rule %r/(?:[a-zA-Z_\u00A1-\uffff]|[\u1000-\u10ff])(?:[a-zA-Z_0-9\u00A1-\uffff]|[\u1000-\u10ff])*!*/, Name rule PUNCTUATION, Other # numbers - rule /(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?/, Literal::Number::Float - rule /(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?/, Literal::Number::Float - rule /\d+(_\d+)+[eEf][+-]?[0-9]+/, Literal::Number::Float - rule /\d+[eEf][+-]?[0-9]+/, Literal::Number::Float - rule /0b[01]+(_[01]+)+/, Literal::Number::Bin - rule /0b[01]+/, Literal::Number::Bin - rule /0o[0-7]+(_[0-7]+)+/, Literal::Number::Oct - rule /0o[0-7]+/, Literal::Number::Oct - rule /0x[a-fA-F0-9]+(_[a-fA-F0-9]+)+/, Literal::Number::Hex - rule /0x[a-fA-F0-9]+/, Literal::Number::Hex - rule /\d+(_\d+)+/, Literal::Number::Integer - rule /\d+/, Literal::Number::Integer + rule %r/(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?/, Literal::Number::Float + rule %r/(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?/, Literal::Number::Float + rule %r/\d+(_\d+)+[eEf][+-]?[0-9]+/, Literal::Number::Float + rule %r/\d+[eEf][+-]?[0-9]+/, Literal::Number::Float + rule %r/0b[01]+(_[01]+)+/, Literal::Number::Bin + rule %r/0b[01]+/, Literal::Number::Bin + rule %r/0o[0-7]+(_[0-7]+)+/, Literal::Number::Oct + rule %r/0o[0-7]+/, Literal::Number::Oct + rule %r/0x[a-fA-F0-9]+(_[a-fA-F0-9]+)+/, Literal::Number::Hex + rule %r/0x[a-fA-F0-9]+/, Literal::Number::Hex + rule %r/\d+(_\d+)+/, Literal::Number::Integer + rule %r/\d+/, Literal::Number::Integer end state :funcname do - rule /[a-zA-Z_]\w*/, Name::Function, :pop! - rule /\([^\s\w{]{1,2}\)/, Operator, :pop! - rule /[^\s\w{]{1,2}/, Operator, :pop! + rule %r/[a-zA-Z_]\w*/, Name::Function, :pop! + rule %r/\([^\s\w{]{1,2}\)/, Operator, :pop! + rule %r/[^\s\w{]{1,2}/, Operator, :pop! end state :typename do - rule /[a-zA-Z_]\w*/, Name::Class, :pop! + rule %r/[a-zA-Z_]\w*/, Name::Class, :pop! end state :stringescape do - rule /\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})/, + rule %r/\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})/, Literal::String::Escape end state :blockcomment do - rule /[^=#]/, Comment::Multiline - rule /#=/, Comment::Multiline, :blockcomment - rule /\=#/, Comment::Multiline, :pop! - rule /[=#]/, Comment::Multiline + rule %r/[^=#]/, Comment::Multiline + rule %r/#=/, Comment::Multiline, :blockcomment + rule %r/\=#/, Comment::Multiline, :pop! + rule %r/[=#]/, Comment::Multiline end state :string do mixin :stringescape - rule /"/, Literal::String, :pop! - rule /\\\\|\\"|\\\n/, Literal::String::Escape # included here for raw strings - rule /\$(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?/, Literal::String::Interpol - rule /[^\\"$]+/, Literal::String + rule %r/"/, Literal::String, :pop! + rule %r/\\\\|\\"|\\\n/, Literal::String::Escape # included here for raw strings + rule %r/\$(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?/, Literal::String::Interpol + rule %r/[^\\"$]+/, Literal::String # quotes, dollar signs, and backslashes must be parsed one at a time - rule /["\\]/, Literal::String + rule %r/["\\]/, Literal::String # unhandled string formatting sign - rule /\$/, Literal::String + rule %r/\$/, Literal::String end end end end