[Misc] Validate grammar and fail early (#11119)
This commit is contained in:
@@ -26,15 +26,11 @@ def grammar_is_likely_lark(grammar_str: str) -> bool:
|
||||
if not line:
|
||||
continue
|
||||
|
||||
# Look for Lark-style rule definitions
|
||||
if ':' in line and '::=' not in line:
|
||||
return True
|
||||
# Look for GBNF rule definition
|
||||
if '::=' in line:
|
||||
return False
|
||||
|
||||
# Look for Lark-specific features
|
||||
if any(pattern in line for pattern in ['?start:', '|', '~']):
|
||||
return True
|
||||
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def convert_lark_to_gbnf(grammar_str: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user