対応言語
This is the list of programming languages parsed by big-code-analysis. Each entry below is a real LANG variant (defined by the mk_langs! invocation in big-code-analysis-ast/src/langs.rs) and is gated behind the matching per-language Cargo feature documented in Per-language Cargo features.
- Bash
- C
- C/C++
- C#
- Elixir
- Go
- Groovy
- Irules
- Java
- JavaScript
- Kotlin
- Lua
- Mozcpp
- Mozjs
- Objective-C
- Perl
- Php
- Python
- Ruby
- Rust
- Tcl
- Tsx
- Typescript
一部のエントリは、共有の文法パイプラインのバリアントです。JavaScript(アップストリームの tree-sitter-javascript 文法)は .js、.mjs、.cjs、.jsx ファイルのデフォルトです。Mozjs は Mozilla / SpiderMonkey フォークで、現在はオプトインです — .jsm(Firefox モジュール)拡張子のみを所有し、正規のスラッグ mozjs を報告します。両者は通常の JavaScript に対してメトリクス的に等価です。Tsx は JSX 構文を有効にした Typescript であり、別個のスラッグ tsx を報告します。#721 以降、C には独自のバリアント C(スラッグ c、アップストリームの tree-sitter-c)があり、.c と emacs モード c を所有します。C/C++ バリアント(スラッグ cpp、#720 以降はアップストリームの tree-sitter-cpp)は .cpp / .cc / .h とその他を引き続き受け持ちます。.h は意図的に Cpp のままです。C++ ヘッダーを C 文法に通すと class / template で ERROR が連鎖するのに対し、C ヘッダーを C++ 文法に通しても C++ キーワードと同名の識別子でつまずくだけだからです。Mozilla/Gecko の C++ 方言はオプトインの Mozcpp バリアント(スラッグ mozcpp)で、ファイル拡張子を所有せず、名前でのみ選択されます — ちょうど Mozjs と JavaScript の関係と同じです(C# は csharp を報告します)。#724 以降、Objective-C(スラッグ objc、アップストリームの tree-sitter-objc)は .m と emacs モード objc / objective-c を所有します。Objective-C++(.mm)は Cpp のままです。.mm ファイルには Objective-C と C++ が混在しており、tree-sitter-objc 文法は C++ 側(テンプレート、名前空間、::)をパースできないため、Objective-C の接合部分でしかつまずかない C++ 文法のほうが、この場合はより穏やかに劣化します — .h と同じトレードオフです。したがって .mm ファイルの Objective-C 部分のメトリクスは近似値です。各バリアントのスラッグはその LANG::name であり、小文字かつ句読点を含まないため、FromStr を通じてラウンドトリップできます。
K&R definitions with a wrapped return type
A pre-ANSI (K&R) function definition opens no function space under C or Objective-C when its return type wraps the declarator — int *, char **, struct S *, or a static pointer return all reproduce it:
int *krptr(a, b) int a; int b; { if (a) { return 0; } return 1; }
tree-sitter-c 0.24.2 builds its old-style function definition from a declarator nested inside the old-style declarator, so an outer pointer_declarator is unreachable and the parser prefers a plain declaration that swallows the first parameter declaration, orphaning the body as a bare compound_statement. No ERROR node is produced — the parse silently succeeds wrongly, and there is no dispatch arm missing on our side.
The consequence is that the body's decisions are charged to the file's unit space: the line above reports cyclomatic.sum 2 and nom.functions 0, a file-level count no function-level row accounts for. A K&R definition whose return type does not wrap the declarator (int krplain(a, b) int a; int b; { … }) is unaffected, as is any ANSI definition. C/C++ and Mozcpp open no space for either K&R form, because tree-sitter-cpp has no rule for the syntax at all. This is an upstream grammar limitation, tracked here as #1209.
内部ヘルパーバリアント
以下の LANG バリアントはユーザー向けの言語ではありません — C ファミリー分析パイプラインの内部ヘルパーであり(すべての C ファミリー Cargo フィーチャ cpp、c、mozcpp に同梱されます)、ソースファイルの分析時に直接選択されることはありません:
Ccomment— C/C++ のコメントに特化しています。Preproc— C/C++ のプリプロセッサマクロに特化しています。
注: #720 以降、Mozilla/Gecko の C++ 方言は
MozcppLANGバリアントとして公開されています(ベンダリングされたbca-tree-sitter-mozcppクレートに支えられ、オプトインのmozcppフィーチャで取り込まれます)。ファイル拡張子を所有しない、名前で選択可能な完全に公開の言語であり、上記のCcomment/Preprocヘルパーとは異なり、内部用では 「ありません」 。