Class ParseTreeSymbolSearch

java.lang.Object
org.ek9lang.cli.ParseTreeSymbolSearch

public final class ParseTreeSymbolSearch extends Object
Provides parse tree traversal operations for symbol lookup. Extracts recursive tree walking logic into a reusable helper.
  • Constructor Details

    • ParseTreeSymbolSearch

      public ParseTreeSymbolSearch(ParsedModule module)
  • Method Details

    • findByName

      public Optional<ISymbol> findByName(org.antlr.v4.runtime.tree.ParseTree root, String name)
      Find a symbol by name anywhere in the parse tree.
      Parameters:
      root - The root node to search from
      name - The symbol name to find
      Returns:
      The symbol if found
    • findFirst

      public Optional<ISymbol> findFirst(org.antlr.v4.runtime.tree.ParseTree root, Predicate<ISymbol> predicate)
      Find the first symbol matching a predicate.
      Parameters:
      root - The root node to search from
      predicate - The matching condition
      Returns:
      The first matching symbol if found
    • collectVariablesInScope

      public List<ISymbol> collectVariablesInScope(org.antlr.v4.runtime.tree.ParseTree root, String scopeName, String prefix)
      Collect variables from a named scope (e.g., program or function body).
      Parameters:
      root - The root node to search from
      scopeName - The name of the scope to search within
      prefix - Prefix to filter variable names
      Returns:
      List of matching variable symbols