Initial commit

This commit is contained in:
avitex 2018-12-18 22:38:12 +11:00
commit f8b8c528ca
Signed by: avitex
GPG Key ID: 38C76CBF3749D62C
6 changed files with 668 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules/
package-lock.json

16
build.js Normal file
View File

@ -0,0 +1,16 @@
const fs = require('fs')
const path = require('path')
const yaml = require('js-yaml')
const plist = require('plist')
const inPath = path.join(__dirname, 'sehn.tmLanguage.yaml')
const outPath = path.join(__dirname, 'package/syntaxes/sehn.tmLanguage')
fs.readFile(inPath, (err, str) => {
if (err) throw err
const data = yaml.load(str)
fs.writeFile(outPath, plist.build(data), (err) => {
if (err) throw err
})
})

15
package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "sehn-tm-language",
"version": "1.0.0",
"private": true,
"description": "",
"scripts": {
"build": "node build.js"
},
"author": "James Dyson",
"license": "MIT",
"dependencies": {
"js-yaml": "^3.12.0",
"plist": "^3.0.1"
}
}

20
package/package.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "sehn",
"version": "0.0.1",
"engines": {
"vscode": ">=0.9.0"
},
"publisher": "me",
"contributes": {
"languages": [{
"id": "sehn",
"aliases": ["SEHN", "sehn"],
"extensions": [".sehn"]
}],
"grammars": [{
"language": "sehn",
"scopeName": "source.sehn",
"path": "./syntaxes/sehn.tmLanguage"
}]
}
}

View File

