Repository navigation
Conversation
tree-sitter-cpp doesn't accept an identifier right after the first string literal of a concatenation, so the common `"%" PRIu32` pattern produced an ERROR node. Accept the <inttypes.h> format macros in that position, aliased to `identifier` like in `PRIu32 "%"`. Restricting it to those macros avoids ambiguities like `extern "C" FOO`. Bump tree-sitter-mozcpp to 0.20.7 and re-enable `test_fn_id_strings`. Fixes #1266.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1269 +/- ##
==========================================
+ Coverage 90.43% 90.46% +0.02%
==========================================
Files 62 62
Lines 16458 16462 +4
==========================================
+ Hits 14884 14892 +8
+ Misses 1574 1570 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1266. Part of #1142.
tree-sitter-cpp only accepts an identifier before a string literal in a
concatenated_string(tree-sitter/tree-sitter-cpp#307). So"%" PRIu32, which is all over mozilla-central's logging and formatting code, produced anERRORnode.This PR overrides
concatenated_stringin tree-sitter-mozcpp so that a string literal can be followed by one of the<inttypes.h>format macros ((PRI|SCN)[diouxX](8|16|32|64|FAST*|LEAST*|MAX|PTR)). The macro is aliased toidentifier, so the tree has the same shape as forPRIu32 "%". Accepting any identifier there, like tree-sitter-c does, would be ambiguous with things likeextern "C" MOZ_EXPORT ...; that's presumably why tree-sitter-cpp dropped it.Checked with
tree-sitter parse:"%" PRIi32,"x=%" PRIu64 "\n","a" "b" PRIx32,u8"a" PRIX64 "b" PRIuPTR "c","%" SCNu32PRIu32 "%",int PRIu32x = 1;,#define PRIu32 "u",extern "C" int x;,extern "C" { ... },"abc"sv"%s" FOOwith an arbitrary macroAlso in this PR:
scanner.cunchanged), andlanguage_cpp.rsregenerated withrecreate-grammars.shtest_fn_id_stringsre-enabled, with two more samplesAll workspace tests pass, including the DeepSpeech/pdf.js/serde snapshot tests, with no snapshot changes.