commit f8b8c528ca6838674abddf458834b4768eb91279 Author: avitex Date: Tue Dec 18 22:38:12 2018 +1100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ccb2c80 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +package-lock.json \ No newline at end of file diff --git a/build.js b/build.js new file mode 100644 index 0000000..543bdbd --- /dev/null +++ b/build.js @@ -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 + }) +}) \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..87e4057 --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/package/package.json b/package/package.json new file mode 100644 index 0000000..1281998 --- /dev/null +++ b/package/package.json @@ -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" + }] + } +} \ No newline at end of file diff --git a/package/syntaxes/sehn.tmLanguage b/package/syntaxes/sehn.tmLanguage new file mode 100644 index 0000000..80ece20 --- /dev/null +++ b/package/syntaxes/sehn.tmLanguage @@ -0,0 +1,420 @@ + + + + + name + SEHN + uuid + 06947fd2-ab1f-4518-8f45-cc76b0294e5f + scopeName + source.sehn + fileTypes + + sehn + + foldingStartMarker + ^\s*[{\[\`](?!.*[}\]\`],?\s*$)|[{\[\`]\s*$ + foldingStopMarker + ^\s*[}\]\`] + patterns + + + include + #value + + + 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] + + + + \ No newline at end of file diff --git a/sehn.tmLanguage.yaml b/sehn.tmLanguage.yaml new file mode 100644 index 0000000..187d2d3 --- /dev/null +++ b/sehn.tmLanguage.yaml @@ -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]' \ No newline at end of file