From ea07bfb4e70436fb33d59e1eb68ff8157b7fd0fc Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 15 May 2014 14:10:15 +0400 Subject: [PATCH] fix highlighting of unicode variables in julia --- demo/kitchen-sink/docs/julia.jl | 2 +- lib/ace/mode/_test/tokens_julia.json | 8 +++++++- lib/ace/mode/julia_highlight_rules.js | 12 ++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/demo/kitchen-sink/docs/julia.jl b/demo/kitchen-sink/docs/julia.jl index 97178469..f558ae22 100644 --- a/demo/kitchen-sink/docs/julia.jl +++ b/demo/kitchen-sink/docs/julia.jl @@ -2,7 +2,7 @@ for op = (:+, :*, :&, :|, :$) @eval ($op)(a,b,c) = ($op)(($op)(a,b),c) end - +v = α'; function g(x,y) return x * y x + y diff --git a/lib/ace/mode/_test/tokens_julia.json b/lib/ace/mode/_test/tokens_julia.json index f4ce4eab..5aaef6f9 100644 --- a/lib/ace/mode/_test/tokens_julia.json +++ b/lib/ace/mode/_test/tokens_julia.json @@ -38,7 +38,13 @@ ],[ "start" ],[ - "start" + "start", + ["text","v "], + ["keyword.operator.update.julia","="], + ["text"," "], + ["variable","α"], + ["keyword.operator.transposed-variable.julia","'"], + ["text",";"] ],[ "start", ["keyword.other.julia","function"], diff --git a/lib/ace/mode/julia_highlight_rules.js b/lib/ace/mode/julia_highlight_rules.js index fabec1e3..acff4f4a 100644 --- a/lib/ace/mode/julia_highlight_rules.js +++ b/lib/ace/mode/julia_highlight_rules.js @@ -63,11 +63,11 @@ var JuliaHighlightRules = function() { regex: '(#)(?!\\{)(.*$)'} ], '#function_call': [ { token: [ 'support.function.julia', 'text' ], - regex: '([a-zA-Z0-9_]+!?)(\\w*\\()'} ], + regex: '([a-zA-Z0-9_]+!?)([\\w\\xff-\\u218e\\u2455-\\uffff]*\\()'} ], '#function_decl': [ { token: [ 'keyword.other.julia', 'meta.function.julia', 'entity.name.function.julia', 'meta.function.julia','text' ], - regex: '(function|macro)(\\s*)([a-zA-Z0-9_\\{]+!?)(\\w*)([(\\\\{])'} ], + regex: '(function|macro)(\\s*)([a-zA-Z0-9_\\{]+!?)([\\w\\xff-\\u218e\\u2455-\\uffff]*)([(\\\\{])'} ], '#keyword': [ { token: 'keyword.other.julia', regex: '\\b(?:function|type|immutable|macro|quote|abstract|bitstype|typealias|module|baremodule|new)\\b' }, @@ -75,7 +75,7 @@ var JuliaHighlightRules = function() { regex: '\\b(?:if|else|elseif|while|for|in|begin|let|end|do|try|catch|finally|return|break|continue)\\b' }, { token: 'storage.modifier.variable.julia', regex: '\\b(?:global|local|const|export|import|importall|using)\\b' }, - { token: 'variable.macro.julia', regex: '@\\w+\\b' } ], + { token: 'variable.macro.julia', regex: '@[\\w\\xff-\\u218e\\u2455-\\uffff]+\\b' } ], '#number': [ { token: 'constant.numeric.julia', regex: '\\b0(?:x|X)[0-9a-fA-F]*|(?:\\b[0-9]+\\.?[0-9]*|\\.[0-9]+)(?:(?:e|E)(?:\\+|-)?[0-9]*)?(?:im)?|\\bInf(?:32)?\\b|\\bNaN(?:32)?\\b|\\btrue\\b|\\bfalse\\b' } ], @@ -99,7 +99,7 @@ var JuliaHighlightRules = function() { { token: 'keyword.operator.interpolation.julia', regex: '\\$#?(?=.)' }, { token: [ 'variable', 'keyword.operator.transposed-variable.julia' ], - regex: '(\\w+)((?:\'|\\.\')*\\.?\')' }, + regex: '([\\w\\xff-\\u218e\\u2455-\\uffff]+)((?:\'|\\.\')*\\.?\')' }, { token: 'text', regex: '\\[|\\('}, { token: [ 'text', 'keyword.operator.transposed-matrix.julia' ], @@ -122,10 +122,10 @@ var JuliaHighlightRules = function() { { include: '#string_escaped_char' }, { defaultToken: 'string.quoted.double.julia' } ] }, { token: 'punctuation.definition.string.begin.julia', - regex: '\\b\\w+"', + regex: '\\b[\\w\\xff-\\u218e\\u2455-\\uffff]+"', push: [ { token: 'punctuation.definition.string.end.julia', - regex: '"\\w*', + regex: '"[\\w\\xff-\\u218e\\u2455-\\uffff]*', next: 'pop' }, { include: '#string_custom_escaped_char' }, { defaultToken: 'string.quoted.custom-double.julia' } ] },