Skip to content

Instantly share code, notes, and snippets.

@alikhil
Created April 24, 2017 16:33
Show Gist options
  • Save alikhil/d739f53c1b93fed75b3cb152ae330f75 to your computer and use it in GitHub Desktop.
Save alikhil/d739f53c1b93fed75b3cb152ae330f75 to your computer and use it in GitHub Desktop.
Language grammar for Slang
{
// версия 1
// операторы, ключевые слова, названия юнитов в определении
// константы, комментарии, базовые типы, библиотечные юниты
patterns = (
{ name = 'string.quoted.double.slang';
begin = '"';
end = '"';
patterns = (
{ name = 'constant.character.escape.untitled';
match = '\\.';
},
{ name = 'constant.character.escape.newLine';
match = '\\n';
},
);
},
{ name = 'keyword.control.slang';
match = '\b(break|continue|then|loop|check|do|else|for|if|end|return|switch|while)\b';
},
{ name = 'keyword.operator';
match = '\b(or|and|xor|in|not|as|is|use|alias|old|new)\b';
},
{ name = 'keyword.other';
match = '\b(extend|init)\b';
},
{ name = 'storage.modifier.slang';
match = '\b(const|override|hidden|external|abstract|concurrent|final|safe|pure)\b';
},
{ name = 'storage.type';
match = '\b(val|var|routine)\b';
},
{ name = 'comment.line.double-slash';
match = '\/\/.*';
},
{ name = 'constant.numeric';
match = '\b([0-9]+\.[0-9][0-9_]*)|[0-9][0-9_]*|0o[0-7][0-7_]|0b[01][01_]*';
},
{ name = 'comment.block';
begin = '\/\*';
end = '\*\/';
},
{ name = 'keyword.operator.character';
match = '(\=|\=\=|\:\=|\/\=|\^|\*|\-|\+|\<|\>|\.\.|\$|\||\/|\~|\&|\?)';
},
{ name = 'constant.language';
match = '\b(true|false)\b';
},
{ name = 'keyword.other.contract';
match = '\b(invariant|ensure|require|variant)\b';
},
{ name = 'support.class';
match = '\b(Integer|Boolean|Real|Character|Bit|Any|Array|String|Numeric)\b';
},
{ name = 'variable.language';
match = '\b(this|super)\b';
},
{ name = 'support.class';
match = '\b(Platform|System|StandardIO|Environment|Math)\b';
},
{ begin = '\b(unit)\s([a-zA-Z][\w_]*)';
end = '\s';
beginCaptures = {
1 = { name = 'storage.type'; };
2 = { name = 'entity.name.type'; };
};
},
{ name = 'storage.type.unit';
match = '\b(unit)';
},
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment