Skip to content

Commit

Permalink
Scope magic constants as language variables (like self)
Browse files Browse the repository at this point in the history
  • Loading branch information
faultyserver committed Feb 6, 2018
1 parent a31c8e7 commit c6bc591
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions myst.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions sample.mt
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit c6bc591

Please sign in to comment.