Move to YAML to make it easier to define grammar
This commit is contained in:
Родитель
1ad05ee587
Коммит
1b1c4508ba
|
@ -0,0 +1,23 @@
|
|||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as yaml from 'js-yaml';
|
||||
import * as plist from 'plist';
|
||||
|
||||
function writePlistFile(grammar: any, fileName: string) {
|
||||
const text = plist.build(grammar);
|
||||
fs.writeFileSync(fileName, text, "utf8");
|
||||
}
|
||||
|
||||
function readYaml(fileName: string) {
|
||||
const text = fs.readFileSync(fileName, "utf8");
|
||||
return yaml.safeLoad(text);
|
||||
}
|
||||
|
||||
function buildGrammar() {
|
||||
const tsGrammar = readYaml("syntaxes/csharp.tmLanguage.yml");
|
||||
|
||||
// Write csharp.tmLanguage
|
||||
writePlistFile(tsGrammar, "syntaxes/csharp.tmLanguage");
|
||||
}
|
||||
|
||||
buildGrammar();
|
|
@ -27,6 +27,7 @@
|
|||
"compile": "tsc -p ./ && gulp tslint",
|
||||
"watch": "tsc -watch -p ./",
|
||||
"test": "node ./node_modules/vscode/bin/test",
|
||||
"build-syntax": "node ./out/build.js",
|
||||
"test-syntax": "mocha --timeout 15000 --ui bdd ./out/test/syntaxes/*.test.syntax.js",
|
||||
"postinstall": "node ./node_modules/vscode/bin/install"
|
||||
},
|
||||
|
@ -46,6 +47,7 @@
|
|||
"devDependencies": {
|
||||
"@types/chai": "^3.4.34",
|
||||
"@types/fs-extra": "0.0.35",
|
||||
"@types/js-yaml": "^3.5.29",
|
||||
"@types/mkdirp": "^0.3.29",
|
||||
"@types/mocha": "^2.2.32",
|
||||
"@types/node": "^6.0.40",
|
||||
|
@ -56,7 +58,9 @@
|
|||
"gulp": "^3.9.1",
|
||||
"gulp-mocha": "^2.1.3",
|
||||
"gulp-tslint": "^4.3.0",
|
||||
"js-yaml": "^3.7.0",
|
||||
"mocha": "^2.3.3",
|
||||
"plist": "^2.0.1",
|
||||
"tslint": "^3.15.1",
|
||||
"tslint-microsoft-contrib": "^2.0.12",
|
||||
"typescript": "^2.0.3",
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
declare module "plist" {
|
||||
export function build(json: any): string;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "build",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "",
|
||||
"main": "build.js",
|
||||
"scripts": {
|
||||
"postinstall": "npm start",
|
||||
"start": "tsc && node ./build.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/js-yaml": "latest",
|
||||
"@types/node": "latest",
|
||||
"js-yaml": "latest",
|
||||
"plist": "latest",
|
||||
"typescript": "latest"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES5",
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -6,7 +6,7 @@
|
|||
import { ITokenizeLineResult, Registry, StackElement } from 'vscode-textmate';
|
||||
|
||||
const registry = new Registry();
|
||||
const grammar = registry.loadGrammarFromPathSync('syntaxes/csharp-new.json');
|
||||
const grammar = registry.loadGrammarFromPathSync('syntaxes/csharp.tmLanguage');
|
||||
const excludedTypes = ['source.cs', 'meta.interpolation.cs', 'meta.type.parameters.cs']
|
||||
|
||||
export function tokenize(input: string | Input, excludeTypes: boolean = true): Token[] {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"syntaxes",
|
||||
".vscode-test"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
declare module "plist" {
|
||||
export function build(json: any): string;
|
||||
}
|
Загрузка…
Ссылка в новой задаче