Skip to main content

Crate vb6semantic

Crate vb6semantic 

Source
Expand description

Semantic analysis library for VB6 code.

This library provides tools for analyzing the semantics of VB6 code, including:

  • Scope management and symbol resolution
  • Type checking and inference
  • Name resolution and disambiguation
  • Error reporting and diagnostics

The main entry point is the SemanticAnalyzer struct, which can analyze VB6 project files and produce a detailed analysis result. The library is designed to be used in conjunction with the vb6parse library for parsing VB6 code from source files into a CST (Concrete Syntax Tree).

§Examples

use vb6semantic::SemanticAnalyzer;
use vb6parse::io::SourceFile;
use vb6parse::files::ProjectFile;

let mut analyzer = SemanticAnalyzer::new();
let project_source = SourceFile::from_file("MyProject.vbp").expect("Failed to read project file");
let (project_opt, failures) = ProjectFile::parse(&project_source).unpack();
if !failures.is_empty() {
    eprintln!("Failed to parse project file: {:?}", failures);
    return;
}

let project = project_opt.expect("Project file should have parsed successfully");

let analysis_result = analyzer.analyze_project(&project).expect("Failed to analyze project");
println!("Analysis completed with {} errors and {} warnings", analysis_result.errors.len(), analysis_result.warnings.len());

Re-exports§

pub use analyzer::SemanticAnalyzer;
pub use error::Result;
pub use error::SemanticError;
pub use error::SourceLocation;
pub use references::ManifestReferenceResolver;
pub use references::ReferenceContext;
pub use references::ReferenceInfo;
pub use references::ReferenceRegistry;
pub use references::ReferenceResolver;
pub use references::StaticReferenceResolver;
pub use resolution::NameResolver;
pub use scope::Scope;
pub use scope::ScopeKind;
pub use scope::ScopeManager;
pub use symbols::Symbol;
pub use symbols::SymbolKind;
pub use symbols::SymbolTable;
pub use symbols::Visibility;
pub use types::TypeChecker;

Modules§

analyzer
Semantic analyzer for VB6 code. This module performs semantic analysis on the parsed CST to build symbol tables, resolve names, check types, and report errors.
error
Error types for semantic analysis
location
Byte-offset → (line, column) mapping for CST nodes.
query
Query index over resolved identifier occurrences.
references
Project reference resolution for VB6 projects.
resolution
Name resolution logic for resolving symbol references in the VB6 semantic analysis This module contains the NameResolver struct, which is responsible for resolving symbol references within the current scope context. It provides methods to resolve simple names and qualified names, as well as checking symbol accessibility. The NameResolver interacts closely with the ScopeManager to perform lookups and determine accessibility based on symbol visibility and scope hierarchy.
scope
This module defines the Scope and ScopeManager structures for managing lexical scopes and symbol resolution in VB6 code.
symbols
Defines the Symbol struct and SymbolTable for managing symbols in the VB6 code This module provides the core data structures for representing symbols (variables, functions, classes, etc.) and a symbol table for managing them within different scopes. The Symbol struct includes information about the symbol’s name, kind, type, visibility, location, and scope. The SymbolTable struct provides methods to create scopes, add symbols, and perform lookups.
types
Type checking for VB6 symbols.

Structs§

TypeInfo
Type checking and inference. Type information for a VB6 symbol.

Enums§

VBType
VB6 type definition (re-exported from vb6core). The static type of a VB6 value, variable, or procedure.

Constants§

VERSION
Version of the semantic analysis library