Skip to content
cd /languages
  • Long-lived desktop
  • Programming
  • AST and symbol support

Pascal and Delphi Support in Maguyva: Unit and Class Graphs

Maguyva parses Pascal and Delphi units with AST, symbol, and graph support, so AI agents can map uses clauses, classes, and procedures before changing them.

Why Pascal codebases need a map first

Delphi and Free Pascal applications often grow around a few large units that everything else uses. Forms inherit from base forms, components from base components, and business rules sit in procedures that a dozen screens call. The code reads well file by file, but the dependencies are where changes go wrong.

Maguyva gives an agent the unit and class structure first, so it can say what a change touches before it writes anything.

What Maguyva extracts in Pascal

Maguyva covers .pas and .pp source units. Procedure and function definitions are extracted as callable symbols, with the procedure, function, var, and const keywords stripped from definition names. Classes and interfaces are selectable as type definitions in structural search.

Imports come from uses clauses, with the keyword stripped so the graph stores unit names. Calls are normalized by removing member prefixes, arguments, and wrapping parentheses, so a call written as Self.Save(x) is stored as Save.

The graph records calls, inheritance, interface implementation, overrides, instantiation, type references, reads and writes, and exception raise and handler edges. Around 107 runtime-library routines (WriteLn, ReadLn, Inc, Dec, Ord, and similar) are filtered out of relationships.

Example agent prompts

  • “Which units use DataModuleMain, and what do they call from it?” (dependency_search incoming)
  • “Which forms inherit from TBaseEditForm, and which methods do they override?” (find_symbol, then dependency_search)
  • “Explain how an invoice is posted, from the button handler to the database unit.” (get_task_context)

Known limits

  • Only .pas and .pp are mapped to Pascal. Delphi project and form files such as .dpr and .dfm are not in the extension list, so form layouts and project wiring are outside the graph.
  • Methods use the same syntax as free procedures, so the methods preset in structural_search selects nothing. Use the functions preset.
  • Calls to filtered runtime-library routines do not appear as graph edges. Use text_pattern_search for them.

Next steps

Connect a repository with the quickstart, then check the support matrix on the compatibility page. If the application links C libraries, read the C guide too.

Best fit

  • > Teams maintaining Delphi or Lazarus/Free Pascal applications whose original authors have moved on.
  • > Object Pascal codebases with deep class hierarchies, interfaces, and large shared units.
  • > Modernization or porting work where the first deliverable is a map of units and their dependencies.

Agent workflows

  • > List every unit that names a shared unit in its `uses` clause before changing it.
  • > Find the classes that inherit from a base form or component and the methods they override.
  • > Trace which procedures call a routine before changing its parameters.

Engine details

  • > Pascal support covers `.pas` and `.pp` units. Delphi project and form files such as `.dpr` and `.dfm` are not in the extension list.
  • > `uses` clauses become import relationships, and calls are normalized by stripping member prefixes, arguments, and wrapping parentheses.
  • > About 107 runtime-library routines such as `WriteLn`, `Inc`, and `Ord` are filtered from relationships so application code stands out.

Useful MCP entry points

  • find_symbol

    Use it for a class, form, or procedure name when you need its definition and references.

  • dependency_search

    Use incoming traversal on a shared unit or base class to see which units and descendants depend on it.

  • get_task_context

    Use it for prompts like “explain how an invoice is posted, from the button handler to the database unit.”