Skip to content

Commit

Permalink
Add a script for converting to textmate format
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed May 18, 2019
1 parent 8bd6d68 commit ffb0cc6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
31 changes: 31 additions & 0 deletions convert-to-textmate.js
@@ -0,0 +1,31 @@
let nlist = require("nextstep-plist")
let filepath = process.argv[2]
let path = require("path")

if (!filepath || !filepath.endsWith(".json")) {
console.log("please provide a path to a json file mate")
process.exit(1)
}

let syntax = require(path.resolve(__dirname, filepath))

let flurp = r =>
r.replace(/# .*/g, '').replace(/\s/g, '')

let grith = patterns => {
for (let pattern of patterns) {
for (let key in pattern) {
if (key == "begin" || key == "match") {
pattern[key] = flurp(pattern[key])
}
}
}
}

grith(syntax.patterns)

for (let repo in syntax.repository) {
grith(syntax.repository[repo].patterns)
}

console.log(nlist.stringify(syntax))
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -79,5 +79,8 @@
},
"scripts": {
"update": "node ./build/update-grammar.js perl6/atom-language-perl6 grammars/perl6fe.cson ./syntaxes/perl6fe.json && node ./build/update-grammar.js perl6/atom-language-perl6 grammars/perl6fe.quoting.cson ./syntaxes/perl6fe.quoting.json && node ./build/update-grammar.js perl6/atom-language-perl6 grammars/perl6fe.regexp.cson ./syntaxes/perl6fe.regexp.json && node ./build/update-grammar.js perl6/atom-language-perl6 grammars/meta-info.cson ./syntaxes/meta-info.json"
},
"dependencies": {
"nextstep-plist": "^0.4.1"
}
}

0 comments on commit ffb0cc6

Please sign in to comment.