Deep Dive How FlowSquad Understands 29+ Programming Languages — Including COBOL, RPG, and Fortran
Deep-Dive Developers · DevOps Engineers

How FlowSquad Understands 29+ Programming Languages — Including COBOL, RPG, and Fortran

Tree-sitter AST parsing for 29 modern languages, plus LLM-first analysis for COBOL, RPG/RPGLE, REXX, Fortran, Assembly, and IBM i artifacts — without writing a single custom parser.

April 15, 2026 · 12 min read · DevelopersDevOps Engineers
TL;DR

Why Is Multi-Language Code Analysis Hard?

Every programming language has its own syntax, scoping rules, idioms, and AST shape. A naive approach to multi-language analysis — regex-based pattern matching — breaks on multi-line strings, nested closures, metaprogramming, and language-specific comment styles. Writing a custom parser for each language is tractable for two or three languages but becomes an indefinite maintenance burden at 29+. For legacy languages like COBOL and RPG, the situation is even harder: mature tree-sitter grammars simply do not exist for most of them.

The challenge compounds for AI-assisted analysis: LLMs have fixed context windows. You cannot simply dump an entire 200,000-line codebase into a prompt and ask "what does this do?". Effective code analysis requires chunking — splitting the codebase into semantically coherent units — and retrieval — finding the right chunks for a given query. Both chunking and retrieval are dramatically more accurate when done at semantic boundaries (function definitions, class bodies, module imports) rather than arbitrary line counts.

FlowSquad solves this by combining 3 technologies: Tree-sitter for syntax-aware parsing of modern languages, ONNX Runtime for fast local embeddings, and VectorDB (ChromaDB or Pinecone) for approximate nearest-neighbor retrieval. For legacy languages where tree-sitter grammars are unavailable, FlowSquad uses an LLM-first approach — the LLM natively understands COBOL, RPG, REXX, and Fortran semantics, producing analysis quality that exceeds regex-based alternatives for these languages.

How Does Tree-Sitter Enable Language-Agnostic Parsing?

Tree-sitter is a parser generator and incremental parsing library originally developed at GitHub. It produces a concrete syntax tree (CST) from source code using grammar files written in a declarative JSON/DSL format. FlowSquad ships with pre-compiled Tree-sitter grammars for 29 modern languages — no grammar compilation is required at runtime.

The key property that makes Tree-sitter suitable for production code analysis is its error recovery: when encountering invalid syntax (which is common in partially written or refactoring-in-progress codebases), Tree-sitter produces a best-effort tree rather than failing. This means FlowSquad can analyze work-in-progress branches and uncommitted changes, not just clean main branches.

From the CST, FlowSquad's semantic extractor runs language-specific visitor functions that pull out the analysis-relevant nodes: function/method definitions and their signatures, class definitions and inheritance hierarchies, import/require/use statements, docstrings and inline comments, and top-level constants and configuration. These are normalized into a language-agnostic CodeSymbol schema used throughout the analysis pipeline.

┌─────────────────── FlowSquad Code Analysis Pipeline ───────────────────────┐ │ │ │ Source File Tree-sitter Semantic ONNX │ │ (any language) ──► CST Parse ──► Extractor ──► Embedder │ │ ~0.8ms/file ~2ms/file ~5ms/chunk │ │ │ │ ──► VectorDB Chunked CodeSymbol 384-dim │ │ Upsert ◄── Storage ◄── Schema ◄── Vectors │ │ ~10ms/batch (ChromaDB/ {name, type, (all-MiniLM │ │ Pinecone) body, lang, -L6-v2) │ │ file, line} │ └──────────────────────────────────────────────────────────────────────────────┘

How Does FlowSquad Build a Semantic Index from Source Code?

After Tree-sitter parsing produces a list of CodeSymbol objects, FlowSquad's indexer performs 3 steps before writing to VectorDB. First, it chunks each symbol: functions shorter than 512 tokens are treated as single chunks; longer functions are split at logical boundaries (inner function definitions, loop bodies) to stay within the embedding model's context window. Second, it constructs a chunk document combining the symbol's signature, docstring, and body for richer semantic signal. Third, it calls the local ONNX embedding model to produce a 384-dimensional float32 vector for each chunk.

The resulting vectors are upserted into VectorDB alongside metadata: file path, symbol name, language, line number range, and the raw source text. At query time (e.g., when AskProduct receives a user question), FlowSquad embeds the query using the same ONNX model, performs an ANN search across all 4 VectorDB collections (code, epics, stories, documentation), and returns the top-K chunks for LLM context assembly.

What Does ONNX Embedding Bring to the Analysis Pipeline?

ONNX Runtime (Open Neural Network Exchange) allows FlowSquad to run the embedding model entirely on-premise — the same host that runs the FlowSquad application server — without sending code to any external API. This is critical for air-gapped deployments and for organizations with strict data residency requirements that prohibit sending source code to cloud services.

The default embedding model is all-MiniLM-L6-v2, a 22.7M parameter sentence transformer that produces high-quality 384-dimensional semantic embeddings while running efficiently on CPU. On a standard 4-core application server, it achieves ~200 embeddings/second — sufficient to index a 100,000-line codebase in under 3 minutes. For teams with GPU resources, ONNX Runtime's CUDA execution provider can push throughput above 2,000 embeddings/second.

Crucially, the same ONNX model is used at both index time and query time, guaranteeing that similarity scores are comparable. This is not guaranteed when using cloud embedding APIs, where model versions can change silently between index and query operations, corrupting retrieval quality.

Which Languages Are Supported and What Gets Extracted?

FlowSquad's polyglot analysis spans two tiers: 29 modern languages with full tree-sitter AST parsing, and a second tier of legacy and platform-specific languages served by LLM-first analysis. Together they cover the full range of codebases found in enterprise environments — from greenfield microservices to decades-old IBM i applications.

Tier 1 — Tree-Sitter AST Parsing (29 languages)

Each of these languages has a dedicated tree-sitter grammar bundled with FlowSquad and a semantic extractor tuned to that language's idioms. AST-level metrics (cyclomatic complexity, call depth, symbol extraction) are available for all Tier 1 languages.

