{"name":"vscode-textmate","version":"1.0.4","description":"VSCode TextMate grammar helpers","main":"./release/main.js","repository":{"type":"git","url":"git+https://github.com/Microsoft/vscode-textmate.git"},"license":"MIT","bugs":{"url":"https://github.com/Microsoft/vscode-textmate/issues"},"scripts":{"watch":"gulp watch","test":"gulp test","benchmark":"node benchmark/benchmark.js"},"dependencies":{"oniguruma":"^5.1.1","sax":"^1.1.1"},"devDependencies":{"colors":"^1.1.2","event-stream":"^3.3.1","gulp":"^3.9.0","gulp-concat":"^2.6.0","gulp-typescript":"^2.8.2"},"gitHead":"189ea33dae51be90f80bfa4cb41fd61ef8e093e5","homepage":"https://github.com/Microsoft/vscode-textmate#readme","_id":"vscode-textmate@1.0.4","_shasum":"399d761610b832b90f7799c2559bfa4050f96a22","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.7","_npmUser":{"name":"alexandrudima","email":"alexdima@microsoft.com"},"dist":{"shasum":"399d761610b832b90f7799c2559bfa4050f96a22","tarball":"http://registry-npm.ywwl.com/vscode-textmate/download/vscode-textmate-1.0.4.tgz","integrity":"sha512-0bHopAi4/dEQDIpBDXxs6D3kgSsmQ+mQszfZCafpvtLYiKgnClKmdblbP4H1kIjK12QCwGcEv69AEqKBOUUZ2Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD/EsLxFhRimTZFitcF/yetgpbmvZDWTtA997KC9UE1/QIhAORs5bA4IldP93SrSdpUX8ywb1i3w1YhdXA0JlwLD3mp"}],"size":13352,"noattachment":false,"key":"/vscode-textmate/-/vscode-textmate-1.0.4.tgz"},"maintainers":[{"name":"alexandrudima","email":"alexdima@microsoft.com"},{"name":"bpasero","email":"benjpas@microsoft.com"}],"directories":{},"readme":"# VSCode TextMate [![Build Status](https://dev.azure.com/ms/vscode-textmate/_apis/build/status/microsoft.vscode-textmate?branchName=master)](https://dev.azure.com/ms/vscode-textmate/_build/latest?definitionId=172&branchName=master)\n\nAn interpreter for grammar files as defined by TextMate. TextMate grammars use the oniguruma dialect (https://github.com/kkos/oniguruma). Supports loading grammar files from JSON or PLIST format. This library is used in VS Code. Cross - grammar injections are currently not supported.\n\n## Installing\n\n```sh\nnpm install vscode-textmate\n```\n\n## Using\n\n```javascript\nconst fs = require('fs');\nconst path = require('path');\nconst vsctm = require('vscode-textmate');\nconst oniguruma = require('vscode-oniguruma');\n\n/**\n * Utility to read a file as a promise\n */\nfunction readFile(path) {\n    return new Promise((resolve, reject) => {\n        fs.readFile(path, (error, data) => error ? reject(error) : resolve(data));\n    })\n}\n\nconst wasmBin = fs.readFileSync(path.join(__dirname, './node_modules/vscode-oniguruma/release/onig.wasm')).buffer;\nconst vscodeOnigurumaLib = oniguruma.loadWASM(wasmBin).then(() => {\n    return {\n        createOnigScanner(patterns) { return new oniguruma.OnigScanner(patterns); },\n        createOnigString(s) { return new oniguruma.OnigString(s); }\n    };\n});\n\n// Create a registry that can create a grammar from a scope name.\nconst registry = new vsctm.Registry({\n    onigLib: vscodeOnigurumaLib,\n    loadGrammar: (scopeName) => {\n        if (scopeName === 'source.js') {\n            // https://github.com/textmate/javascript.tmbundle/blob/master/Syntaxes/JavaScript.plist\n            return readFile('./JavaScript.plist').then(data => vsctm.parseRawGrammar(data.toString()))\n        }\n        console.log(`Unknown scope name: ${scopeName}`);\n        return null;\n    }\n});\n\n// Load the JavaScript grammar and any other grammars included by it async.\nregistry.loadGrammar('source.js').then(grammar => {\n    const text = [\n        `function sayHello(name) {`,\n        `\\treturn \"Hello, \" + name;`,\n        `}`\n    ];\n    let ruleStack = vsctm.INITIAL;\n    for (let i = 0; i < text.length; i++) {\n        const line = text[i];\n        const lineTokens = grammar.tokenizeLine(line, ruleStack);\n        console.log(`\\nTokenizing line: ${line}`);\n        for (let j = 0; j < lineTokens.tokens.length; j++) {\n            const token = lineTokens.tokens[j];\n            console.log(` - token from ${token.startIndex} to ${token.endIndex} ` +\n              `(${line.substring(token.startIndex, token.endIndex)}) ` +\n              `with scopes ${token.scopes.join(', ')}`\n            );\n        }\n        ruleStack = lineTokens.ruleStack;\n    }\n});\n\n/* OUTPUT:\n\nUnknown scope name: source.js.regexp\n\nTokenizing line: function sayHello(name) {\n - token from 0 to 8 (function) with scopes source.js, meta.function.js, storage.type.function.js\n - token from 8 to 9 ( ) with scopes source.js, meta.function.js\n - token from 9 to 17 (sayHello) with scopes source.js, meta.function.js, entity.name.function.js\n - token from 17 to 18 (() with scopes source.js, meta.function.js, punctuation.definition.parameters.begin.js\n - token from 18 to 22 (name) with scopes source.js, meta.function.js, variable.parameter.function.js\n - token from 22 to 23 ()) with scopes source.js, meta.function.js, punctuation.definition.parameters.end.js\n - token from 23 to 24 ( ) with scopes source.js\n - token from 24 to 25 ({) with scopes source.js, punctuation.section.scope.begin.js\n\nTokenizing line:        return \"Hello, \" + name;\n - token from 0 to 1 (  ) with scopes source.js\n - token from 1 to 7 (return) with scopes source.js, keyword.control.js\n - token from 7 to 8 ( ) with scopes source.js\n - token from 8 to 9 (\") with scopes source.js, string.quoted.double.js, punctuation.definition.string.begin.js\n - token from 9 to 16 (Hello, ) with scopes source.js, string.quoted.double.js\n - token from 16 to 17 (\") with scopes source.js, string.quoted.double.js, punctuation.definition.string.end.js\n - token from 17 to 18 ( ) with scopes source.js\n - token from 18 to 19 (+) with scopes source.js, keyword.operator.arithmetic.js\n - token from 19 to 20 ( ) with scopes source.js\n - token from 20 to 24 (name) with scopes source.js, support.constant.dom.js\n - token from 24 to 25 (;) with scopes source.js, punctuation.terminator.statement.js\n\nTokenizing line: }\n - token from 0 to 1 (}) with scopes source.js, punctuation.section.scope.end.js\n\n*/\n\n```\n\n## For grammar authors\n\nSee [vscode-tmgrammar-test](https://github.com/PanAeon/vscode-tmgrammar-test) that can help you write unit tests against your grammar.\n\n## API doc\n\nSee [the main.ts file](./src/main.ts)\n\n## Developing\n\n* Clone the repository\n* Run `npm install`\n* Compile in the background with `npm run watch`\n* Run tests with `npm test`\n* Run benchmark with `npm run benchmark`\n* Troubleshoot a grammar with `npm run inspect -- PATH_TO_GRAMMAR PATH_TO_FILE`\n\n## Code of Conduct\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n\n\n## License\n[MIT](https://github.com/Microsoft/vscode-textmate/blob/master/LICENSE.md)\n\n","publish_time":1446645209338,"_cnpm_publish_time":1446645209338,"dist-tags":{"latest":"9.3.2","next":"4.0.0-next.3"}}