Skip to content

feat: add language support for Fortran, Ada, and COBOL #164

@jafreck

Description

@jafreck

Summary

Add tree-sitter extractor + LSP enrichment support for three enterprise/scientific languages: Fortran, Ada, and COBOL.

All three have actively maintained LSP servers and tree-sitter grammars available. None have SCIP indexers, so the implementation path is the standard tree-sitter + LSP enrichment pipeline.


Fortran

LSP server: fortls (Python, pip install fortls, 500+ stars, active)
Tree-sitter grammar: tree-sitter-fortran
Demand: HPC, scientific computing, national labs, weather modeling

What to implement

  • Add tree-sitter-fortran as a dependency
  • Create src/indexer/extractors/fortran.ts — extract program, subroutine, function, module, type declarations; extract call statements and function references as call refs; extract use statements as imports
  • Register in SourceIndexStage EXTRACTORS map and ParserPool LANG_PACKAGES
  • Add fortls to src/indexer/lsp/registry.ts ({ command: 'fortls', args: ['--notify_init'] })
  • Add file extensions: .f, .f90, .f95, .f03, .f08, .for, .fpp
  • Add test fixtures in tests/fixtures/fortran/
  • Add extractor tests

Notes

  • Fortran has both free-form (.f90+) and fixed-form (.f) syntax; tree-sitter-fortran handles both
  • CALL subroutine_name(args) is the primary call pattern; function calls appear as expressions
  • USE module_name is the import mechanism
  • TYPE :: TypeName defines derived types (similar to structs)

Ada

LSP server: ada_language_server (AdaCore, production-grade, used in GNAT Studio)
Tree-sitter grammar: tree-sitter-ada
Demand: Aerospace, defense, safety-critical systems, embedded

What to implement

  • Add tree-sitter-ada as a dependency
  • Create src/indexer/extractors/ada.ts — extract procedure, function, package, task, protected, type declarations; extract procedure/function calls as call refs; extract with/use clauses as imports
  • Register in SourceIndexStage EXTRACTORS map and ParserPool LANG_PACKAGES
  • Add ada_language_server to LSP registry ({ command: 'ada_language_server', args: [] })
  • Add file extensions: .ads, .adb, .ada
  • Add test fixtures in tests/fixtures/ada/
  • Add extractor tests

Notes

  • Ada has specs (.ads) and bodies (.adb) — both should be indexed
  • with Package_Name; use Package_Name; is the import pattern
  • Package hierarchy defines the namespace: Package.Child.Procedure_Name
  • AdaCore's LSP server requires a GPR project file; may need config guidance

COBOL

LSP server: Broadcom COBOL Language Support (Eclipse, active, enterprise-grade)
Alternative: IBM Z Open Editor (commercial)
Tree-sitter grammar: tree-sitter-cobol
Demand: Banking, insurance, mainframe modernization

What to implement

  • Add tree-sitter-cobol as a dependency
  • Create src/indexer/extractors/cobol.ts — extract PROGRAM-ID, SECTION, PARAGRAPH declarations; extract PERFORM and CALL statements as call refs; extract COPY statements as imports
  • Register in SourceIndexStage EXTRACTORS map and ParserPool LANG_PACKAGES
  • Add Broadcom COBOL LS to LSP registry
  • Add file extensions: .cob, .cbl, .cpy, .cobol
  • Add test fixtures in tests/fixtures/cobol/
  • Add extractor tests

Notes

  • COBOL has divisions (IDENTIFICATION, ENVIRONMENT, DATA, PROCEDURE) — focus extraction on PROCEDURE DIVISION
  • PERFORM paragraph-name and CALL 'program-name' are the primary call patterns
  • COPY copybook-name is the include/import mechanism
  • COBOL column layout (columns 1-6 sequence, 7 indicator, 8-72 code) — tree-sitter handles this
  • The Broadcom LSP requires copybook path configuration which may need .lore.config support

Implementation order

Recommended: Fortran → Ada → COBOL (in order of decreasing tooling maturity and setup simplicity)

References

  • LSP server implementations
  • Lore's existing extractor pattern: see src/indexer/extractors/c.ts or src/indexer/extractors/python.ts as templates

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions