mirror of
https://github.com/tree-sitter/tree-sitter.git
synced 2026-09-10 07:26:23 -04:00
fix(dsl): forbid invalid field names
This commit is contained in:
parent
99bc36b857
commit
fbf3049dc0
|
|
@ -34,6 +34,9 @@ function blank() {
|
|||
}
|
||||
|
||||
function field(name, rule) {
|
||||
if (typeof name !== "string" || !/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {
|
||||
throw new Error(`Invalid field name '${name}': field names must start with a letter or underscore, followed by letters, digits, or underscores`);
|
||||
}
|
||||
return {
|
||||
type: "FIELD",
|
||||
name,
|
||||
|
|
|
|||
Loading…
Reference in a new issue