fix: don't add extraneous exports to the json and add missing rules to the schema

This commit is contained in:
Amaan Qureshi 2024-02-07 07:10:51 -05:00
parent f349be529a
commit 993ee75d8c
No known key found for this signature in database
GPG key ID: E67890ADC4227273
2 changed files with 16 additions and 3 deletions

View file

@ -385,7 +385,7 @@ function grammar(baseGrammar, options) {
throw new Error("Grammar must have at least one rule.");
}
return { name, word, rules, extras, conflicts, precedences, externals, inline, supertypes };
return { grammar: { name, word, rules, extras, conflicts, precedences, externals, inline, supertypes } };
}
function checkArguments(ruleCount, caller, callerName, suffix = '') {
@ -419,4 +419,4 @@ global.grammar = grammar;
global.field = field;
const result = require(process.env.TREE_SITTER_GRAMMAR_PATH);
process.stdout.write(JSON.stringify(result, null, null));
process.stdout.write(JSON.stringify(result.grammar, null, null));

View file

@ -31,6 +31,16 @@
}
},
"precedences": {
"type": "array",
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/rule"
}
}
},
"externals": {
"type": "array",
"items": {
@ -240,7 +250,10 @@
"pattern": "^(PREC|PREC_LEFT|PREC_RIGHT|PREC_DYNAMIC)$"
},
"value": {
"type": "integer"
"oneof": [
{ "type": "integer" },
{ "type": "string" }
]
},
"content": {
"$ref": "#/definitions/rule"