mehen supports eleven source languages, Markdown, and SQL. Per-file language detection is by extension, and the
matching analyzer crate owns parsing and metric interpretation. Each language uses the parser that
gives mehen the best semantic coverage for that ecosystem.
Source languages
| Language | Extensions | Parser |
|---|
| Python | .py | Ruff (ruff_python_parser + ruff_python_ast) |
| TypeScript / JavaScript | .ts, .mts, .cts, .js, .mjs, .cjs | Oxc (oxc_parser) |
| TSX / JSX | .tsx, .jsx | Oxc (oxc_parser) |
| PHP | .php | Mago (mago-syntax) |
| Ruby | .rb | Prism (ruby-prism) |
| Rust | .rs | ra_ap_syntax (rust-analyzer’s syntax library) |
| Go | .go | tree-sitter-go |
| Kotlin | .kt, .kts | ANTLR — official Kotlin spec grammar via antlr-rust-runtime |
| Java | .java | ANTLR — grammars-v4 Java grammar via antlr-rust-runtime |
| C | .c, .h | tree-sitter-c |
| PowerShell | .ps1, .psm1, .psd1 | tree-sitter-pwsh |
TypeScript is a superset of JavaScript, so mehen analyzes .js / .mjs / .cjs through the Oxc
TypeScript front-end and .jsx through Oxc’s TSX front-end.
Why these parsers
- Ruff parses Python with full support for current syntax (3.13/3.14 features, f-strings,
match/case, exception groups, async constructs) and exposes a typed AST plus a semantic model.
- Oxc is a JavaScript/TypeScript toolchain in Rust and one of the fastest TS parsers in
production. It handles decorators, class fields, parameter properties, JSX,
satisfies, using,
and dynamic import natively.
- Mago is a PHP toolchain in Rust. It understands attributes, promoted properties, enums, traits,
anonymous classes, readonly members, null-safe calls, and
match expressions out of the box.
- Prism is the official Ruby parser maintained by the Ruby core team. It covers blocks, lambdas,
numbered parameters, modifier conditionals, rescue modifiers, endless methods, pattern matching,
and safe navigation.
ra_ap_syntax is the syntax tree library used by rust-analyzer; it gives mehen exactly the
syntactic granularity rust-analyzer uses for its own analyses.
- ANTLR parses Kotlin and Java, generated to Rust by
ophi-dev/antlr-rust-runtime. Kotlin uses the
official Kotlin specification grammar, which models Kotlin
constructs (when entries, the elvis ?: and safe-call ?. operators, catch blocks, labeled
jumps, property accessors) as first-class, semantically-named rules. Java uses the community
grammars-v4 Java grammar, which
covers modern Java (records, sealed types, switch expressions, text blocks, pattern matching,
modules). Both are richer than a tree-sitter CST.
- Tree-sitter is mehen’s pick for Go, C, and PowerShell, where its grammar quality and
ecosystem maturity make it the best fit.
Documentation
| Format | Extensions | Parser |
|---|
| Markdown | .md, .markdown, .mdown, .mkd, .mkdn, .mdx | pulldown-cmark |
Markdown gets a dedicated documentation metric suite — code-style metrics like cyclomatic complexity
and NOM/NPA/NPM/WMC do not apply because Markdown has no functions or classes. See
Markdown metrics for the full set.
SQL
| Format | Extensions | Parser |
|---|
| SQL | .sql, .ddl, .dml | sqruff |
A dedicated SQL analyzer (mehen-sql) ships its own metric family — query-block structure, CTE
graphs, join graphs, predicate complexity, object-touch risk, dialect portability, and an
SQL-flavored Halstead. Code-style metrics like cyclomatic complexity and NOM/NPA/NPM/WMC do not
apply to declarative SQL. The dialect is inferred from syntax hints (postgres, T-SQL, snowflake,
bigquery, mysql, sqlite, oracle, clickhouse, redshift, sparksql, athena, db2) with a reported
confidence, defaulting to ANSI. See SQL metrics overview for the full set.
Polyglot monorepos
mehen runs per-file language detection over any directory tree. Pass multiple paths to limit which
trees are walked and let mehen pick supported languages from each:
mehen top-offenders crates/api/src apps/web/src tools --metric cognitive
The GitHub Action accepts the same multi-path input.