fpoirotte/php_parsergenerator_installer

在安装软件包时自动编译解析器

0.1.4 2018-05-11 08:02 UTC

This package is auto-updated.

Last update: 2024-09-14 06:32:17 UTC


README

此仓库包含一个自定义的Composer安装程序,适用于使用 fpoirotte/php_parsergenerator Composer软件包编写的解析器项目。

当安装或更新依赖于此安装程序的软件包时,如果需要,其解析器将根据其源语法自动重新构建。同样,当卸载软件包时,这些解析器也会自动删除。

使用方法

要使用此安装程序,编辑您的项目composer.json文件

  • 将类型设置为php-parsers
  • 添加对fpoirotte/php_parsergenerator_installer的要求
  • 使用php-parsers附加选项声明您的解析器

附加选项可以包含以下内容:

  • 语法文件的相对路径列表:对于每个此类语法,将在同一文件夹中生成具有相同基本名称的解析器(例如,src/Foo.y 编译为 src/Foo.php
  • 预期的解析器与其源语法的映射(见下文)

例如,erebot/intl Composer软件包使用以下配置在src/PluralParser.php中构建一个解析器,基于位于软件包根目录相对路径data/PluralParser.y中的语法内容

{
     "name": "erebot/intl",
     "type": "php-parsers",
     "require": {
         "fpoirotte/php_parsergenerator_installer": "^0.1.0"
     },
     "extra": {
         "php-parsers": {
             "src/PluralParser.php": "data/PluralParser.y"
         }
     }
 }

现在,当安装/更新使用此安装程序的软件包时,您将看到类似以下输出

clicky@localhost:~/git/Erebot/Styling$ composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 34 installs, 0 updates, 0 removals
  - Installing fpoirotte/php_parsergenerator (0.2.3): Loading from cache
  - Installing fpoirotte/php_parsergenerator_installer (0.1.4): Loading from cache
  ...
Generating autoload files
Compiling '.../vendor/erebot/intl/src/PluralParser.php' from '.../vendor/erebot/intl/data/PluralParser.y'
Parser statistics: 28 terminals, 3 nonterminals, 27 rules
                   55 states, 0 parser table entries, 20 conflicts
20 parsing conflicts.
Compiling 'src/Styling/Parser.php' from 'data/Styling.y'
Parser statistics: 8 terminals, 3 nonterminals, 9 rules
                   17 states, 0 parser table entries, 0 conflicts

版权和许可

版权所有 (c) 2018,弗朗索瓦·波伊罗特。此安装程序根据3条款BSD许可协议授权,有关更多信息,请参阅LICENSE文件