tacoberu / hayo-ast
Abstract Syntax Tree (AST) implementation for the Hayo scripting language.
v0.1.5
2026-06-02 02:58 UTC
Requires
- php: >=7.4
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
- slevomat/coding-standard: ^8.24
- spaze/phpstan-disallowed-calls: ^4.6
- tracy/tracy: ^2.4
This package is auto-updated.
Last update: 2026-06-03 03:01:39 UTC
README
Abstract Syntax Tree (AST) implementation for the Hayo scripting language in PHP.
Note: This project is not useful on its own as it is a component of the php-hayo project.
Installation
Install via Composer:
composer require tacoberu/hayo-ast
Basic Usage
The library provides classes for representing various language constructs like expressions, scalars, lambdas, and scopes.
Scalars
Represent basic values:
use Taco\Hayo\Scalar; $int = Scalar::Int_(42); $str = Scalar::Str_("Hello World"); $bool = Scalar::Bool_(true); echo (string) $int; // 42 : Int
Expressions
Expressions can be functional calls or binary operations:
use Taco\Hayo\Expr; use Taco\Hayo\Scalar; // Function call: str.len "Lorem" $expr = Expr::Func_("str.len", [Scalar::Str_("Lorem")]); // Binary operation: 1 + 2 $binExpr = Expr::Bin_(Scalar::Int_(1), "+", Scalar::Int_(2));
References
You can track required symbols (references) in an expression:
$expr = Expr::Bin_('a', "+", Scalar::Int_(1)); print_r($expr->refs()); // ['a', '+']
License
This project is licensed under the MIT License.