-
Notifications
You must be signed in to change notification settings - Fork 537
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All the grammar files are maintained in yaml format.
- Loading branch information
Showing
22 changed files
with
645 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const yaml = require('js-yaml') | ||
|
||
const syntaxDir = path.join(__dirname, '..', 'syntax') | ||
|
||
/** | ||
* Convert an input yaml file to a json output file | ||
* @param {string} inputfile a yaml file name | ||
* @param {string} outputfile a json file name | ||
*/ | ||
function convertYamlToJson(inputfile, outputfile) { | ||
try { | ||
const grammar = yaml.load(fs.readFileSync(inputfile, {encoding: 'utf-8'})) | ||
fs.writeFileSync(outputfile, JSON.stringify(grammar, undefined, 4)) | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
} | ||
|
||
async function main() { | ||
const grammarSrcFiles = [ | ||
'src/BibTeX-style.tmLanguage.yaml', | ||
'src/DocTeX.tmLanguage.yaml', | ||
'src/JLweave.tmLanguage.yaml', | ||
'src/LaTeX-Expl3.tmLanguage.yaml', | ||
'src/Pweave.tmLanguage.yaml', | ||
'src/RSweave.tmLanguage.yaml' | ||
] | ||
for (const file of grammarSrcFiles) { | ||
const baseFile = path.basename(file, '.yaml') | ||
console.log(`Generating ${baseFile} from src/`) | ||
convertYamlToJson(path.join(syntaxDir, file), path.join(syntaxDir, baseFile + '.json')) | ||
} | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,116 @@ | ||
{ | ||
"name": "BibTeX Style", | ||
"scopeName": "source.bst", | ||
"patterns": [ | ||
{ | ||
"include": "#comments" | ||
}, | ||
{ | ||
"include": "#function-declaration" | ||
}, | ||
{ | ||
"include": "#command-keywords" | ||
}, | ||
{ | ||
"include": "#operators" | ||
}, | ||
{ | ||
"include": "#builtin-objects" | ||
}, | ||
{ | ||
"include": "#string" | ||
}, | ||
{ | ||
"include": "#number" | ||
} | ||
], | ||
"repository": { | ||
"function-declaration": { | ||
"name": "meta.function.bst", | ||
"begin": "\\b(FUNCTION)\\s*\\{\\s*([[:alpha:]_.\\$]*\\$?)", | ||
"end": "\\}", | ||
"beginCaptures": { | ||
"1": { | ||
"name": "storage.type.function.bst" | ||
}, | ||
"2": { | ||
"name": "entity.name.function.bst" | ||
} | ||
} | ||
}, | ||
"command-keywords": { | ||
"patterns": [ | ||
"name": "BibTeX Style", | ||
"patterns": [ | ||
{ | ||
"name": "storage.type.int.bst", | ||
"match": "\\b(?<!\\.)INTEGERS\\b(?!\\.)" | ||
"include": "#comments" | ||
}, | ||
{ | ||
"name": "storage.type.var.bst", | ||
"match": "\\b(?<!\\.)(ENTRY|MACRO|STRINGS)\\b(?!\\.)" | ||
"include": "#function-declaration" | ||
}, | ||
{ | ||
"name": "support.function.bst", | ||
"match": "\\b(?<!\\.)(READ|EXECUTE|ITERATE|REVERSE|SORT)\\b(?!\\.)" | ||
} | ||
] | ||
}, | ||
"operators": { | ||
"patterns": [ | ||
{ | ||
"name": "keyword.operator.relational.bst", | ||
"match": "<|>" | ||
"include": "#command-keywords" | ||
}, | ||
{ | ||
"name": "keyword.operator.comparison.bst", | ||
"match": "\\=" | ||
"include": "#operators" | ||
}, | ||
{ | ||
"name": "keyword.operator.arithmetic.bst", | ||
"match": "\\+|-|\\*" | ||
"include": "#builtin-objects" | ||
}, | ||
{ | ||
"name": "keyword.operator.assignment.bst", | ||
"match": ":\\=" | ||
"include": "#string" | ||
}, | ||
{ | ||
"name": "keyword.operator.logic.bst", | ||
"match": "\\b(?<!\\.)(and|or|not)(?!(\\w|\\.))" | ||
"include": "#number" | ||
} | ||
] | ||
}, | ||
"builtin-objects": { | ||
"patterns": [ | ||
{ | ||
"name": "keyword.control.bst", | ||
"match": "\\b(?<!\\.)(if\\$|while\\$)(?!(\\w|\\.))" | ||
], | ||
"repository": { | ||
"builtin-objects": { | ||
"patterns": [ | ||
{ | ||
"match": "\\b(?<!\\.)(if\\$|while\\$)(?!(\\w|\\.))", | ||
"name": "keyword.control.bst" | ||
}, | ||
{ | ||
"match": "\\b(?<!\\.)(add\\.period\\$|call\\.type\\$|change\\.case\\$|chr\\.to\\.int\\$|cite\\$|duplicate\\$|empty\\$|format\\.name\\$|int\\.to\\.chr\\$|int\\.to\\.chr\\$|int\\.to\\.str\\$|missing\\$|newline\\$|num\\.names\\$|pop\\$|preamble\\$|purify\\$|quote\\$|skip\\$|stack\\$|substring\\$|swap\\$|text\\.length\\$|text\\.prefix\\$|top\\$|type\\$|warning\\$|width\\$|write\\$)(?!(\\w|\\.))", | ||
"name": "support.function.bst" | ||
}, | ||
{ | ||
"match": "\\b(?<!\\.)(entry\\.max\\$|global\\.max\\$)(?!(\\w|\\.))", | ||
"name": "support.constant.bst" | ||
}, | ||
{ | ||
"match": "\\b(?<!\\.)sort\\.key\\$(?!(\\w|\\.))", | ||
"name": "support.variable.bst" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "support.function.bst", | ||
"match": "\\b(?<!\\.)(add\\.period\\$|call\\.type\\$|change\\.case\\$|chr\\.to\\.int\\$|cite\\$|duplicate\\$|empty\\$|format\\.name\\$|int\\.to\\.chr\\$|int\\.to\\.chr\\$|int\\.to\\.str\\$|missing\\$|newline\\$|num\\.names\\$|pop\\$|preamble\\$|purify\\$|quote\\$|skip\\$|stack\\$|substring\\$|swap\\$|text\\.length\\$|text\\.prefix\\$|top\\$|type\\$|warning\\$|width\\$|write\\$)(?!(\\w|\\.))" | ||
"command-keywords": { | ||
"patterns": [ | ||
{ | ||
"match": "\\b(?<!\\.)INTEGERS\\b(?!\\.)", | ||
"name": "storage.type.int.bst" | ||
}, | ||
{ | ||
"match": "\\b(?<!\\.)(ENTRY|MACRO|STRINGS)\\b(?!\\.)", | ||
"name": "storage.type.var.bst" | ||
}, | ||
{ | ||
"match": "\\b(?<!\\.)(READ|EXECUTE|ITERATE|REVERSE|SORT)\\b(?!\\.)", | ||
"name": "support.function.bst" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "support.constant.bst", | ||
"match": "\\b(?<!\\.)(entry\\.max\\$|global\\.max\\$)(?!(\\w|\\.))" | ||
"comments": { | ||
"begin": "%", | ||
"end": "$", | ||
"name": "comment.line.percentage.bst" | ||
}, | ||
{ | ||
"name": "support.variable.bst", | ||
"match": "\\b(?<!\\.)sort\\.key\\$(?!(\\w|\\.))" | ||
"function-declaration": { | ||
"begin": "\\b(FUNCTION)\\s*\\{\\s*([[:alpha:]_.\\$]*\\$?)", | ||
"beginCaptures": { | ||
"1": { | ||
"name": "storage.type.function.bst" | ||
}, | ||
"2": { | ||
"name": "entity.name.function.bst" | ||
} | ||
}, | ||
"end": "\\}", | ||
"name": "meta.function.bst" | ||
}, | ||
"number": { | ||
"match": "#-?\\d+\\b", | ||
"name": "constant.numeric.bst" | ||
}, | ||
"operators": { | ||
"patterns": [ | ||
{ | ||
"match": "<|>", | ||
"name": "keyword.operator.relational.bst" | ||
}, | ||
{ | ||
"match": "\\=", | ||
"name": "keyword.operator.comparison.bst" | ||
}, | ||
{ | ||
"match": "\\+|-|\\*", | ||
"name": "keyword.operator.arithmetic.bst" | ||
}, | ||
{ | ||
"match": ":\\=", | ||
"name": "keyword.operator.assignment.bst" | ||
}, | ||
{ | ||
"match": "\\b(?<!\\.)(and|or|not)(?!(\\w|\\.))", | ||
"name": "keyword.operator.logic.bst" | ||
} | ||
] | ||
}, | ||
"string": { | ||
"begin": "\"", | ||
"end": "\"", | ||
"name": "string.quoted.double.bst" | ||
} | ||
] | ||
}, | ||
"string": { | ||
"name": "string.quoted.double.bst", | ||
"begin": "\"", | ||
"end": "\"" | ||
}, | ||
"number": { | ||
"name": "constant.numeric.bst", | ||
"match": "#-?\\d+\\b" | ||
}, | ||
"comments": { | ||
"name": "comment.line.percentage.bst", | ||
"begin": "%", | ||
"end": "$" | ||
} | ||
} | ||
} | ||
"scopeName": "source.bst" | ||
} |
Oops, something went wrong.