Crate mago_semantics

Source
Expand description

§Mago Semantics Crate

The mago_semantics crate provides semantic analysis capabilities for PHP code. Mago is the name of the toolchain, and this crate processes PHP source code to generate an abstract syntax tree (AST), performs name resolution, builds a symbol table, and detects semantic issues.

This crate is essential for the compilation pipeline of PHP within the Mago toolchain, ensuring that source code adheres to the language’s semantic rules before code generation or interpretation.

§Features

  • Parsing: Converts PHP source code into an AST.
  • Name Resolution: Associates identifiers with their declarations.
  • Symbol Table Construction: Records all symbols (classes, functions, variables) for quick lookup.
  • Semantic Analysis: Checks for semantic correctness and reports issues.

Structs§

Semantics
The Semantics struct encapsulates all the information obtained after performing semantic analysis on a PHP source code file. It includes the original source code, the parsed abstract syntax tree (AST), any parse errors encountered, resolved names, the symbol table, and a collection of semantic issues.