@ -0,0 +1,420 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>SEHN</string>
<key>uuid</key>
<string>06947fd2-ab1f-4518-8f45-cc76b0294e5f</string>
<key>scopeName</key>
<string>source.sehn</string>
<key>fileTypes</key>
<array>
<string>sehn</string>
</array>
<key>foldingStartMarker</key>
<string>^\s*[{\[\`](?!.*[}\]\`],?\s*$)|[{\[\`]\s*$</string>
<key>foldingStopMarker</key>
<string>^\s*[}\]\`]</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#value</string>
</dict>
</array>
<key>repository</key>
<dict>
<key>value</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#bool</string>
</dict>
<dict>
<key>include</key>
<string>#real</string>
</dict>
<dict>
<key>include</key>
<string>#text</string>
</dict>
<dict>
<key>include</key>
<string>#text-list</string>
</dict>
<dict>
<key>include</key>
<string>#list</string>
</dict>
<dict>
<key>include</key>
<string>#dict</string>
</dict>
<dict>
<key>include</key>
<string>#tag</string>
</dict>
<dict>
<key>include</key>
<string>#kind</string>
</dict>
<dict>
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#illegal</string>
</dict>
</array>
</dict>
<key>bool</key>
<dict>
<key>name</key>
<string>constant.language.boolean.sehn</string>
<key>match</key>
<string>\b(?:true|false)\b</string>
</dict>
<key>real</key>
<dict>
<key>name</key>
<string>constant.numeric.sehn</string>
<key>match</key>
<string>\-?(?:(?:([0-9]+)(\.)([0-9]+))|(?:([1-9][0-9]*)(e)(-?)([1-9][0-9]+))|(?:([1-9][0-9]+)))</string>
</dict>
<key>text</key>
<dict>
<key>name</key>
<string>string.quoted.double.sehn</string>
<key>begin</key>
<string>"</string>
<key>end</key>
<string>"</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.sehn</string>
</dict>
</dict>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.sehn</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#text-content</string>
</dict>
</array>
</dict>
<key>text-content</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>constant.character.escape.sehn</string>
<key>match</key>
<string>\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4})</string>
</dict>
<dict>
<key>name</key>
<string>invalid.illegal.unrecognized-string-escape.sehn</string>
<key>match</key>
<string>\\.</string>
</dict>
</array>
</dict>
<key>text-list</key>
<dict>
<key>name</key>
<string>meta.structure.stringlist</string>
<key>begin</key>
<string>\`</string>
<key>end</key>
<string>\`</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.stringlist.begin.sehn</string>
</dict>
</dict>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.stringlist.end.sehn</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#text</string>
</dict>
<dict>
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#illegal</string>
</dict>
</array>
</dict>
<key>dict</key>
<dict>
<key>name</key>
<string>meta.structure.dictionary.sehn</string>
<key>begin</key>
<string>\{</string>
<key>end</key>
<string>\}</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.dictionary.begin.sehn</string>
</dict>
</dict>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.dictionary.end.sehn</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#dict-key</string>
</dict>
<dict>
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#dict-val</string>
</dict>
<dict>
<key>name</key>
<string>invalid.illegal.expected-dictionary-separator.sehn</string>
<key>match</key>
<string>[^\s\}]</string>
</dict>
</array>
</dict>
<key>dict-key</key>
<dict>
<key>name</key>
<string>string.sehn support.type.property-name.sehn</string>
<key>begin</key>
<string>"</string>
<key>end</key>
<string>"</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.support.type.property-name.begin.sehn</string>
</dict>
</dict>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.support.type.property-name.end.sehn</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#text-content</string>
</dict>
</array>
</dict>
<key>dict-val</key>
<dict>
<key>name</key>
<string>meta.structure.dictionary.value.sehn</string>
<key>begin</key>
<string>:</string>
<key>end</key>
<string>(,)|(?=\})</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.separator.dictionary.key-value.sehn</string>
</dict>
</dict>
<key>endCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.separator.dictionary.pair.sehn</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#value</string>
</dict>
<dict>
<key>name"</key>
<string>invalid.illegal.expected-dictionary-separator.sehn</string>
<key>match"</key>
<string>[^\\s,]</string>
</dict>
</array>
</dict>
<key>list</key>
<dict>
<key>name</key>
<string>meta.structure.list.sehn</string>
<key>begin</key>
<string>\[</string>
<key>end</key>
<string>\]</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.list.begin.sehn</string>
</dict>
</dict>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.list.end.sehn</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>punctuation.separator.list.sehn</string>
<key>match</key>
<string>,</string>
</dict>
<dict>
<key>include</key>
<string>#value</string>
</dict>
<dict>
<key>name</key>
<string>invalid.illegal.expected-list-separator.sehn</string>
<key>match</key>
<string>[^\s\]]</string>
</dict>
</array>
</dict>
<key>tag</key>
<dict>
<key>name</key>
<string>meta.structure.tag</string>
<key>begin</key>
<string>(?:(\b(?:[a-z](?:[a-zA-Z0-9]*\/?[a-zA-Z0-9]+)+)\b)|(\b(?:[A-Z](?:[a-zA-Z0-9]*\/?[a-zA-Z0-9]+)+)\b))(\()</string>
<key>end</key>
<string>(\))</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>storage.type.tag.standard.sehn</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>storage.type.tag.application.sehn</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>punctuation.definition.tag.begin.sehn</string>
</dict>
</dict>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.tag.end.sehn</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#value</string>
</dict>
</array>
</dict>
<key>kind</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>name</key>
<string>storage.type.base.sehn</string>
<key>match</key>
<string>\b(?:none|bool|real|text|dict|list|kind)\b</string>
</dict>
<dict>
<key>name</key>
<string>storage.type.extension.standard.sehn</string>
<key>match</key>
<string>\b(?:[a-z](?:[a-zA-Z0-9]*\/?[a-zA-Z0-9]+)+)\b</string>
</dict>
<dict>
<key>name</key>
<string>storage.type.extension.application.sehn</string>
<key>match</key>
<string>\b(?:[A-Z](?:[a-zA-Z0-9]*\/?[a-zA-Z0-9]+)+)\b</string>
</dict>
</array>
</dict>
<key>comment</key>
<dict>
<key>name</key>
<string>comment.line.sehn</string>
<key>match</key>
<string>#.*</string>
</dict>
<key>illegal</key>
<dict>
<key>name</key>
<string>invalid.illegal.sehn</string>
<key>match</key>
<string>[^\s]</string>
</dict>
</dict>
</dict>
</plist>

195
sehn.tmLanguage.yaml Normal file
View File

@ -0,0 +1,195 @@
# =====================================
# Meta
name: SEHN
uuid: 06947fd2-ab1f-4518-8f45-cc76b0294e5f
scopeName: source.sehn
fileTypes:
- sehn
# =====================================
# Folding
# Matches the start of a dict, list or textlist as
# long as the end does not follow on the same line, ignoring
# whitespace and one optional comma OR if the start character
# is at the end of the line.
foldingStartMarker: '^\s*[{\[\`](?!.*[}\]\`],?\s*$)|[{\[\`]\s*$'
# Matches the end of a dict, list or textlist as
# long as it is not preceeded by anything other
# than whitespace.
foldingStopMarker: '^\s*[}\]\`]'
# =====================================
# Root patterns
patterns:
- include: '#value'
# =====================================
# Common patterns
repository:
value:
patterns:
- include: '#bool'
- include: '#real'
- include: '#text'
- include: '#text-list'
- include: '#list'
- include: '#dict'
- include: '#tag'
- include: '#kind'
- include: '#comment'
- include: '#illegal'
# =====================================
bool:
name: constant.language.boolean.sehn
match: '\b(?:true|false)\b'
# =====================================
real:
name: constant.numeric.sehn
match: '\-?(?:(?:([0-9]+)(\.)([0-9]+))|(?:([1-9][0-9]*)(e)(-?)([1-9][0-9]+))|(?:([1-9][0-9]+)))'
# =====================================
text:
name: string.quoted.double.sehn
begin: '"'
end: '"'
beginCaptures:
0:
name: punctuation.definition.string.begin.sehn
endCaptures:
0:
name: punctuation.definition.string.end.sehn
patterns:
- include: '#text-content'
text-content:
patterns:
- name: constant.character.escape.sehn
match: '\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4})'
- name: invalid.illegal.unrecognized-string-escape.sehn
match: '\\.'
text-list:
name: meta.structure.stringlist
begin: '\`'
end: '\`'
beginCaptures:
0:
name: punctuation.definition.stringlist.begin.sehn
endCaptures:
0:
name: punctuation.definition.stringlist.end.sehn
patterns:
- include: '#text'
- include: '#comment'
- include: '#illegal'
# =====================================
dict:
name: meta.structure.dictionary.sehn
begin: '\{'
end: '\}'
beginCaptures:
0:
name: punctuation.definition.dictionary.begin.sehn
endCaptures:
0:
name: punctuation.definition.dictionary.end.sehn
patterns:
- include: '#dict-key'
- include: '#comment'
- include: '#dict-val'
- name: invalid.illegal.expected-dictionary-separator.sehn
match: '[^\s\}]'
dict-key:
name: string.sehn support.type.property-name.sehn
begin: '"'
end: '"'
beginCaptures:
0:
name: punctuation.support.type.property-name.begin.sehn
endCaptures:
0:
name: punctuation.support.type.property-name.end.sehn
patterns:
- include: '#text-content'
dict-val:
name: meta.structure.dictionary.value.sehn
begin: ':'
end: '(,)|(?=\})'
beginCaptures:
0:
name: punctuation.separator.dictionary.key-value.sehn
endCaptures:
1:
name: punctuation.separator.dictionary.pair.sehn
patterns:
- include: '#value'
- name": invalid.illegal.expected-dictionary-separator.sehn
match": '[^\\s,]'
# =====================================
list:
name: meta.structure.list.sehn
begin: '\['
end: '\]'
beginCaptures:
0:
name: punctuation.definition.list.begin.sehn
endCaptures:
0:
name: punctuation.definition.list.end.sehn
patterns:
- name: punctuation.separator.list.sehn
match: ','
- include: '#value'
- name: invalid.illegal.expected-list-separator.sehn
match: '[^\s\]]'
# =====================================
tag:
name: meta.structure.tag
begin: '(?:(\b(?:[a-z](?:[a-zA-Z0-9]*\/?[a-zA-Z0-9]+)+)\b)|(\b(?:[A-Z](?:[a-zA-Z0-9]*\/?[a-zA-Z0-9]+)+)\b))(\()'
end: '(\))'
beginCaptures:
1:
name: storage.type.tag.standard.sehn
2:
name: storage.type.tag.application.sehn
3:
name: punctuation.definition.tag.begin.sehn
endCaptures:
0:
name: punctuation.definition.tag.end.sehn
patterns:
- include: '#value'
# =====================================
kind:
patterns:
- name: storage.type.base.sehn
match: '\b(?:none|bool|real|text|dict|list|kind)\b'
- name: storage.type.extension.standard.sehn
match: '\b(?:[a-z](?:[a-zA-Z0-9]*\/?[a-zA-Z0-9]+)+)\b'
- name: storage.type.extension.application.sehn
match: '\b(?:[A-Z](?:[a-zA-Z0-9]*\/?[a-zA-Z0-9]+)+)\b'
# =====================================
comment:
name: comment.line.sehn
match: '#.*'
illegal:
name: invalid.illegal.sehn
match: '[^\s]'