Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit cebac48

Browse files
author
Hendrik van Antwerpen
authored
Merge pull request #416 from eyakubovich/ey/err-on-unmatched-directive
Check for nested and unmatched directives
2 parents c09f746 + b96c015 commit cebac48

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

  • languages/tree-sitter-stack-graphs-typescript

languages/tree-sitter-stack-graphs-typescript/build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ fn preprocess(
4141
bail!("Line {line_no}: unexpected code before directive");
4242
}
4343

44+
if filter.is_some() {
45+
bail!("Line {line_no}: dialect directive cannot be nested");
46+
}
47+
4448
let directive = captures.get(1).unwrap().as_str();
4549
if !DIALECTS.contains(&directive) {
4650
bail!("Line {line_no}: unknown dialect: {directive}");
@@ -64,6 +68,10 @@ fn preprocess(
6468
output.write(b"\n")?;
6569
}
6670

71+
if filter.is_some() {
72+
bail!("Unmatched directive end at the end of the file");
73+
}
74+
6775
Ok(())
6876
}
6977

0 commit comments

Comments
 (0)