From c6bc5912a4762cbcd2f779d69fa1256d3e8f5ad3 Mon Sep 17 00:00:00 2001 From: Jon Egeland Date: Tue, 6 Feb 2018 14:55:46 -0500 Subject: [PATCH] Scope magic constants as language variables (like `self`) --- myst.sublime-syntax | 5 +++-- sample.mt | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/myst.sublime-syntax b/myst.sublime-syntax index 1ed649d..7b649d7 100644 --- a/myst.sublime-syntax +++ b/myst.sublime-syntax @@ -10,6 +10,7 @@ scope: source.myst variables: def_op: '\!|\+|\-|\*|\/|\%|\[\]=?|==|!=' identifier: '([a-zA-Z][a-zA-Z0-9]*|_[a-zA-Z0-9]*)' + magic_constants: '__LINE__|__FILE__|__DIR__' contexts: main: - include: comments @@ -56,6 +57,8 @@ contexts: - match: '\{' scope: meta.brackets punctuation.section.brackets.begin.myst push: map_literal + - match: self|{{magic_constants}} + scope: variable.language.myst - match: '\b[0-9][_0-9]*\.[0-9][_0-9]*\b' scope: constant.numeric.float.myst - match: '\b[0-9][_0-9]*\b' @@ -67,8 +70,6 @@ contexts: - match: \" scope: punctuation.definition.string.begin.myst push: string - - match: self - scope: variable.language.myst - match: '(@)([_a-z][_a-zA-Z0-9]*)' captures: 1: punctuation.definition.variable.myst diff --git a/sample.mt b/sample.mt index 2e15142..b3850d0 100644 --- a/sample.mt +++ b/sample.mt @@ -62,6 +62,10 @@ deftype Person def [](index); end def []=(index, other); end + __LINE__ + __FILE__ + __DIR__ + def matched(%Thing{name}, [a,b] =: foo, <(a + b)>) foo.map{ |_a, &block| a * 2.34 }