ls-a/arithmetic-ast 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ls-a/arithmetic-ast

最新稳定版本:1.0.0

Composer 安装命令:

composer require ls-a/arithmetic-ast

包简介

Implements the Shunting Yard Algorithm and creates an Abstract Syntax Tree with arithmetic operations

README 文档

README

This documentation is also available in these languages:

This library provides a implementation of Abstract Syntax Tree for arithmetic operations.
For more information, see these links:

Code sample:

<?php

$tokens = [
    TokenParser::parse('1 + 2 * 3'),
    TokenParser::parse('1 + (2 * 3 % 5 - (2 + 3 + 4) + (5 / 2)) + (3 * 4)'),
    TokenParser::parse('(mock(1, 2) + 2.6) / 2'),
    TokenParser::parse('mock-with-dashes(mock-with-dashes(mock-with-dashes(2)))')
];

Features

This library includes :

  • Support for following operators : +, -, *, /, %
  • Allowance to create new operators, with custom symbols, whether single character or string
  • Unary operator managament
  • Functions support
  • Function string parameters
  • Variadic function parameters
  • Support for following units: mm, cm, pt, pc, in, % and related converters, plus support to create your own

For every operation, you can use evaluate method to get its result.

Why?

First, because why not? We could not find an arithmetic abstract syntax tree on composer and felt it was missing.
Next, for a little background, this package is used in XSL-Core package, to handle various XML function calls in attributes.

Installation

This library is available on Composer. Install it with:

composer require ls-a/arithmetic-ast

Changelog

Please refer to the CHANGELOG file to see the latest changes.

Support

We put our heart into delivering high-quality products that are accessible to everyone. If you like our work, don’t hesitate to reach out to us for your next project!

Contributing

Contributions are governed by the CONTRIBUTING file.

Security

If you’ve found a bug or vulnerability, please contact us by email at contact@ls-a.fr instead of opening an issue, in order to protect the security of other users.

Credits

  • Renaud Berthier

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2025-11-11