Merge pull request #2951 from amaanq/export-schema-fix
fix: don't add extraneous exports to the json and add missing rules to the schema
This commit is contained in:
commit
4f3a3debe8
3 changed files with 17 additions and 8 deletions
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -213,17 +213,13 @@ fn load_js_grammar_file(grammar_path: &Path, js_runtime: Option<&str>) -> Result
|
|||
let stdout =
|
||||
String::from_utf8(output.stdout).with_context(|| "Got invalid UTF8 from node")?;
|
||||
|
||||
let mut node_output = "";
|
||||
let mut grammar_json = &stdout[..];
|
||||
|
||||
if let Some(pos) = stdout.rfind('\n') {
|
||||
// If there's a newline, split the last line from the rest of the output
|
||||
node_output = &stdout[..pos];
|
||||
let node_output = &stdout[..pos];
|
||||
grammar_json = &stdout[pos + 1..];
|
||||
}
|
||||
|
||||
// If we got any output from the node process that isn't the grammar JSON
|
||||
if !node_output.is_empty() {
|
||||
let mut stdout = std::io::stdout().lock();
|
||||
stdout.write_all(node_output.as_bytes())?;
|
||||
stdout.write_all(b"\n")?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue