More work to support TextMate grammars.

This commit is contained in:
Martín Lucas Golini
2025-05-10 21:34:02 -03:00
parent 51430ae87b
commit af381e400a
6 changed files with 309 additions and 110 deletions

View File

@@ -58,6 +58,9 @@ class EE_API RegEx : public PatternMatcher {
ExtendedMore = 0x01000000u, // C
Literal = 0x02000000u, // C
MatchInvalidUtf = 0x04000000u, // J M D
Anchored = 0x80000000u,
NoUtfCheck = 0x40000000u,
Endanchored = 0x20000000u,
FilterOutCaptures =
0x08000000u, // It will filter out repeated captures and same range captures
};
@@ -83,9 +86,10 @@ class EE_API RegEx : public PatternMatcher {
mutable size_t mMatchNum;
void* mCompiledPattern;
int mCaptureCount;
bool mValid{ false };
bool mCached{ false };
bool mFilterOutCaptures{ false };
bool mValid : 1 { false };
bool mCached : 1 { false };
bool mFilterOutCaptures : 1 { false };
bool mAnchored : 1 { false };
};
}} // namespace EE::System

View File

@@ -59,7 +59,9 @@ struct EE_API SyntaxPattern {
const SyntaxDefinition* def{ nullptr };
Uint16 flags{ 0 };
Uint16 repositoryIdx{ 0 };
std::vector<SyntaxPattern> subPatterns;
std::vector<SyntaxPattern> contentPatterns;
String::HashType contentScopeRepoHash{
0 }; // Hash of the repository containing this rule's content patterns
SyntaxPattern( std::vector<std::string>&& _patterns, const std::string& _type,
const std::string& _syntax = "",
@@ -122,6 +124,8 @@ struct EE_API SyntaxPattern {
inline bool checkIsRepositoryInclude() const {
return checkIsIncludePattern() && patterns[1][0] == '#';
}
inline bool hasContentScope() const { return contentScopeRepoHash != 0; }
};
class EE_API SyntaxDefinition {
@@ -245,6 +249,8 @@ class EE_API SyntaxDefinition {
const SyntaxPattern* getPatternFromState( const SyntaxStateType& state ) const;
void compile();
protected:
friend class SyntaxDefinitionManager;