LanguageFunctions/MethodsClasses/StructsImportsDocstringsTypes/Interfaces
Python✓✓✓✓ (PEP 257)✓ (type hints)
Java✓✓✓✓ (Javadoc)✓ (interfaces)
Go✓✓ (structs)✓✓ (GoDoc)✓ (interfaces)
Rust✓✓ (structs/enums)✓ (use)✓ (//!)✓ (traits)
JavaScript✓✓ (ES6)✓ (ESM/CJS)✓ (JSDoc)—
TypeScript✓✓✓✓ (TSDoc)✓ (interfaces)
C#✓✓✓ (using)✓ (XML)✓ (interfaces)
C++✓✓✓ (#include)✓ (Doxygen)✓ (templates)
Ruby✓✓ (modules)✓ (require)✓ (YARD)—
PHP✓✓✓ (use/require)✓ (PHPDoc)✓ (interfaces)
Kotlin✓✓ (data classes)✓✓ (KDoc)✓ (interfaces)
Swift✓✓✓✓✓ (protocols)
Scala✓✓✓✓ (ScalaDoc)✓ (traits)
Dart✓✓✓✓✓
Lua✓—✓ (require)——
R✓—✓ (library)✓ (roxygen2)—
Groovy✓✓✓✓✓
Perl✓✓ (packages)✓ (use)✓ (POD)—
Bash/Shell✓ (functions)—✓ (source)——
PowerShell✓—✓——
Fortran✓✓ (modules)✓ (use)——
Assembly (ASM)✓ (procedures)————
Objective-C✓✓✓ (#import)✓✓
HTML—————
CSS—————
JSON—————
YAML—————
SQL✓ (procedures)————

Tier 2 — LLM-First Analysis (legacy & IBM i languages)

For these languages, no mature tree-sitter grammar exists. FlowSquad skips the AST parse step and routes directly to LLM-based semantic analysis — which actually performs better than regex parsers for highly structured legacy dialects like COBOL and RPG. File discovery, LOC metrics, security pattern scanning, and full LLM-driven requirement and architecture analysis are all available.

LanguageFile ExtensionsFile Discovery & LOCSecurity ScanLLM Semantic AnalysisAST Metrics
COBOL.cbl .cob .cobol .sqlcbl✓✓ (regex patterns)✓—
RPG / RPGLE.rpg .rpgle .sqlrpgle✓✓ (regex patterns)✓—
CL / CLLE.clle .clp .clp38✓✓✓—
REXX.rexx .rex✓✓✓—
IBM i Artifacts.dds .bnd .mnusrc .msgf✓✓✓—
PL/SQL.pls .pck .pkb .pks .plsql✓—✓—
T-SQL.tsql✓—✓—
Why LLM-first works well for legacy languages: Modern LLMs are trained on large corpora of COBOL, RPG, and REXX source code from open-source repositories, mainframe documentation, and enterprise code samples. They understand COBOL's IDENTIFICATION DIVISION, RPG's fixed-format columns, and REXX's procedural structures natively — without requiring a compiled grammar. For the primary use cases (requirement extraction, architecture mapping, security pattern detection), LLM analysis of legacy code is comparable in quality to tree-sitter analysis of modern languages.
# Example: FlowSquad extraction output for a Python module { "file": "src/services/payment_processor.py", "language": "python", "symbols": [ { "type": "class", "name": "PaymentProcessor", "line_start": 12, "docstring": "Handles Stripe and PayPal payment processing.", "methods": ["charge", "refund", "get_status"] }, { "type": "function", "name": "charge", "signature": "def charge(self, amount: Decimal, card_token: str) -> PaymentResult", "line_start": 34, "embedding_chunk": "[384-dim float32 vector]" } ], "imports": ["stripe", "decimal", "logging"], "index_time_ms": 23 }

Frequently Asked Questions

Does FlowSquad support COBOL analysis?

Yes. FlowSquad recognises COBOL files (.cbl, .cob, .cobol, .sqlcbl) and processes them through file discovery, LOC metrics, regex-based security pattern scanning, and LLM-driven semantic analysis. Because no production-ready tree-sitter grammar exists for enterprise COBOL dialects, FlowSquad uses an LLM-first approach for COBOL — which delivers meaningful requirement extraction, architecture mapping, and security insights without a compiled parser. See COBOL, RPG & IBM i Analysis in FlowSquad for a full walkthrough.

Does FlowSquad support RPG / RPGLE for IBM i?

Yes. FlowSquad recognises RPG files (.rpg, .rpgle, .sqlrpgle) alongside CL, REXX, DDS, BND, and other IBM i platform artifacts. These are processed through the same LLM-first pipeline as COBOL. IBM i shops can load an entire IFS repository and get requirement analysis, architecture diagrams, and security scanning on their RPG and CL source — out of the box, with no configuration changes.

Can FlowSquad be extended to support additional languages?

Yes. Adding a new Tier 1 language requires a Tree-sitter grammar (which exist for 100+ languages in the official Tree-sitter repository) and a semantic extractor visitor function. The ONNX embedding and VectorDB pipeline requires no changes. For languages without a tree-sitter grammar, FlowSquad's LLM-first path handles them automatically as long as the file extension is registered — community-contributed language support is on the public roadmap.

How does FlowSquad handle mixed-language repositories (polyglot monorepos)?

FlowSquad detects language at the file level using extension mapping and Tree-sitter grammar probing. Files of different languages within the same repository — including a mix of Java microservices and legacy COBOL batch programs — are indexed independently and stored in the same VectorDB collection, allowing cross-language queries in AskProduct (e.g., "How does the Java API service call the COBOL payment batch program?").

Does FlowSquad send source code to any external service?

No code is sent externally during the indexing process. Tree-sitter parsing and ONNX embedding run entirely on the FlowSquad host. Code chunks are sent to your configured LLM provider (OpenAI, Anthropic, etc.) when features like AskProduct or HLD generation assemble an LLM prompt — but this can be eliminated entirely by using an on-premise Ollama deployment.

How does the index stay up to date as the codebase changes?

FlowSquad supports incremental re-indexing triggered by webhook events from connected Git providers (GitHub, GitLab, Bitbucket, Azure DevOps). When a push event is received, only the changed files are re-parsed and re-embedded. A full re-index can also be triggered manually from the Admin panel.

What VectorDB backends are supported?

FlowSquad supports two VectorDB backends: ChromaDB (recommended for on-premise/air-gapped deployments, runs as a local service) and Pinecone (managed cloud VectorDB, recommended for teams already on Pinecone or preferring a hosted option). The backend is configured in the Setup Wizard and can be changed with a re-index.

Share on dev.to Share on Hashnode Share on Medium Share on LinkedIn