fix: fix missing rule issues

上级 3f1b9086
......@@ -189,7 +189,7 @@ impl IRuleRegistry for Grammar {
if let Some(rule) = self.rule_id2desc.get(&pattern_id) {
return rule.clone();
}
// println!("None: rule, {:?}, rule_id2: {:?}", pattern_id, self.rule_id2desc.clone());
// println!("None: rule: {:?}, rule_id2: {:?}", pattern_id, self.rule_id2desc.clone());
Box::from(NoneRule {})
}
......@@ -208,7 +208,6 @@ mod tests {
use crate::grammar::grammar::Grammar;
use crate::inter::IRawGrammar;
use crate::rule::AbstractRule;
#[test]
fn should_build_json_code() {
......@@ -261,7 +260,7 @@ GitHub 漫游指南
fn should_build_makefile_grammar() {
let code = "{}";
let grammar = to_grammar("test-cases/first-mate/fixtures/makefile.json", code);
// assert_eq!(grammar.rule_id2desc.len(), 104);
// assert_eq!(grammar.rule_id2desc.len(), 82);
assert_eq!(grammar.rule_id2desc.len(), 64);
debug_output(&grammar, String::from("program.json"));
}
......
......@@ -146,7 +146,6 @@ impl RuleFactory {
}
let mut has_missing_patterns = false;
match origin_patterns.clone() {
None => {
if 0 != r.len() {
......@@ -162,7 +161,7 @@ impl RuleFactory {
let result = ICompilePatternsResult {
patterns: r,
has_missing_patterns: false,
has_missing_patterns,
};
result
......
[
null,
{
"id": 1,
"_name": "source.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"patterns": [
2
],
"hasMissingPatterns": false,
"_cachedCompiledPatterns": {
"_items": [
{
"hasAnchor": false,
"source": "\\b(?:true|false|null)\\b",
"_anchorCache": null,
"ruleId": 3,
"hasBackReferences": false
},
{
"hasAnchor": false,
"source": "(?x: # turn on extended mode\n\t\t\t -? # an optional minus\n\t\t\t (?:\n\t\t\t 0 # a zero\n\t\t\t | # ...or...\n\t\t\t [1-9] # a 1-9 character\n\t\t\t \\d* # followed by zero or more digits\n\t\t\t )\n\t\t\t (?:\n\t\t\t (?:\n\t\t\t \\. # a period\n\t\t\t \\d+ # followed by one or more digits\n\t\t\t )?\n\t\t\t (?:\n\t\t\t [eE] # an e character\n\t\t\t [+-]? # followed by an option +/-\n\t\t\t \\d+ # followed by one or more digits\n\t\t\t )? # make exponent optional\n\t\t\t )? # make decimal portion optional\n\t\t\t )",
"_anchorCache": null,
"ruleId": 4,
"hasBackReferences": false
},
{
"hasAnchor": false,
"source": "\"",
"_anchorCache": null,
"ruleId": 5,
"hasBackReferences": false
},
{
"hasAnchor": false,
"source": "\\[",
"_anchorCache": null,
"ruleId": 10,
"hasBackReferences": false
},
{
"hasAnchor": false,
"source": "\\{",
"_anchorCache": null,
"ruleId": 15,
"hasBackReferences": false
}
],
"_hasAnchors": false,
"_cached": {
"debugRegExps": [
"\\b(?:true|false|null)\\b",
"(?x: # turn on extended mode\n\t\t\t -? # an optional minus\n\t\t\t (?:\n\t\t\t 0 # a zero\n\t\t\t | # ...or...\n\t\t\t [1-9] # a 1-9 character\n\t\t\t \\d* # followed by zero or more digits\n\t\t\t )\n\t\t\t (?:\n\t\t\t (?:\n\t\t\t \\. # a period\n\t\t\t \\d+ # followed by one or more digits\n\t\t\t )?\n\t\t\t (?:\n\t\t\t [eE] # an e character\n\t\t\t [+-]? # followed by an option +/-\n\t\t\t \\d+ # followed by one or more digits\n\t\t\t )? # make exponent optional\n\t\t\t )? # make decimal portion optional\n\t\t\t )",
"\"",
"\\[",
"\\{"
],
"rules": [
3,
4,
5,
10,
15
],
"scanner": {}
},
"_anchorCache": {
"A0_G0": null,
"A0_G1": null,
"A1_G0": null,
"A1_G1": null
}
},
"_type": "IncludeOnlyRule"
},
{
"id": 2,
"_name": null,
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"patterns": [
3,
4,
5,
10,
15
],
"hasMissingPatterns": false,
"_cachedCompiledPatterns": null,
"_type": "IncludeOnlyRule"
},
{
"id": 3,
"_name": "constant.language.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"_match": {
"hasAnchor": false,
"source": "\\b(?:true|false|null)\\b",
"_anchorCache": null,
"ruleId": 3,
"hasBackReferences": false
},
"captures": [],
"_cachedCompiledPatterns": null,
"_type": "MatchRule"
},
{
"id": 4,
"_name": "constant.numeric.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"_match": {
"hasAnchor": false,
"source": "(?x: # turn on extended mode\n\t\t\t -? # an optional minus\n\t\t\t (?:\n\t\t\t 0 # a zero\n\t\t\t | # ...or...\n\t\t\t [1-9] # a 1-9 character\n\t\t\t \\d* # followed by zero or more digits\n\t\t\t )\n\t\t\t (?:\n\t\t\t (?:\n\t\t\t \\. # a period\n\t\t\t \\d+ # followed by one or more digits\n\t\t\t )?\n\t\t\t (?:\n\t\t\t [eE] # an e character\n\t\t\t [+-]? # followed by an option +/-\n\t\t\t \\d+ # followed by one or more digits\n\t\t\t )? # make exponent optional\n\t\t\t )? # make decimal portion optional\n\t\t\t )",
"_anchorCache": null,
"ruleId": 4,
"hasBackReferences": false
},
"captures": [],
"_cachedCompiledPatterns": null,
"_type": "MatchRule"
},
{
"id": 5,
"_name": "string.quoted.double.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"_begin": {
"hasAnchor": false,
"source": "\"",
"_anchorCache": null,
"ruleId": 5,
"hasBackReferences": false
},
"beginCaptures": [
{
"id": 6,
"_name": "punctuation.definition.string.begin.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
}
],
"_end": {
"hasAnchor": false,
"source": "\"",
"_anchorCache": null,
"ruleId": -1,
"hasBackReferences": false
},
"endHasBackReferences": false,
"endCaptures": [
{
"id": 7,
"_name": "punctuation.definition.string.end.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
}
],
"applyEndPatternLast": false,
"patterns": [
8,
9
],
"hasMissingPatterns": false,
"_cachedCompiledPatterns": null,
"_type": "BeginEndRule"
},
{
"id": 6,
"_name": "punctuation.definition.string.begin.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
},
{
"id": 7,
"_name": "punctuation.definition.string.end.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
},
{
"id": 8,
"_name": "constant.character.escape.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"_match": {
"hasAnchor": false,
"source": "(?x: # turn on extended mode\n \\\\ # a literal backslash\n (?: # ...followed by...\n [\"\\\\/bfnrt] # one of these characters\n | # ...or...\n u # a u\n [0-9a-fA-F]{4} # and four hex digits\n )\n )",
"_anchorCache": null,
"ruleId": 8,
"hasBackReferences": false
},
"captures": [],
"_cachedCompiledPatterns": null,
"_type": "MatchRule"
},
{
"id": 9,
"_name": "invalid.illegal.unrecognized-string-escape.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"_match": {
"hasAnchor": false,
"source": "\\\\.",
"_anchorCache": null,
"ruleId": 9,
"hasBackReferences": false
},
"captures": [],
"_cachedCompiledPatterns": null,
"_type": "MatchRule"
},
{
"id": 10,
"_name": "meta.structure.array.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"_begin": {
"hasAnchor": false,
"source": "\\[",
"_anchorCache": null,
"ruleId": 10,
"hasBackReferences": false
},
"beginCaptures": [
{
"id": 11,
"_name": "punctuation.definition.array.begin.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
}
],
"_end": {
"hasAnchor": false,
"source": "\\]",
"_anchorCache": null,
"ruleId": -1,
"hasBackReferences": false
},
"endHasBackReferences": false,
"endCaptures": [
{
"id": 12,
"_name": "punctuation.definition.array.end.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
}
],
"applyEndPatternLast": false,
"patterns": [
2,
13,
14
],
"hasMissingPatterns": false,
"_cachedCompiledPatterns": null,
"_type": "BeginEndRule"
},
{
"id": 11,
"_name": "punctuation.definition.array.begin.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
},
{
"id": 12,
"_name": "punctuation.definition.array.end.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
},
{
"id": 13,
"_name": "punctuation.separator.array.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"_match": {
"hasAnchor": false,
"source": ",",
"_anchorCache": null,
"ruleId": 13,
"hasBackReferences": false
},
"captures": [],
"_cachedCompiledPatterns": null,
"_type": "MatchRule"
},
{
"id": 14,
"_name": "invalid.illegal.expected-array-separator.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"_match": {
"hasAnchor": false,
"source": "[^\\s\\]]",
"_anchorCache": null,
"ruleId": 14,
"hasBackReferences": false
},
"captures": [],
"_cachedCompiledPatterns": null,
"_type": "MatchRule"
},
{
"id": 15,
"_name": "meta.structure.dictionary.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"_begin": {
"hasAnchor": false,
"source": "\\{",
"_anchorCache": null,
"ruleId": 15,
"hasBackReferences": false
},
"beginCaptures": [
{
"id": 16,
"_name": "punctuation.definition.dictionary.begin.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
}
],
"_end": {
"hasAnchor": false,
"source": "\\}",
"_anchorCache": null,
"ruleId": -1,
"hasBackReferences": false
},
"endHasBackReferences": false,
"endCaptures": [
{
"id": 17,
"_name": "punctuation.definition.dictionary.end.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
}
],
"applyEndPatternLast": false,
"patterns": [
5,
18,
22
],
"hasMissingPatterns": false,
"_cachedCompiledPatterns": {
"_items": [
{
"hasAnchor": false,
"source": "\\}",
"_anchorCache": null,
"ruleId": -1,
"hasBackReferences": false
},
{
"hasAnchor": false,
"source": "\"",
"_anchorCache": null,
"ruleId": 5,
"hasBackReferences": false
},
{
"hasAnchor": false,
"source": ":",
"_anchorCache": null,
"ruleId": 18,
"hasBackReferences": false
},
{
"hasAnchor": false,
"source": "[^\\s\\}]",
"_anchorCache": null,
"ruleId": 22,
"hasBackReferences": false
}
],
"_hasAnchors": false,
"_cached": {
"debugRegExps": [
"\\}",
"\"",
":",
"[^\\s\\}]"
],
"rules": [
-1,
5,
18,
22
],
"scanner": {}
},
"_anchorCache": {
"A0_G0": null,
"A0_G1": null,
"A1_G0": null,
"A1_G1": null
}
},
"_type": "BeginEndRule"
},
{
"id": 16,
"_name": "punctuation.definition.dictionary.begin.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
},
{
"id": 17,
"_name": "punctuation.definition.dictionary.end.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
},
{
"id": 18,
"_name": "meta.structure.dictionary.value.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"_begin": {
"hasAnchor": false,
"source": ":",
"_anchorCache": null,
"ruleId": 18,
"hasBackReferences": false
},
"beginCaptures": [
{
"id": 19,
"_name": "punctuation.separator.dictionary.key-value.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
}
],
"_end": {
"hasAnchor": false,
"source": "(,)|(?=\\})",
"_anchorCache": null,
"ruleId": -1,
"hasBackReferences": false
},
"endHasBackReferences": false,
"endCaptures": [
null,
{
"id": 20,
"_name": "punctuation.separator.dictionary.pair.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
}
],
"applyEndPatternLast": false,
"patterns": [
2,
21
],
"hasMissingPatterns": false,
"_cachedCompiledPatterns": null,
"_type": "BeginEndRule"
},
{
"id": 19,
"_name": "punctuation.separator.dictionary.key-value.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
},
{
"id": 20,
"_name": "punctuation.separator.dictionary.pair.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
},
{
"id": 21,
"_name": "invalid.illegal.expected-dictionary-separator.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"_match": {
"hasAnchor": false,
"source": "[^\\s,]",
"_anchorCache": null,
"ruleId": 21,
"hasBackReferences": false
},
"captures": [],
"_cachedCompiledPatterns": null,
"_type": "MatchRule"
},
{
"id": 22,
"_name": "invalid.illegal.expected-dictionary-separator.json",
"_nameIsCapturing": false,
"_contentName": null,
"_contentNameIsCapturing": false,
"_match": {
"hasAnchor": false,
"source": "[^\\s\\}]",
"_anchorCache": null,
"ruleId": 22,
"hasBackReferences": false
},
"captures": [],
"_cachedCompiledPatterns": null,
"_type": "MatchRule"
}
]
\ No newline at end of file
......@@ -1622,7 +1622,7 @@
null,
{
"id": 67,
"_name": "keyword.control.$1.makefile",
"_name": "keyword.control.$1.makefile",
"_nameIsCapturing": true,
"_contentName": null,
"_contentNameIsCapturing": false,
......@@ -2012,4 +2012,4 @@
"retokenizeCapturedWithRuleId": 0,
"_type": "CaptureRule"
}
]
\ No newline at end of file
]
......@@ -735,10 +735,10 @@ var Grammar = /** @class */ (function () {
this._rootId = rule_1.RuleFactory.getCompiledRuleId(this._grammar.repository.$self, this, this._grammar.repository);
}
console.log(this._ruleId2desc.length);
let fs = require('fs');
let data = JSON.stringify(this._ruleId2desc, null, 2);
fs.writeFileSync("testdata/makefile.out.json", data, 'utf8');
// console.log(this._ruleId2desc.length);
// let fs = require('fs');
// let data = JSON.stringify(this._ruleId2desc, null, 2);
// fs.writeFileSync("testdata/makefile.out.json", data, 'utf8');
var isFirstLine;
if (!prevState || prevState === StackElement.NULL) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册