fix errors in imported elixir mode
This commit is contained in:
parent
4da689e71b
commit
399e25ceaf
3 changed files with 43 additions and 22 deletions
|
|
@ -1 +1,24 @@
|
|||
TODO add a nice demo!
|
||||
defmodule HelloModule do
|
||||
# A "Hello world" function
|
||||
def some_fun do
|
||||
IO.puts "Juhu Kinners!"
|
||||
end
|
||||
# A private function
|
||||
defp priv do
|
||||
is_regex ~r"""
|
||||
This is a regex
|
||||
spanning several
|
||||
lines.
|
||||
"""
|
||||
x = elem({ :a, :b, :c }, 0) #=> :a
|
||||
end
|
||||
end
|
||||
|
||||
test_fun = fn(x) ->
|
||||
cond do
|
||||
x > 10 ->
|
||||
:greater_than_ten
|
||||
true ->
|
||||
:maybe_ten
|
||||
end
|
||||
end
|
||||
|
|
@ -39,7 +39,7 @@ var oop = require("../lib/oop");
|
|||
var TextMode = require("./text").Mode;
|
||||
var ElixirHighlightRules = require("./elixir_highlight_rules").ElixirHighlightRules;
|
||||
// TODO: pick appropriate fold mode
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
var FoldMode = require("./folding/coffee").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = ElixirHighlightRules;
|
||||
|
|
@ -48,7 +48,7 @@ var Mode = function() {
|
|||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
// this.lineCommentStart = ""@(?:module|type)?doc \""";
|
||||
this.lineCommentStart = "#";
|
||||
// this.blockComment = {start: ""/*"", end: ""*/""};
|
||||
// Extra logic goes here.
|
||||
this.$id = "ace/mode/elixir"
|
||||
|
|
|
|||
|
|
@ -101,11 +101,11 @@ var ElixirHighlightRules = function() {
|
|||
{ defaultToken: 'comment.documentation.string' } ],
|
||||
comment: '@doc with string is treated as documentation' },
|
||||
{ token: 'keyword.control.elixir',
|
||||
regex: '(?<!\\.)\\b(?:do|end|case|bc|lc|for|if|cond|unless|try|receive|fn|defmodule|defp?|defprotocol|defimpl|defrecord|defstruct|defmacrop?|defdelegate|defcallback|defmacrocallback|defexception|defoverridable|exit|after|rescue|catch|else|raise|throw|import|require|alias|use|quote|unquote|super)\\b(?![?!])',
|
||||
regex: '\\b(?:do|end|case|bc|lc|for|if|cond|unless|try|receive|fn|defmodule|defp?|defprotocol|defimpl|defrecord|defstruct|defmacrop?|defdelegate|defcallback|defmacrocallback|defexception|defoverridable|exit|after|rescue|catch|else|raise|throw|import|require|alias|use|quote|unquote|super)\\b(?![?!])',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<!\\.)\\b(do|end|case|bc|lc|for|if|cond|unless|try|receive|fn|defmodule|defp?|defprotocol|defimpl|defrecord|defstruct|defmacrop?|defdelegate|defcallback|defmacrocallback|defexception|defoverridable|exit|after|rescue|catch|else|raise|throw|import|require|alias|use|quote|unquote|super)\\b(?![?!])' },
|
||||
{ token: 'keyword.operator.elixir',
|
||||
regex: '(?<!\\.)\\b(?:and|not|or|when|xor|in|inlist|inbits)\\b',
|
||||
regex: '\\b(?:and|not|or|when|xor|in|inlist|inbits)\\b',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<!\\.)\\b(and|not|or|when|xor|in|inlist|inbits)\\b',
|
||||
comment: ' as above, just doesn\'t need a \'end\' and does a logic operation' },
|
||||
|
|
@ -124,7 +124,7 @@ var ElixirHighlightRules = function() {
|
|||
{ token: 'variable.other.constant.elixir',
|
||||
regex: '\\b[A-Z]\\w*\\b' },
|
||||
{ token: 'constant.numeric.elixir',
|
||||
regex: '\\b(?:0x[\\da-fA-F](?>_?[\\da-fA-F])*|\\d(?>_?\\d)*(?:\\.(?![^[:space:][:digit:]])(?>_?\\d)*)?(?:[eE][-+]?\\d(?>_?\\d)*)?|0b[01]+|0o[0-7]+)\\b',
|
||||
regex: '\\b(?:0x[\\da-fA-F](?:_?[\\da-fA-F])*|\\d(?:_?\\d)*(?:\\.(?![^[:space:][:digit:]])(?:_?\\d)*)?(?:[eE][-+]?\\d(?:_?\\d)*)?|0b[01]+|0o[0-7]+)\\b',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '\\b(0x\\h(?>_?\\h)*|\\d(?>_?\\d)*(\\.(?![^[:space:][:digit:]])(?>_?\\d)*)?([eE][-+]?\\d(?>_?\\d)*)?|0b[01]+|0o[0-7]+)\\b' },
|
||||
{ token: 'punctuation.definition.constant.elixir',
|
||||
|
|
@ -146,7 +146,7 @@ var ElixirHighlightRules = function() {
|
|||
{ include: '#escaped_char' },
|
||||
{ defaultToken: 'constant.other.symbol.double-quoted.elixir' } ] },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '(?>\'\'\')',
|
||||
regex: '(?:\'\'\')',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?>\'\'\')',
|
||||
push:
|
||||
|
|
@ -168,7 +168,7 @@ var ElixirHighlightRules = function() {
|
|||
{ defaultToken: 'support.function.variable.quoted.single.elixir' } ],
|
||||
comment: 'single quoted string (allows for interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '(?>""")',
|
||||
regex: '(?:""")',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?>""")',
|
||||
push:
|
||||
|
|
@ -190,7 +190,7 @@ var ElixirHighlightRules = function() {
|
|||
{ defaultToken: 'string.quoted.double.elixir' } ],
|
||||
comment: 'double quoted string (allows for interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[a-z](?>""")',
|
||||
regex: '~[a-z](?:""")',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '~[a-z](?>""")',
|
||||
push:
|
||||
|
|
@ -253,7 +253,7 @@ var ElixirHighlightRules = function() {
|
|||
{ defaultToken: 'string.interpolated.elixir' } ],
|
||||
comment: 'sigil (allow for interpolation)' },
|
||||
{ token: 'punctuation.definition.string.begin.elixir',
|
||||
regex: '~[A-Z](?>""")',
|
||||
regex: '~[A-Z](?:""")',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '~[A-Z](?>""")',
|
||||
push:
|
||||
|
|
@ -302,26 +302,26 @@ var ElixirHighlightRules = function() {
|
|||
next: 'pop' },
|
||||
{ defaultToken: 'string.quoted.other.literal.upper.elixir' } ],
|
||||
comment: 'sigil (without interpolation)' },
|
||||
{ token: 'punctuation.definition.constant.elixir',
|
||||
regex: '(?<!:):(?>[a-zA-Z_][\\w@]*(?>[?!]|=(?![>=]))?|\\<\\>|===?|!==?|<<>>|<<<|>>>|~~~|::|<\\-|\\|>|=>|~|~=|=|/|\\\\\\\\|\\*\\*?|\\.\\.?\\.?|>=?|<=?|&&?&?|\\+\\+?|\\-\\-?|\\|\\|?\\|?|\\!|@|\\%?\\{\\}|%|\\[\\]|\\^(?:\\^\\^)?)',
|
||||
{ token: ['punctuation.definition.constant.elixir', 'constant.other.symbol.elixir'],
|
||||
regex: '(:)([a-zA-Z_][\\w@]*(?:[?!]|=(?![>=]))?|\\<\\>|===?|!==?|<<>>|<<<|>>>|~~~|::|<\\-|\\|>|=>|~|~=|=|/|\\\\\\\\|\\*\\*?|\\.\\.?\\.?|>=?|<=?|&&?&?|\\+\\+?|\\-\\-?|\\|\\|?\\|?|\\!|@|\\%?\\{\\}|%|\\[\\]|\\^(?:\\^\\^)?)',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<!:)(:)(?>[a-zA-Z_][\\w@]*(?>[?!]|=(?![>=]))?|\\<\\>|===?|!==?|<<>>|<<<|>>>|~~~|::|<\\-|\\|>|=>|~|~=|=|/|\\\\\\\\|\\*\\*?|\\.\\.?\\.?|>=?|<=?|&&?&?|\\+\\+?|\\-\\-?|\\|\\|?\\|?|\\!|@|\\%?\\{\\}|%|\\[\\]|\\^(\\^\\^)?)',
|
||||
comment: 'symbols' },
|
||||
{ token: 'punctuation.definition.constant.elixir',
|
||||
regex: '(?>[a-zA-Z_][\\w@]*(?>[?!])?):(?!:)',
|
||||
regex: '(?:[a-zA-Z_][\\w@]*(?:[?!])?):(?!:)',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?>[a-zA-Z_][\\w@]*(?>[?!])?)(:)(?!:)',
|
||||
comment: 'symbols' },
|
||||
{ token:
|
||||
[ 'punctuation.definition.comment.elixir',
|
||||
'comment.line.number-sign.elixir' ],
|
||||
regex: '(?:^[ \\t]+)?(#)(.*$)' },
|
||||
regex: '(#)(.*)' },
|
||||
{ token: 'constant.numeric.elixir',
|
||||
regex: '(?<!\\w)\\?(?:\\\\(?:x[\\da-fA-F]{1,2}(?![\\da-fA-F])\\b|[^xMC])|[^\\s\\\\])',
|
||||
regex: '\\?(?:\\\\(?:x[\\da-fA-F]{1,2}(?![\\da-fA-F])\\b|[^xMC])|[^\\s\\\\])',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<!\\w)\\?(\\\\(x\\h{1,2}(?!\\h)\\b|[^xMC])|[^\\s\\\\])',
|
||||
comment: '\n\t\t\tmatches questionmark-letters.\n\n\t\t\texamples (1st alternation = hex):\n\t\t\t?\\x1 ?\\x61\n\n\t\t\texamples (2rd alternation = escaped):\n\t\t\t?\\n ?\\b\n\n\t\t\texamples (3rd alternation = normal):\n\t\t\t?a ?A ?0 \n\t\t\t?* ?" ?( \n\t\t\t?. ?#\n\t\t\t\n\t\t\tthe negative lookbehind prevents against matching\n\t\t\tp(42.tainted?)\n\t\t\t' },
|
||||
{ token: 'punctuation.separator.variable.elixir',
|
||||
/* { token: 'punctuation.separator.variable.elixir',
|
||||
regex: '(?<=\\{|do|\\{\\s|do\\s)\\|',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<=\\{|do|\\{\\s|do\\s)(\\|)',
|
||||
|
|
@ -331,16 +331,15 @@ var ElixirHighlightRules = function() {
|
|||
next: 'pop' },
|
||||
{ token: 'variable.other.block.elixir',
|
||||
regex: '[_a-zA-Z][_a-zA-Z0-9]*' },
|
||||
{ token: 'punctuation.separator.variable.elixir', regex: ',' } ] },
|
||||
{ token: 'punctuation.separator.variable.elixir', regex: ',' } ] },*/
|
||||
{ token: 'keyword.operator.assignment.augmented.elixir',
|
||||
regex: '\\+=|\\-=|\\|\\|=|~=|&&=' },
|
||||
{ token: 'keyword.operator.comparison.elixir',
|
||||
regex: '===?|!==?|<=?|>=?' },
|
||||
{ token: 'keyword.operator.bitwise.elixir',
|
||||
regex: '\\|\\|\\||&&&|^^^|<<<|>>>|~~~' },
|
||||
regex: '\\|{3}|&{3}|\\^{3}|<{3}|>{3}|~{3}' },
|
||||
{ token: 'keyword.operator.logical.elixir',
|
||||
regex: '(?<=[ \\t])!+|\\bnot\\b|&&|\\band\\b|\\|\\||\\bor\\b|\\bxor\\b',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
regex: '!+|\\bnot\\b|&&|\\band\\b|\\|\\||\\bor\\b|\\bxor\\b',
|
||||
originalRegex: '(?<=[ \\t])!+|\\bnot\\b|&&|\\band\\b|\\|\\||\\bor\\b|\\bxor\\b' },
|
||||
{ token: 'keyword.operator.arithmetic.elixir',
|
||||
regex: '\\*|\\+|\\-|/' },
|
||||
|
|
@ -411,8 +410,7 @@ var ElixirHighlightRules = function() {
|
|||
{ token:
|
||||
[ 'punctuation.definition.comment.elixir',
|
||||
'comment.line.number-sign.elixir' ],
|
||||
regex: '(?<=^|\\s)(#)(\\s[[a-zA-Z0-9,. \\t?!-][^\\x00-\\x7F]]*$)',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
regex: '(?:^|\\s)(#)(\\s[[a-zA-Z0-9,. \\t?!-][^\\x00-\\x7F]]*$)',
|
||||
originalRegex: '(?<=^|\\s)(#)\\s[[a-zA-Z0-9,. \\t?!-][^\\x{00}-\\x{7F}]]*$',
|
||||
comment: 'We are restrictive in what we allow to go after the comment character to avoid false positives, since the availability of comments depend on regexp flags.' } ] }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue