Skip to content

Commit

Permalink
Add class scope for MLang fragments. Add other lookup scoping for
Browse files Browse the repository at this point in the history
identifiers defined in MLang fragments (syn, sem, and type).
  • Loading branch information
johnwikman committed Mar 7, 2022
1 parent ac786ab commit 002f2f8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
31 changes: 25 additions & 6 deletions mcore.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ contexts:
top-lang:
- match: '\b(lang)\b'
scope: keyword.directive.lang.mcore
push: [top-lang-entry-pushed, identifier-typedef-pushed]
push: [top-lang-entry-pushed, identifier-classdef-pushed]

top-lang-pushed:
- match: '\b(lang)\b'
scope: keyword.directive.lang.mcore
set: [top-lang-entry-pushed, identifier-typedef-pushed]
set: [top-lang-entry-pushed, identifier-classdef-pushed]

top-lang-entry-pushed:
# Check what comes after 'lang'
Expand All @@ -163,18 +163,18 @@ contexts:
top-lang-syn-entry-pushed:
- match: '\b(syn)\b'
scope: keyword.other.syn.mcore
set: [top-lang-syn-body-pushed, eqoperator-pushed, identifier-pushed]
set: [top-lang-syn-body-pushed, eqoperator-pushed, identifier-typedef-pushed]

top-lang-syn-body-pushed:
- match: '(\|)'
scope: keyword.operator.case.mcore
set: [typeexpr-pushed-breaksynbody, identifier-pushed]
set: [typeexpr-pushed-breaksynbody, identifier-typedef-pushed]
- include: top-lang-end-or-more-pushed

top-lang-sem-entry-pushed:
- match: '\b(sem)\b'
scope: keyword.other.sem.mcore
set: [top-lang-sem-preamble-pushed, identifier-pushed]
set: [top-lang-sem-preamble-pushed, identifier-funcdef-pushed]

top-lang-sem-preamble-pushed:
- match: '(=)'
Expand All @@ -193,7 +193,7 @@ contexts:
top-lang-type-entry-pushed:
- match: '\b(type)\b'
scope: keyword.other.type.mcore
set: [typeexpr-pushed-breaklang-end-or-more, eqoperator-pushed, identifier-pushed]
set: [typeexpr-pushed-breaklang-end-or-more, eqoperator-pushed, identifier-typedef-pushed]

### ###
### Top-Level Let Expressions ###
Expand Down Expand Up @@ -5176,6 +5176,25 @@ contexts:
pop: true
- include: stringsymbol
- meta_include_prototype: false
identifier-classdef-pushed:
- match: '\b(?:({{builtin_ident}})|({{reserved_ident}})|(_)|({{ident}})|({{conident}}))\b'
captures:
1: support.function.builtin.ident.mcore
2: invalid.illegal.reserved.ident.mcore
3: keyword.other.ignored.ident.mcore
4: other.ident.mcore
5: entity.name.class.mcore
pop: true
- match: '(#(?:var|con|type|label|frozen))(")'
captures:
1: keyword.directive.identifier.mcore
2: string.quote.double.mcore
set:
- match: '(")'
scope: string.quote.double.mcore
pop: true
- include: stringsymbol
- meta_include_prototype: false

### ###
### Integer Tokens ###
Expand Down
14 changes: 8 additions & 6 deletions src/mcore/mcore.sublime-syntax-base
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ contexts:
top-lang:
- match: '\b(lang)\b'
scope: keyword.directive.lang.mcore
push: [top-lang-entry-pushed, identifier-typedef-pushed]
push: [top-lang-entry-pushed, identifier-classdef-pushed]

top-lang-pushed:
- match: '\b(lang)\b'
scope: keyword.directive.lang.mcore
set: [top-lang-entry-pushed, identifier-typedef-pushed]
set: [top-lang-entry-pushed, identifier-classdef-pushed]

top-lang-entry-pushed:
# Check what comes after 'lang'
Expand All @@ -163,18 +163,18 @@ contexts:
top-lang-syn-entry-pushed:
- match: '\b(syn)\b'
scope: keyword.other.syn.mcore
set: [top-lang-syn-body-pushed, eqoperator-pushed, identifier-pushed]
set: [top-lang-syn-body-pushed, eqoperator-pushed, identifier-typedef-pushed]

top-lang-syn-body-pushed:
- match: '(\|)'
scope: keyword.operator.case.mcore
set: [typeexpr-pushed-breaksynbody, identifier-pushed]
set: [typeexpr-pushed-breaksynbody, identifier-typedef-pushed]
- include: top-lang-end-or-more-pushed

top-lang-sem-entry-pushed:
- match: '\b(sem)\b'
scope: keyword.other.sem.mcore
set: [top-lang-sem-preamble-pushed, identifier-pushed]
set: [top-lang-sem-preamble-pushed, identifier-funcdef-pushed]

top-lang-sem-preamble-pushed:
- match: '(=)'
Expand All @@ -193,7 +193,7 @@ contexts:
top-lang-type-entry-pushed:
- match: '\b(type)\b'
scope: keyword.other.type.mcore
set: [typeexpr-pushed-breaklang-end-or-more, eqoperator-pushed, identifier-pushed]
set: [typeexpr-pushed-breaklang-end-or-more, eqoperator-pushed, identifier-typedef-pushed]

### ###
### Top-Level Let Expressions ###
Expand Down Expand Up @@ -1027,6 +1027,8 @@ contexts:
#%%IMPORT=m.ident("",IdentCapture="entity.name.function.mcore")
identifier-typedef-pushed:
#%%IMPORT=m.ident("",TyIdentCapture="entity.name.type.mcore")
identifier-classdef-pushed:
#%%IMPORT=m.ident("",TyIdentCapture="entity.name.class.mcore")

### ###
### Integer Tokens ###
Expand Down

0 comments on commit 002f2f8

Please sign in to comment.