Skip to content

Instantly share code, notes, and snippets.

@wararyo
Last active May 18, 2018 04:01
Show Gist options
  • Save wararyo/a9d589939a1246518e2e8bcfc423cebe to your computer and use it in GitHub Desktop.
Save wararyo/a9d589939a1246518e2e8bcfc423cebe to your computer and use it in GitHub Desktop.
Sublime Syntax for Sunaba
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: Sunaba
file_extensions:
- sunaba
- snb
- sunaba.txt
- snb.txt
scope: source.sunaba
variables:
identifier_continue: '[[:alnum:]_]'
identifier: '\b[[:alpha:]_]{{identifier_continue}}*\b'
contexts:
prototype:
- include: comments
main:
- include: keywords
- include: numbers
- include: operators
- match: '(?<!def ){{identifier}}(?= ?\()(?! ?\(.*\) ?とは)'
scope: meta.qualified-name.sunaba variable.function.sunaba
- match: '^{{identifier}}(?= ?\(.*\) ?とは)'
scope: source.sunaba meta.function.sunaba entity.name.function.sunaba meta.generic-name.sunaba
- match: '^def\b'
scope: source.sunaba meta.function.sunaba storage.type.function.sunaba
- match: '\bとは$'
scope: source.sunaba meta.function.sunaba storage.type.function.sunaba
- match: '(?<=def ){{identifier}}(?= ?\()'
scope: source.sunaba meta.function.sunaba entity.name.function.sunaba meta.generic-name.sunaba
- match: '\b(const|定数)\b'
scope: source.sunaba meta.qualified-name.sunaba support.type.sunaba
- match: '(memory|メモリ)(?=\[.+\])'
scope: source.sunaba meta.function-call.sunaba meta.qualified-name.sunaba variable.function.sunaba
- match: '\b{{identifier}}(?=\[.+\])'
scope: source.sunaba meta.function-call.sunaba meta.qualified-name.sunaba variable.function.sunaba
keywords:
- match: '\b(if|while|なら|なかぎり)\b'
scope: keyword.control.sunaba
- match: '\b(import)\b'
scope: source.sunaba meta.statement.import.sunaba keyword.control.import.sunaba
operators:
- match: ->|→
scope: source.sunaba keyword.operator.assignment.sunaba
- match: <\=|>\=|\=(?!\=)|<|>|\!\=|≧|≦
scope: keyword.operator.comparison.sunaba
- match: \+|\-|\*|/
scope: keyword.operator.arithmetic.sunaba
- match: \=\=
scope: source.sunaba keyword.operator.comparison.sunaba invalid.illegal.name.sunaba
numbers:
- match: '\b(-)?[0-9.]+\b'
scope: constant.numeric.sunaba
comments:
- match: ^/\* =(\s*.*?)\s*= \*/$\n?
scope: comment.block.sunaba
captures:
1: meta.toc-list.banner.block.sunaba
- match: /\*
scope: punctuation.definition.sunabaomment.sunaba
push:
- meta_scope: comment.block.sunaba
- match: \*/
scope: punctuation.definition.sunabaomment.sunaba
pop: true
- match: \*/(?!\*)
scope: invalid.illegal.stray-comment-end.sunaba
- match: '#'
scope: punctuation.definition.comment.subana
push:
# This is an anonymous context push for brevity.
- meta_scope: comment.line.double-slash.subana
- match: $\n?
pop: true
@wararyo
Copy link
Author

wararyo commented May 18, 2018

How to Install

  1. Put it into (Windows)C:\Users\{user}\AppData\Roaming\Sublime Text 3\Packages\User (Mac)~/Library/Application Support/Sublime Text 3/Packages/User
  2. Rename sunaba file into *.sunaba or *.sunaba.txt
  3. Open it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment