common/grammar : replace problematic backtracking regex [\s\S]* (#18342)

* grammar : add support for std::regex_search() with trigger patterns

* common : update hermes2 pro trigger to search instead of match

* common : use regex_search with anchoring for partial matching

* common : adjust regex partial tests to use new pattern

* grammar : check pattern directly instead of adding a type

* common : adjust existing patterns to match new semantics
This commit is contained in:
Aldehir Rojas
2026-01-03 16:02:43 -06:00
committed by GitHub
parent c69c7ebc90
commit cef1d23c5a
6 changed files with 83 additions and 52 deletions
+2
View File
@@ -119,6 +119,8 @@ struct llama_grammar_parser {
struct llama_grammar_trigger_pattern {
std::string pattern;
std::regex regex;
size_t find(const std::string & input) const;
};
struct llama_grammar {