Last active
December 21, 2016 15:12
-
-
Save smarr/7ce977fbeffe4a9a3debe1965555bae2 to your computer and use it in GitHub Desktop.
SOMns Syntax Highlighting as TextMate Grammar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { patterns = ( { include = '#module'; } ); | |
| repository = { | |
| accessModifier = { | |
| match = '\b(public|private|protected)\b'; | |
| captures = { 1 = { name = 'keyword.modifier.som'; }; }; | |
| }; | |
| assignmentOperator = { | |
| name = 'keyword.operator.assignment.som'; | |
| match = '(?<!:):='; | |
| }; | |
| binaryMsgPattern = { | |
| patterns = ( | |
| { include = '#binarySelector'; }, | |
| { include = '#slotDecl'; }, | |
| ); | |
| }; | |
| binarySelector = { | |
| name = 'keyword.operator.binary.som'; | |
| match = '[+/\\*~<>=@%|&?!,-]+'; | |
| }; | |
| keywordSegment = { | |
| match = '(\b\w+:)\s*(\w+\b)'; | |
| captures = { | |
| 1 = { name = 'entity.name.function.som'; }; | |
| 2 = { name = 'variable.language.som'; }; | |
| }; | |
| }; | |
| blockExp = { | |
| begin = '\['; | |
| end = '\]'; | |
| beginCaptures = { 0 = { name = 'punctuation.definition.block.begin.som'; }; }; | |
| endCaptures = { 0 = { name = 'punctuation.definition.block.end.som'; }; }; | |
| patterns = ( { include = '#exps'; } ); | |
| }; | |
| classDefBlock = { | |
| name = 'class-definition-block'; | |
| begin = '\((?=[^*])'; | |
| end = '\)'; | |
| beginCaptures = { 0 = { name = 'punctuation.definition.block.begin.som'; }; }; | |
| endCaptures = { 0 = { name = 'punctuation.definition.block.end.som'; }; }; | |
| patterns = ( | |
| { include = '#accessModifier'; }, | |
| { include = '#keywordSegment'; }, | |
| { include = '#multilinecomment'; }, | |
| { include = '#classHeader'; }, | |
| { include = '#classDefBlock'; }, | |
| { include = '#slotDecls'; }, | |
| { include = '#classDecl'; }, | |
| { include = '#string'; }, | |
| { include = '#category'; }, | |
| { include = '#methodDecl'; }, | |
| { include = '#classSideColon'; }, | |
| ); | |
| }; | |
| classHeader = { | |
| name = 'meta.class.som'; | |
| begin = '(?=(?:\w+\s+)?(?:class)\s+\w+\s*)'; | |
| end = '(?=\()'; | |
| patterns = ( | |
| { include = '#accessModifier'; }, | |
| { include = '#keywordSegment'; }, | |
| { name = 'meta.class.identifier.som'; | |
| match = '(class)\s+(\w+)'; | |
| captures = { | |
| 1 = { name = 'storage.modifier.class.som'; }; | |
| 2 = { name = 'entity.name.type.class.som'; }; | |
| }; | |
| }, | |
| { name = 'meta.definition.class.inherited.classes.som'; | |
| begin = '='; | |
| end = '(?=\()'; | |
| beginCaptures = { 0 = { name = 'storage.modifier.extends.som'; }; }; | |
| patterns = ( | |
| { name = 'entity.name.function.som'; | |
| match = '\b(\w+(?::)?)'; | |
| }, | |
| { name = 'storage.modifier.mixin.som'; | |
| match = '<:'; | |
| }, | |
| ); | |
| }, | |
| ); | |
| }; | |
| classSideColon = { | |
| match = '(?<=\))\s*(:)\s*(?=\()'; | |
| captures = { 0 = { name = 'storage.modifier.class-side.som'; }; }; | |
| }; | |
| constants = { | |
| name = 'constant.language.som'; | |
| match = '\b(nil|true|false)\b'; | |
| }; | |
| eventualSendOperator = { | |
| name = 'keyword.operator.asyncsend.som'; | |
| match = '<-:'; | |
| }; | |
| exps = { | |
| name = 'meta.expressions.som'; | |
| patterns = ( | |
| { include = '#parentheticalExp'; }, | |
| { include = '#multilinecomment'; }, | |
| { include = '#blockExp'; }, | |
| { include = '#eventualSendOperator'; }, | |
| { include = '#string'; }, | |
| { include = '#constants'; }, | |
| { include = '#numbers'; }, | |
| { include = '#returnOp'; }, | |
| { include = '#selfSuperOuter'; }, | |
| { include = '#assignmentOperator'; }, | |
| { include = '#symbol'; }, | |
| { include = '#binarySelector'; }, | |
| ); | |
| }; | |
| keyword = { | |
| match = '\b(\w+:)'; | |
| captures = { 1 = { name = 'entity.name.function.som'; }; }; | |
| }; | |
| keywordMsgPattern = { | |
| patterns = ( | |
| { include = '#keyword'; }, | |
| { include = '#slotDecl'; }, | |
| ); | |
| }; | |
| messagePattern = { | |
| patterns = ( | |
| { include = '#unaryMsgPattern'; }, | |
| { include = '#binaryMsgPattern'; }, | |
| { include = '#keywordMsgPattern'; }, | |
| ); | |
| }; | |
| methodDecl = { | |
| name = 'meta.function.declaration.som'; | |
| begin = '(?:(\w+)|([+\/\\*~<>=@%|&?!,-]+)\s+(\w+)|(?:\s*(\w+:)\s*(\w+)))\s*(=)\s*(\()'; | |
| end = '\)'; | |
| beginCaptures = { | |
| 1 = { name = 'entity.name.function.som'; }; | |
| 2 = { name = 'entity.name.function.som'; }; | |
| 3 = { name = 'variable.language.som'; }; | |
| 4 = { name = 'entity.name.function.som'; }; | |
| 5 = { name = 'variable.language.som'; }; | |
| 6 = { name = 'storage.modifier.define-function.som'; }; | |
| 7 = { name = 'punctuation.definition.block.begin.som'; }; | |
| }; | |
| endCaptures = { 0 = { name = 'punctuation.definition.block.end.som'; }; }; | |
| patterns = ( | |
| { include = '#exps'; }, | |
| { include = '#slotDecls'; }, | |
| ); | |
| }; | |
| module = { | |
| patterns = ( | |
| { include = '#classHeader'; }, | |
| { include = '#classDefBlock'; }, | |
| { include = '#multilinecomment'; }, | |
| { include = '#classSideColon'; }, | |
| ); | |
| }; | |
| multilinecomment = { | |
| name = 'comment'; | |
| begin = '\(\*'; | |
| end = '\*\)'; | |
| contentName = 'comment'; | |
| patterns = ( | |
| { name = 'comment'; | |
| include = '#multilinecomment'; | |
| }, | |
| ); | |
| }; | |
| numbers = { | |
| name = 'constant.numeric.som'; | |
| match = '\b(\d+(\.\d+)?)\b'; | |
| }; | |
| parentheticalExp = { | |
| begin = '\((?=[^*])'; | |
| end = '\)'; | |
| beginCaptures = { 0 = { name = 'punctuation.definition.block.begin.som'; }; }; | |
| endCaptures = { 0 = { name = 'punctuation.definition.block.end.som'; }; }; | |
| patterns = ( { include = '#exps'; } ); | |
| }; | |
| returnOp = { | |
| name = 'keyword.control.som'; | |
| match = '\^'; | |
| }; | |
| selfSuperOuter = { | |
| name = 'variable.language.som'; | |
| match = '\b(self|super|outer)\b'; | |
| }; | |
| slotDecl = { | |
| match = '\b(\w+)\b'; | |
| captures = { 1 = { name = 'variable.language.som'; }; }; | |
| }; | |
| slotDecls = { | |
| begin = '\|'; | |
| end = '\|'; | |
| beginCaptures = { 0 = { name = 'punctuation.definition.block.begin.som'; }; }; | |
| endCaptures = { 0 = { name = 'punctuation.definition.block.end.som'; }; }; | |
| patterns = ( | |
| { include = '#slotDef'; }, | |
| { include = '#multilinecomment'; } | |
| ); | |
| }; | |
| slotDef = { | |
| patterns = ( | |
| { include = '#accessModifier';}, | |
| { match = '\b(\w+)\b'; | |
| captures = { | |
| 1 = { name = 'variable.language.som'; }; | |
| }; | |
| }, | |
| { begin = '(=|::=)'; | |
| end = '\.'; | |
| beginCaptures = { 0 = { name = 'storage.modifier.variables.som'; }; }; | |
| endCaptures = { 0 = { name = 'punctuation.terminator.som'; }; }; | |
| patterns = ( { include = '#exps'; } ); | |
| }, | |
| ); | |
| }; | |
| string = { | |
| name = 'string.quoted.single'; | |
| begin = "'"; | |
| end = "'"; | |
| }; | |
| symbol = { | |
| name = 'constant.character.symbol'; | |
| match = '#\w+\b'; | |
| }; | |
| unaryMsgPattern = { patterns = ( { include = '#unarySelector'; } ); }; | |
| unarySelector = { match = '\b(\w+)\b'; }; | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment