diff --git a/Regular Expressions (Elixir).sublime-syntax b/Regular Expressions (Elixir).sublime-syntax index bb5cafff..eab88eee 100644 --- a/Regular Expressions (Elixir).sublime-syntax +++ b/Regular Expressions (Elixir).sublime-syntax @@ -25,6 +25,7 @@ contexts: - include: subroutine_call - include: back_reference - include: assertion + - include: comment - include: escape_sequence - include: class_set - include: inline_option @@ -33,7 +34,6 @@ contexts: - include: operator - include: quantifier - include: dot_meta_char - - include: comment - include: literal quoted_sequence: @@ -367,16 +367,11 @@ contexts: - match: \[:.*?:\] scope: invalid.illegal.posix-class.regexp.elixir set: unexpected_quantifier_pop - - match: (\[)(\]) - scope: meta.set.regexp.elixir keyword.control.set.regexp.elixir invalid.illegal.set.regexp.elixir - captures: - 1: punctuation.definition.set.begin.regexp.elixir - 2: punctuation.definition.set.end.regexp.elixir - set: unexpected_quantifier_pop - - match: (\[)(\^?) + - match: (\[)(\^?)(]?) captures: 1: keyword.control.set.regexp.elixir punctuation.definition.set.begin.regexp.elixir 2: keyword.operator.negation.regexp.elixir + 3: meta.literal.regexp.elixir push: - meta_scope: meta.set.regexp.elixir - include: character_range @@ -388,9 +383,9 @@ contexts: - include: literal character_range: - - match: (?=(\\[dsw]|\\x\h\h|\\\d+|\\c\p{ascii}|\\.|.)-\g<1>) + - match: (?=(\\x\h\h?|\\x{\h+}|\\[0-7]{1,3}|\o{[0-7]+}|\\c\p{ascii}|\\.|[^\\])-(?!])\g<1>) push: - - match: (?>(\\[dsw])|(\\x\h\h|\\\d+|\\c\p{ascii}|\\.|.)) + - match: (\\[dsw])|(\\x\h\h?|\\x{\h+}|\\[0-7]{1,3}|\o{[0-7]+}|\\c\p{ascii}|\\.|[^\\]) scope: meta.character-range.regexp.elixir captures: 1: invalid.illegal.range.regexp.elixir @@ -400,7 +395,7 @@ contexts: scope: keyword.operator.range.regexp.elixir set: - meta_scope: meta.character-range.regexp.elixir - - match: (?>(\\[dsw])|(\\x\h\h|\\\d+|\\c\p{ascii}|\\.|.)) + - match: (\\[dsw])|(\\x\h\h?|\\x{\h+}|\\[0-7]{1,3}|\o{[0-7]+}|\\c\p{ascii}|\\.|[^\\]) captures: 1: invalid.illegal.range.regexp.elixir 2: constant.other.range.regexp.elixir @@ -412,6 +407,9 @@ contexts: scope: invalid.illegal.escape-sequence.regexp.elixir - match: \\b scope: constant.character.escape.backspace.regexp.elixir + # Inside a class set \x, \xh and \xhh are valid sequences. + - match: \\x\h?\h? + scope: constant.character.escape.hex.regexp.elixir - include: common_escape_sequence # E.g: [:alpha:] or [:^alpha:] @@ -465,7 +463,13 @@ contexts: scope: keyword.other.any.regexp.elixir comment: - - match: (?:]][]" -#// ^^ invalid.illegal.set.regexp.elixir +~r"[.+*?{1}()[|^$][\N\b\x\xf\xff\A\B\g\G\k\K\R\X\z\Z]" +#// ^^^^^^^^^^^^^^^^^^^^ constant.character.escape.regexp.elixir +#// ^^^^^^^^^ constant.character.escape.hex.regexp.elixir +#// ^^ constant.character.escape.backspace.regexp.elixir +#// ^^ invalid.illegal.escape-sequence.regexp.elixir +#// ^^^^^^^^^^^^^ meta.literal.regexp.elixir +#//^^^^^^^^^^^^^^^ meta.set.regexp.elixir +~r"[[:>:]]" #// ^^^^^ invalid.deprecated.word-boundary.regexp.elixir +~r"[a]][]][^]][^a]" +#// ^ meta.literal.regexp.elixir +#// ^ punctuation.definition.set.end.regexp.elixir +#// ^ meta.literal.regexp.elixir +#// ^ keyword.operator.negation.regexp.elixir +#// ^ punctuation.definition.set.end.regexp.elixir +#// ^ meta.literal.regexp.elixir +#// ^ meta.literal.regexp.elixir +#// ^ meta.literal.regexp.elixir ~r"[ -#// ^ meta.set.regexp.elixir +#// ^ meta.set.regexp.elixir meta.literal.regexp.elixir ]" +~r"[a-b-c] [-a-z-] [\d-\s \w-\\] [\x0-\x1] [\x00-\xff] [\000-\007] [\0-\18]" +#// ^ meta.literal.regexp.elixir +#// ^^^^ constant.other.range.regexp.elixir +#// ^ keyword.operator.range.regexp.elixir +#// ^^^^ constant.other.range.regexp.elixir +#// ^^^^ constant.other.range.regexp.elixir +#// ^^^^ constant.other.range.regexp.elixir +#// ^^^ constant.other.range.regexp.elixir +#// ^^^ constant.other.range.regexp.elixir +#// ^^ constant.other.range.regexp.elixir +#// ^^ invalid.illegal.range.regexp.elixir +#// ^^ invalid.illegal.range.regexp.elixir +#// ^^ invalid.illegal.range.regexp.elixir +#// ^ meta.literal.regexp.elixir +#// ^ keyword.operator.range.regexp.elixir +#// ^ meta.literal.regexp.elixir +#// ^^ meta.literal.regexp.elixir +~r"[-] [--] [---] [\--\-] [[--] [--[] [[-[] [[-] [[-\]] [\[-\]]" +#// ^^ constant.other.range.regexp.elixir +#// ^^ constant.other.range.regexp.elixir +#// ^^ meta.literal.regexp.elixir +#// ^ constant.other.range.regexp.elixir +#// ^ constant.other.range.regexp.elixir +#// ^ constant.other.range.regexp.elixir +#// ^ constant.other.range.regexp.elixir +#// ^ constant.other.range.regexp.elixir +#// ^^ constant.other.range.regexp.elixir +#// ^^ constant.other.range.regexp.elixir +#// ^ keyword.operator.range.regexp.elixir +#// ^ punctuation.definition.set.end.regexp.elixir +#// ^^ meta.literal.regexp.elixir +#// ^ meta.literal.regexp.elixir + # Inline options: ~r"(*NO_START_OPT)(*UTF)(*UTF8)(*UCP)(*CRLF)(*CR)(*LF)(*ANYCRLF)(*ANY)(*BSR_ANYCRLF)(*BSR_UNICODE)(*LIMIT_MATCH=)(*LIMIT_RECURSION=)(*ANY)" #//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ keyword.control.flag.regexp.elixir @@ -206,18 +248,31 @@ # Comments: ~r"(?#comment block)" -#//^^^^^^^^^^ comment.block.group.regexp.elixir +#//^^^^^^^^^^^^^^^^^ comment.block.group.regexp.elixir ~r"# # comment line" #// ^ comment.line.number-sign.regexp.elixir #//^^ meta.literal.regexp.elixir ~r"[ # not a comment inside a set]" #// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.literal.regexp.elixir -~r" # a comment" -#// ^^^^^^^^^^^ comment.line.number-sign.regexp.elixir -#//^ meta.literal.regexp.elixir -~r"\ # escape preceding space to prevent matching as a comment" -#// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.literal.regexp.elixir +~r"\ # \\\ # # a comment" +#// ^^^^^^^^^^^ comment.line.number-sign.regexp.elixir +#// ^^ meta.literal.regexp.elixir +#// ^^^^ constant.character.escape.regexp.elixir +#// ^^ meta.literal.regexp.elixir #//^^ constant.character.escape.regexp.elixir +~r"\ # escape preceding space to prevent matching as a comment +#// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.literal.regexp.elixir +#//^^ constant.character.escape.regexp.elixir +(back to regex...) +#// ^^^ keyword.other.any.regexp.elixir +" +~r"\\ # match as comment with an even number of preceding backslashes +#// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.regexp.elixir +#//^^ constant.character.escape.regexp.elixir +(back to regex...) +#// ^^^ keyword.other.any.regexp.elixir +" + ~r"no preceding space#not a comment" #//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.literal.regexp.elixir ~R[ #{123}] ~r[ #{123}]