#php #semantic #ast #mago #analysis #check #rules

mago-semantics

Performs semantic analysis on PHP code, interpreting the AST to check correctness, resolve references, and enforce language rules

16 releases

new 0.0.19 Jan 10, 2025
0.0.18 Dec 29, 2024

#214 in Programming languages

Download history 359/week @ 2024-12-04 381/week @ 2024-12-11 271/week @ 2024-12-18 310/week @ 2024-12-25 43/week @ 2025-01-01

1,153 downloads per month
Used in 5 crates (4 directly)

MIT/Apache

1MB
22K SLoC

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.

Dependencies

~12–24MB
~307K SLoC