Page MenuHomePhabricator

No OneTemporary

diff --git a/composer.json b/composer.json
index 58f83dc..a2a6a31 100644
--- a/composer.json
+++ b/composer.json
@@ -1,38 +1,39 @@
{
"name" : "spitfire/engine",
"license": "MIT",
"homepage": "https://spitfirephp.com",
"require": {
"php" : ">7",
"ext-gd" : "*",
"spitfire/dependency-provider": "dev-master",
"spitfire/caching": "dev-master",
"psr/log": "^1.1",
"spitfire/request": "^0.1.0",
"spitfire/cli": "dev-master",
"spitfire/database": "dev-master",
- "spitfire/collection": "dev-master"
+ "spitfire/collection": "dev-master",
+ "spitfire/ast": "dev-master"
},
"require-dev": {
"phpunit/phpunit": "^9.4",
"monolog/monolog": "^2.2"
},
"suggest": {
"monolog/monolog" : "Provides logging capabilities for applications"
},
"autoload": {
"files": [
"./core/functions.php"
],
"psr-4": {
"spitfire\\": "./"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
diff --git a/composer.lock b/composer.lock
index 5f9d1ab..aac11c6 100644
--- a/composer.lock
+++ b/composer.lock
@@ -1,2524 +1,2583 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "6b83842736fcf8cba1ea13cb0d09636e",
+ "content-hash": "e053d898acf3d9b9eaff700263225650",
"packages": [
{
"name": "magic3w/url-reflection",
"version": "v0.1.1",
"source": {
"type": "git",
"url": "https://phabricator.magic3w.com/source/url-reflection.git",
"reference": "6d7529af43c2cb1ed264e9b88d257ac4066b641c"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"autoload": {
"psr-4": {
"magic3w\\http\\url\\reflection\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "César de la Cal Bretschneider",
"email": "cesar@magic3w.com"
}
],
"description": "Allows applications to have a URL parsed and retrieve information about it's components",
"time": "2020-11-04T12:01:53+00:00"
},
{
"name": "psr/container",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
"homepage": "https://github.com/php-fig/container",
"keywords": [
"PSR-11",
"container",
"container-interface",
"container-interop",
"psr"
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/master"
},
"time": "2017-02-14T16:28:37+00:00"
},
{
"name": "psr/log",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"support": {
"source": "https://github.com/php-fig/log/tree/1.1.3"
},
"time": "2020-03-23T09:12:05+00:00"
},
+ {
+ "name": "spitfire/ast",
+ "version": "dev-master",
+ "source": {
+ "type": "git",
+ "url": "https://phabricator.magic3w.com/source/spitfire-ast.git",
+ "reference": "370c8ec285f29c957f0639ca1ac040ff4c21534f"
+ },
+ "require": {
+ "spitfire/collection": "dev-master",
+ "spitfire/exception": "dev-master"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "10.0.x-dev"
+ },
+ "default-branch": true,
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "spitfire\\ast\\": "./src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "César de la Cal Bretschneider",
+ "email": "cesar@magic3w.com"
+ }
+ ],
+ "description": "Allows applications to create abstract syntax trees that can read in input for validation and similar purposes.",
+ "time": "2020-12-22T20:15:51+00:00"
+ },
{
"name": "spitfire/caching",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://phabricator.magic3w.com/source/spitfire-caching.git",
"reference": "4c122e9fdd79979143cde9b6dd1c561a9866062f"
},
"require-dev": {
"phpunit/phpunit": "^9.4"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
"spitfire\\cache\\": "./src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "César de la Cal Bretschneider",
"email": "cesar@magic3w.com"
}
],
"description": "Caching component for spitfire",
"time": "2020-10-28T14:49:56+00:00"
},
{
"name": "spitfire/cli",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://phabricator.magic3w.com/source/spitfire-cli.git",
"reference": "e9a8edcac4da73ab4567c4c463dbbdc8e19a7160"
},
"require": {
"spitfire/collection": "dev-master"
},
"default-branch": true,
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "César de la Cal Bretschneider",
"email": "cesar@magic3w.com"
}
],
"description": "CLI Components for Spitfire",
"time": "2020-12-09T18:35:05+00:00"
},
{
"name": "spitfire/collection",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://phabricator.magic3w.com/source/spitfire-collection.git",
"reference": "91331bd1f15d9c15d363734bd477c7bd363291a5"
},
"require-dev": {
"phpunit/phpunit": "^9.4"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
"spitfire\\collection\\": "./src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "César de la Cal Bretschneider",
"email": "cesar@magic3w.com"
}
],
"description": "Provides collections for spitfire/engine",
"time": "2020-10-19T09:26:22+00:00"
},
{
"name": "spitfire/database",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://phabricator.magic3w.com/source/spitfire-database.git",
"reference": "fb0764e966a5eb1d4fb751f8ec76405422f008e6"
},
"require-dev": {
"phpunit/phpunit": "^9.4"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
"spitfire\\storage\\database\\": "./src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "César de la Cal Bretschneider",
"email": "cesar@magic3w.com"
}
],
"description": "Database components for spitfire/engine",
"time": "2020-11-04T15:22:44+00:00"
},
{
"name": "spitfire/dependency-provider",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://phabricator.magic3w.com/source/Spitfire-Provider.git",
"reference": "f62f4f265191203c79c49d8f4a5320e3e5da4626"
},
"require": {
"php": ">7",
"psr/container": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
"spitfire\\provider\\": "./src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"time": "2020-08-21T08:34:50+00:00"
},
+ {
+ "name": "spitfire/exception",
+ "version": "dev-master",
+ "source": {
+ "type": "git",
+ "url": "https://phabricator.magic3w.com/source/spitfire-exception.git",
+ "reference": "7b1cd4ef3df39dafe16e5a2fd8ed0c37d2881ddf"
+ },
+ "default-branch": true,
+ "type": "library",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "César de la Cal Bretschneider",
+ "email": "cesar@magic3w.com"
+ }
+ ],
+ "description": "Exception interfaces for spitfire",
+ "time": "2020-12-03T14:13:22+00:00"
+ },
{
"name": "spitfire/request",
"version": "v0.1.0",
"source": {
"type": "git",
"url": "https://phabricator.magic3w.com/source/spitfire-request.git",
"reference": "d3b3801273b7d65f42e974834a0658d9255caacd"
},
"require": {
"magic3w/url-reflection": "^0.1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.4"
},
"type": "library",
"autoload": {
"psr-4": {
"spitfire\\io\\request\\": "./src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "César de la Cal Bretschneider",
"email": "cesar@magic3w.com"
}
],
"description": "Spitfire request mechanism",
"time": "2020-10-15T16:00:20+00:00"
}
],
"packages-dev": [
{
"name": "doctrine/instantiator",
"version": "1.4.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b",
"reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^8.0",
"ext-pdo": "*",
"ext-phar": "*",
"phpbench/phpbench": "^0.13 || 1.0.0-alpha2",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com",
"homepage": "https://ocramius.github.io/"
}
],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://www.doctrine-project.org/projects/instantiator.html",
"keywords": [
"constructor",
"instantiate"
],
"support": {
"issues": "https://github.com/doctrine/instantiator/issues",
"source": "https://github.com/doctrine/instantiator/tree/1.4.0"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator",
"type": "tidelift"
}
],
"time": "2020-11-10T18:47:58+00:00"
},
{
"name": "monolog/monolog",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "1cb1cde8e8dd0f70cc0fe51354a59acad9302084"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/1cb1cde8e8dd0f70cc0fe51354a59acad9302084",
"reference": "1cb1cde8e8dd0f70cc0fe51354a59acad9302084",
"shasum": ""
},
"require": {
"php": ">=7.2",
"psr/log": "^1.0.1"
},
"provide": {
"psr/log-implementation": "1.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"elasticsearch/elasticsearch": "^7",
"graylog2/gelf-php": "^1.4.2",
"mongodb/mongodb": "^1.8",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
"phpspec/prophecy": "^1.6.1",
"phpstan/phpstan": "^0.12.59",
"phpunit/phpunit": "^8.5",
"predis/predis": "^1.1",
"rollbar/rollbar": "^1.3",
"ruflin/elastica": ">=0.90 <7.0.1",
"swiftmailer/swiftmailer": "^5.3|^6.0"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-mbstring": "Allow to work properly with unicode symbols",
"ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "https://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "https://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/2.2.0"
},
"funding": [
{
"url": "https://github.com/Seldaek",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/monolog/monolog",
"type": "tidelift"
}
],
"time": "2020-12-14T13:15:25+00:00"
},
{
"name": "myclabs/deep-copy",
"version": "1.10.2",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220",
"reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"replace": {
"myclabs/deep-copy": "self.version"
},
"require-dev": {
"doctrine/collections": "^1.0",
"doctrine/common": "^2.6",
"phpunit/phpunit": "^7.1"
},
"type": "library",
"autoload": {
"psr-4": {
"DeepCopy\\": "src/DeepCopy/"
},
"files": [
"src/DeepCopy/deep_copy.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Create deep copies (clones) of your objects",
"keywords": [
"clone",
"copy",
"duplicate",
"object",
"object graph"
],
"support": {
"issues": "https://github.com/myclabs/DeepCopy/issues",
"source": "https://github.com/myclabs/DeepCopy/tree/1.10.2"
},
"funding": [
{
"url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy",
"type": "tidelift"
}
],
"time": "2020-11-13T09:40:50+00:00"
},
{
"name": "nikic/php-parser",
"version": "v4.10.4",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "c6d052fc58cb876152f89f532b95a8d7907e7f0e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c6d052fc58cb876152f89f532b95a8d7907e7f0e",
"reference": "c6d052fc58cb876152f89f532b95a8d7907e7f0e",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=7.0"
},
"require-dev": {
"ircmaxell/php-yacc": "^0.0.7",
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
},
"bin": [
"bin/php-parse"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.9-dev"
}
},
"autoload": {
"psr-4": {
"PhpParser\\": "lib/PhpParser"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Nikita Popov"
}
],
"description": "A PHP parser written in PHP",
"keywords": [
"parser",
"php"
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v4.10.4"
},
"time": "2020-12-20T10:01:03+00:00"
},
{
"name": "phar-io/manifest",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/phar-io/manifest.git",
"reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phar-io/manifest/zipball/85265efd3af7ba3ca4b2a2c34dbfc5788dd29133",
"reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-phar": "*",
"ext-xmlwriter": "*",
"phar-io/version": "^3.0.1",
"php": "^7.2 || ^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Arne Blankerts",
"email": "arne@blankerts.de",
"role": "Developer"
},
{
"name": "Sebastian Heuer",
"email": "sebastian@phpeople.de",
"role": "Developer"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "Developer"
}
],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"support": {
"issues": "https://github.com/phar-io/manifest/issues",
"source": "https://github.com/phar-io/manifest/tree/master"
},
"time": "2020-06-27T14:33:11+00:00"
},
{
"name": "phar-io/version",
"version": "3.0.4",
"source": {
"type": "git",
"url": "https://github.com/phar-io/version.git",
"reference": "e4782611070e50613683d2b9a57730e9a3ba5451"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phar-io/version/zipball/e4782611070e50613683d2b9a57730e9a3ba5451",
"reference": "e4782611070e50613683d2b9a57730e9a3ba5451",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Arne Blankerts",
"email": "arne@blankerts.de",
"role": "Developer"
},
{
"name": "Sebastian Heuer",
"email": "sebastian@phpeople.de",
"role": "Developer"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "Developer"
}
],
"description": "Library for handling version information and constraints",
"support": {
"issues": "https://github.com/phar-io/version/issues",
"source": "https://github.com/phar-io/version/tree/3.0.4"
},
"time": "2020-12-13T23:18:30+00:00"
},
{
"name": "phpdocumentor/reflection-common",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b",
"reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-2.x": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jaap van Otterdijk",
"email": "opensource@ijaap.nl"
}
],
"description": "Common reflection classes used by phpdocumentor to reflect the code structure",
"homepage": "http://www.phpdoc.org",
"keywords": [
"FQSEN",
"phpDocumentor",
"phpdoc",
"reflection",
"static analysis"
],
"support": {
"issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
"source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
},
"time": "2020-06-27T09:03:43+00:00"
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "5.2.2",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "069a785b2141f5bcf49f3e353548dc1cce6df556"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556",
"reference": "069a785b2141f5bcf49f3e353548dc1cce6df556",
"shasum": ""
},
"require": {
"ext-filter": "*",
"php": "^7.2 || ^8.0",
"phpdocumentor/reflection-common": "^2.2",
"phpdocumentor/type-resolver": "^1.3",
"webmozart/assert": "^1.9.1"
},
"require-dev": {
"mockery/mockery": "~1.3.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mike van Riel",
"email": "me@mikevanriel.com"
},
{
"name": "Jaap van Otterdijk",
"email": "account@ijaap.nl"
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"support": {
"issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
"source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master"
},
"time": "2020-09-03T19:13:55+00:00"
},
{
"name": "phpdocumentor/type-resolver",
"version": "1.4.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
"reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0",
"phpdocumentor/reflection-common": "^2.0"
},
"require-dev": {
"ext-tokenizer": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-1.x": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"phpDocumentor\\Reflection\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mike van Riel",
"email": "me@mikevanriel.com"
}
],
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0"
},
"time": "2020-09-17T18:55:26+00:00"
},
{
"name": "phpspec/prophecy",
"version": "1.12.2",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "245710e971a030f42e08f4912863805570f23d39"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/245710e971a030f42e08f4912863805570f23d39",
"reference": "245710e971a030f42e08f4912863805570f23d39",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.2",
"php": "^7.2 || ~8.0, <8.1",
"phpdocumentor/reflection-docblock": "^5.2",
"sebastian/comparator": "^3.0 || ^4.0",
"sebastian/recursion-context": "^3.0 || ^4.0"
},
"require-dev": {
"phpspec/phpspec": "^6.0",
"phpunit/phpunit": "^8.0 || ^9.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11.x-dev"
}
},
"autoload": {
"psr-4": {
"Prophecy\\": "src/Prophecy"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Konstantin Kudryashov",
"email": "ever.zet@gmail.com",
"homepage": "http://everzet.com"
},
{
"name": "Marcello Duarte",
"email": "marcello.duarte@gmail.com"
}
],
"description": "Highly opinionated mocking framework for PHP 5.3+",
"homepage": "https://github.com/phpspec/prophecy",
"keywords": [
"Double",
"Dummy",
"fake",
"mock",
"spy",
"stub"
],
"support": {
"issues": "https://github.com/phpspec/prophecy/issues",
"source": "https://github.com/phpspec/prophecy/tree/1.12.2"
},
"time": "2020-12-19T10:15:11+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "9.2.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "f3e026641cc91909d421802dd3ac7827ebfd97e1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f3e026641cc91909d421802dd3ac7827ebfd97e1",
"reference": "f3e026641cc91909d421802dd3ac7827ebfd97e1",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-libxml": "*",
"ext-xmlwriter": "*",
"nikic/php-parser": "^4.10.2",
"php": ">=7.3",
"phpunit/php-file-iterator": "^3.0.3",
"phpunit/php-text-template": "^2.0.2",
"sebastian/code-unit-reverse-lookup": "^2.0.2",
"sebastian/complexity": "^2.0",
"sebastian/environment": "^5.1.2",
"sebastian/lines-of-code": "^1.0.3",
"sebastian/version": "^3.0.1",
"theseer/tokenizer": "^1.2.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"suggest": {
"ext-pcov": "*",
"ext-xdebug": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "9.2-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
"homepage": "https://github.com/sebastianbergmann/php-code-coverage",
"keywords": [
"coverage",
"testing",
"xunit"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.5"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-11-28T06:44:49+00:00"
},
{
"name": "phpunit/php-file-iterator",
"version": "3.0.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "aa4be8575f26070b100fccb67faabb28f21f66f8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8",
"reference": "aa4be8575f26070b100fccb67faabb28f21f66f8",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "FilterIterator implementation that filters files based on a list of suffixes.",
"homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
"keywords": [
"filesystem",
"iterator"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-09-28T05:57:25+00:00"
},
{
"name": "phpunit/php-invoker",
"version": "3.1.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-invoker.git",
"reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67",
"reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"ext-pcntl": "*",
"phpunit/phpunit": "^9.3"
},
"suggest": {
"ext-pcntl": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Invoke callables with a timeout",
"homepage": "https://github.com/sebastianbergmann/php-invoker/",
"keywords": [
"process"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-invoker/issues",
"source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-09-28T05:58:55+00:00"
},
{
"name": "phpunit/php-text-template",
"version": "2.0.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-text-template.git",
"reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28",
"reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Simple template engine.",
"homepage": "https://github.com/sebastianbergmann/php-text-template/",
"keywords": [
"template"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-text-template/issues",
"source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T05:33:50+00:00"
},
{
"name": "phpunit/php-timer",
"version": "5.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git",
"reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2",
"reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Utility class for timing",
"homepage": "https://github.com/sebastianbergmann/php-timer/",
"keywords": [
"timer"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-timer/issues",
"source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T13:16:10+00:00"
},
{
"name": "phpunit/phpunit",
"version": "9.5.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7bdf4085de85a825f4424eae52c99a1cec2f360",
"reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.3.1",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-xml": "*",
"ext-xmlwriter": "*",
"myclabs/deep-copy": "^1.10.1",
"phar-io/manifest": "^2.0.1",
"phar-io/version": "^3.0.2",
"php": ">=7.3",
"phpspec/prophecy": "^1.12.1",
"phpunit/php-code-coverage": "^9.2.3",
"phpunit/php-file-iterator": "^3.0.5",
"phpunit/php-invoker": "^3.1.1",
"phpunit/php-text-template": "^2.0.3",
"phpunit/php-timer": "^5.0.2",
"sebastian/cli-parser": "^1.0.1",
"sebastian/code-unit": "^1.0.6",
"sebastian/comparator": "^4.0.5",
"sebastian/diff": "^4.0.3",
"sebastian/environment": "^5.1.3",
"sebastian/exporter": "^4.0.3",
"sebastian/global-state": "^5.0.1",
"sebastian/object-enumerator": "^4.0.3",
"sebastian/resource-operations": "^3.0.3",
"sebastian/type": "^2.3",
"sebastian/version": "^3.0.2"
},
"require-dev": {
"ext-pdo": "*",
"phpspec/prophecy-phpunit": "^2.0.1"
},
"suggest": {
"ext-soap": "*",
"ext-xdebug": "*"
},
"bin": [
"phpunit"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "9.5-dev"
}
},
"autoload": {
"classmap": [
"src/"
],
"files": [
"src/Framework/Assert/Functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "The PHP Unit Testing framework.",
"homepage": "https://phpunit.de/",
"keywords": [
"phpunit",
"testing",
"xunit"
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.1"
},
"funding": [
{
"url": "https://phpunit.de/donate.html",
"type": "custom"
},
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2021-01-17T07:42:25+00:00"
},
{
"name": "sebastian/cli-parser",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/cli-parser.git",
"reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2",
"reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Library for parsing CLI options",
"homepage": "https://github.com/sebastianbergmann/cli-parser",
"support": {
"issues": "https://github.com/sebastianbergmann/cli-parser/issues",
"source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-09-28T06:08:49+00:00"
},
{
"name": "sebastian/code-unit",
"version": "1.0.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/code-unit.git",
"reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120",
"reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Collection of value objects that represent the PHP code units",
"homepage": "https://github.com/sebastianbergmann/code-unit",
"support": {
"issues": "https://github.com/sebastianbergmann/code-unit/issues",
"source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T13:08:54+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
"version": "2.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
"reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5",
"reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"support": {
"issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues",
"source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-09-28T05:30:19+00:00"
},
{
"name": "sebastian/comparator",
"version": "4.0.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "55f4261989e546dc112258c7a75935a81a7ce382"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382",
"reference": "55f4261989e546dc112258c7a75935a81a7ce382",
"shasum": ""
},
"require": {
"php": ">=7.3",
"sebastian/diff": "^4.0",
"sebastian/exporter": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
}
],
"description": "Provides the functionality to compare PHP values for equality",
"homepage": "https://github.com/sebastianbergmann/comparator",
"keywords": [
"comparator",
"compare",
"equality"
],
"support": {
"issues": "https://github.com/sebastianbergmann/comparator/issues",
"source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T15:49:45+00:00"
},
{
"name": "sebastian/complexity",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/complexity.git",
"reference": "739b35e53379900cc9ac327b2147867b8b6efd88"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88",
"reference": "739b35e53379900cc9ac327b2147867b8b6efd88",
"shasum": ""
},
"require": {
"nikic/php-parser": "^4.7",
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Library for calculating the complexity of PHP code units",
"homepage": "https://github.com/sebastianbergmann/complexity",
"support": {
"issues": "https://github.com/sebastianbergmann/complexity/issues",
"source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T15:52:27+00:00"
},
{
"name": "sebastian/diff",
"version": "4.0.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d",
"reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"symfony/process": "^4.2 || ^5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Kore Nordmann",
"email": "mail@kore-nordmann.de"
}
],
"description": "Diff implementation",
"homepage": "https://github.com/sebastianbergmann/diff",
"keywords": [
"diff",
"udiff",
"unidiff",
"unified diff"
],
"support": {
"issues": "https://github.com/sebastianbergmann/diff/issues",
"source": "https://github.com/sebastianbergmann/diff/tree/4.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T13:10:38+00:00"
},
{
"name": "sebastian/environment",
"version": "5.1.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "388b6ced16caa751030f6a69e588299fa09200ac"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac",
"reference": "388b6ced16caa751030f6a69e588299fa09200ac",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"suggest": {
"ext-posix": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.1-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Provides functionality to handle HHVM/PHP environments",
"homepage": "http://www.github.com/sebastianbergmann/environment",
"keywords": [
"Xdebug",
"environment",
"hhvm"
],
"support": {
"issues": "https://github.com/sebastianbergmann/environment/issues",
"source": "https://github.com/sebastianbergmann/environment/tree/5.1.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-09-28T05:52:38+00:00"
},
{
"name": "sebastian/exporter",
"version": "4.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d89cc98761b8cb5a1a235a6b703ae50d34080e65",
"reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65",
"shasum": ""
},
"require": {
"php": ">=7.3",
"sebastian/recursion-context": "^4.0"
},
"require-dev": {
"ext-mbstring": "*",
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "Provides the functionality to export PHP variables for visualization",
"homepage": "http://www.github.com/sebastianbergmann/exporter",
"keywords": [
"export",
"exporter"
],
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
"source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-09-28T05:24:23+00:00"
},
{
"name": "sebastian/global-state",
"version": "5.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "a90ccbddffa067b51f574dea6eb25d5680839455"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/a90ccbddffa067b51f574dea6eb25d5680839455",
"reference": "a90ccbddffa067b51f574dea6eb25d5680839455",
"shasum": ""
},
"require": {
"php": ">=7.3",
"sebastian/object-reflector": "^2.0",
"sebastian/recursion-context": "^4.0"
},
"require-dev": {
"ext-dom": "*",
"phpunit/phpunit": "^9.3"
},
"suggest": {
"ext-uopz": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Snapshotting of global state",
"homepage": "http://www.github.com/sebastianbergmann/global-state",
"keywords": [
"global state"
],
"support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues",
"source": "https://github.com/sebastianbergmann/global-state/tree/5.0.2"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T15:55:19+00:00"
},
{
"name": "sebastian/lines-of-code",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/lines-of-code.git",
"reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc",
"reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc",
"shasum": ""
},
"require": {
"nikic/php-parser": "^4.6",
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Library for counting the lines of code in PHP source code",
"homepage": "https://github.com/sebastianbergmann/lines-of-code",
"support": {
"issues": "https://github.com/sebastianbergmann/lines-of-code/issues",
"source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-11-28T06:42:11+00:00"
},
{
"name": "sebastian/object-enumerator",
"version": "4.0.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/object-enumerator.git",
"reference": "5c9eeac41b290a3712d88851518825ad78f45c71"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71",
"reference": "5c9eeac41b290a3712d88851518825ad78f45c71",
"shasum": ""
},
"require": {
"php": ">=7.3",
"sebastian/object-reflector": "^2.0",
"sebastian/recursion-context": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"support": {
"issues": "https://github.com/sebastianbergmann/object-enumerator/issues",
"source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T13:12:34+00:00"
},
{
"name": "sebastian/object-reflector",
"version": "2.0.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/object-reflector.git",
"reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7",
"reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
"support": {
"issues": "https://github.com/sebastianbergmann/object-reflector/issues",
"source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T13:14:26+00:00"
},
{
"name": "sebastian/recursion-context",
"version": "4.0.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git",
"reference": "cd9d8cf3c5804de4341c283ed787f099f5506172"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172",
"reference": "cd9d8cf3c5804de4341c283ed787f099f5506172",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
}
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"support": {
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
"source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T13:17:30+00:00"
},
{
"name": "sebastian/resource-operations",
"version": "3.0.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/resource-operations.git",
"reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8",
"reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"support": {
"issues": "https://github.com/sebastianbergmann/resource-operations/issues",
"source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-09-28T06:45:17+00:00"
},
{
"name": "sebastian/type",
"version": "2.3.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/type.git",
"reference": "81cd61ab7bbf2de744aba0ea61fae32f721df3d2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/type/zipball/81cd61ab7bbf2de744aba0ea61fae32f721df3d2",
"reference": "81cd61ab7bbf2de744aba0ea61fae32f721df3d2",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Collection of value objects that represent the types of the PHP type system",
"homepage": "https://github.com/sebastianbergmann/type",
"support": {
"issues": "https://github.com/sebastianbergmann/type/issues",
"source": "https://github.com/sebastianbergmann/type/tree/2.3.1"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-10-26T13:18:59+00:00"
},
{
"name": "sebastian/version",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/version.git",
"reference": "c6c1022351a901512170118436c764e473f6de8c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c",
"reference": "c6c1022351a901512170118436c764e473f6de8c",
"shasum": ""
},
"require": {
"php": ">=7.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"support": {
"issues": "https://github.com/sebastianbergmann/version/issues",
"source": "https://github.com/sebastianbergmann/version/tree/3.0.2"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-09-28T06:39:44+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.22.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "c6c942b1ac76c82448322025e084cadc56048b4e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e",
"reference": "c6c942b1ac76c82448322025e084cadc56048b4e",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-01-07T16:49:33+00:00"
},
{
"name": "theseer/tokenizer",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/theseer/tokenizer.git",
"reference": "75a63c33a8577608444246075ea0af0d052e452a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a",
"reference": "75a63c33a8577608444246075ea0af0d052e452a",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"php": "^7.2 || ^8.0"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Arne Blankerts",
"email": "arne@blankerts.de",
"role": "Developer"
}
],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"support": {
"issues": "https://github.com/theseer/tokenizer/issues",
"source": "https://github.com/theseer/tokenizer/tree/master"
},
"funding": [
{
"url": "https://github.com/theseer",
"type": "github"
}
],
"time": "2020-07-12T23:59:07+00:00"
},
{
"name": "webmozart/assert",
"version": "1.9.1",
"source": {
"type": "git",
"url": "https://github.com/webmozarts/assert.git",
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389",
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389",
"shasum": ""
},
"require": {
"php": "^5.3.3 || ^7.0 || ^8.0",
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {
"phpstan/phpstan": "<0.12.20",
"vimeo/psalm": "<3.9.1"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36 || ^7.5.13"
},
"type": "library",
"autoload": {
"psr-4": {
"Webmozart\\Assert\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "Assertions to validate method input/output with nice error messages.",
"keywords": [
"assert",
"check",
"validate"
],
"support": {
"issues": "https://github.com/webmozarts/assert/issues",
"source": "https://github.com/webmozarts/assert/tree/1.9.1"
},
"time": "2020-07-08T17:02:28+00:00"
}
],
"aliases": [],
"minimum-stability": "dev",
"stability-flags": {
"spitfire/dependency-provider": 20,
"spitfire/caching": 20,
"spitfire/cli": 20,
"spitfire/database": 20,
- "spitfire/collection": 20
+ "spitfire/collection": 20,
+ "spitfire/ast": 20
},
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": ">7",
"ext-gd": "*"
},
"platform-dev": [],
"plugin-api-version": "2.0.0"
}
diff --git a/core/parser/Lexer.php b/core/parser/Lexer.php
deleted file mode 100644
index ed5d57e..0000000
--- a/core/parser/Lexer.php
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php namespace spitfire\core\parser;
-
-use spitfire\core\parser\lexemes\EndOfFile;
-use spitfire\core\parser\lexemes\WhiteSpace;
-use spitfire\core\parser\scanner\ScannerModuleInterface;
-use spitfire\exceptions\PrivateException;
-use function collect;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class Lexer
-{
-
- private $modules;
-
- public function __construct() {
- $this->modules = collect(func_get_args());
-
- if (!$this->modules->containsOnly(ScannerModuleInterface::class)) {
- throw new PrivateException('Lexer error. Tried to provide invalid arguments', 1906100944);
- }
- }
-
- public function tokenize($str) {
- $buf = new StringBuffer($str);
- $ret = [];
-
- /*
- * Main loop. If the lexer has not yet finished looping over the string, then
- * it's not done yet.
- */
- while ($buf->hasMore()) {
-
- /*
- * Iterate over the modules. The way the lexer is constructed, it allows
- * the programmer to define Reserved Words, Symbols and parsers for literals,
- * allowing the programmer to fine tune the way the syntax should look.
- */
- foreach ($this->modules as $module) {
- /*
- * Check if the module can start tokenizing the string.
- */
- $r = $module->in($buf);
-
- /*
- * In case the module was unable to extract anything, we will skip
- * to the next module.
- */
- if (!$r) { continue; }
-
- $ret[] = $r;
-
- /*
- * If the module worked, and extracted data out of the string, then
- * we do not continue looping over the other modules, and instead
- * jump back to the while loop.
- */
- continue 2;
- }
-
- throw new PrivateException(sprintf('Unexpected character "%s" at offset %d', $buf->peek(), $buf->seek()), 190617);
- }
-
- $ret[] = new EndOfFile();
-
- return array_values(array_filter($ret, function ($e) { return !$e instanceof WhiteSpace && !empty($e); }));
- }
-
-}
diff --git a/core/parser/Scope.php b/core/parser/Scope.php
deleted file mode 100644
index d72c80c..0000000
--- a/core/parser/Scope.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php namespace spitfire\core\parser;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class Scope
-{
-
- private $prototype = null;
- private $vars = [];
-
- public function __construct($prototype = null) {
- $this->prototype = $prototype;
- }
-
- public function set($var, $to) {
- $this->vars[$var] = $to;
- }
-
- public function get($var) {
-
- if (array_key_exists($var, $this->vars)) {
- return $this->vars[$var];
- }
-
- elseif ($this->prototype) {
- return $this->prototype->get($var);
- }
-
- else {
- trigger_error('Undefined variable ' . $var, E_USER_NOTICE);
- return null;
- }
-
- }
-
-}
diff --git a/core/parser/StringBuffer.php b/core/parser/StringBuffer.php
deleted file mode 100644
index ee2ab8a..0000000
--- a/core/parser/StringBuffer.php
+++ /dev/null
@@ -1,145 +0,0 @@
-<?php namespace spitfire\core\parser;
-
-use BadMethodCallException;
-use spitfire\core\parser\StringBuffer;
-use spitfire\exceptions\OutOfBoundsException;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * The string buffer is intended to make it easy for applications to manipulate
- * the contents of a string. Spitfire uses this to navigate and lex a string that
- * it's tokenizing.
- *
- * The advantage of a dedicated buffer compared to direct operations on the is that
- * we do not have to edit the string while reading it. When using strings and
- * just consuming them, the system will have to allocate new memory for every
- * operation.
- *
- * @author César de la Cal Bretschneider <cesar@magic3w.com>
- */
-class StringBuffer
-{
-
- /**
- * Indicates where on the string the application has sseked to. By default this
- * will be the first index (0) of the string.
- */
- private $pointer = 0;
-
- /**
- * The string the application is operating on. This string is immutable, this
- * allows the application to take advantage of the reduced amount of memory
- * copy operations.
- */
- private $string;
-
-
- public function __construct(string$string) {
- $this->string = $string;
- }
-
- /**
- * Moves the pointer to the indicated position. If no argument is given, the
- * application will return the current pointer position.
- *
- * @param int $pos
- * @return int The old pointer position.
- */
- public function seek(int$pos = null) {
- $old = $this->pointer;
-
- if ($pos !== null) { $this->pointer = $pos; }
- if ($pos < 0) { throw new BadMethodCallException('Seek cannot be negative', 2002191830); }
- if (!isset($this->string[$pos])) { throw new BadMethodCallException('Seeked beyond the end of the string', 2002191834); }
-
- return $old;
- }
-
- public function fastforward($amt = 1) {
- $this->pointer+= $amt;
- }
-
- public function peek($amt = 1, $offset = 0) {
- return substr($this->string, $this->pointer + $offset, $amt);
- }
-
- public function read($amt = 1) {
- $ret = substr($this->string, $this->pointer, $amt);
- $this->pointer += $amt;
- return $ret;
- }
-
- /**
- *
- *
- * @param string $char (single character)
- * @param string $escape (single character)
- * @return string
- * @throws OutOfBoundsException
- */
- public function readUntil($char, $escape = null) {
- $old = $this->pointer;
- $cur = $this->pointer;
-
- while(true) {
- /*
- * The application is not allowed to read past the end. But this is not
- * considered normal behavior
- */
- if (!isset($this->string[$cur])) {
- throw new OutOfBoundsException('Reached past the end');
- }
-
- if ($escape && $escape == $this->string[$cur]) {
- $cur+= 2;
- continue;
- }
-
- /*
- * If the current element is the character we're looking for AND not prefixed
- * by our escape character
- */
- if ($this->string[$cur] == $char) {
- break;
- }
-
- $cur++;
- }
-
- $ret = substr($this->string, $old, $cur - $old);
- $this->pointer = $cur;
- return $ret;
- }
-
- public function slack() {
- return new StringBuffer(substr($this->string, $this->pointer));
- }
-
- public function hasMore() {
- return isset($this->string[$this->pointer ]);
- }
-
-}
diff --git a/core/parser/TokenBuffer.php b/core/parser/TokenBuffer.php
deleted file mode 100644
index b781120..0000000
--- a/core/parser/TokenBuffer.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php namespace spitfire\core\parser;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class TokenBuffer
-{
-
- private $tokens;
- private $cursor;
-
- public function __construct($tokens) {
- $this->tokens = $tokens;
- $this->cursor = 0;
- }
-
- public function fastforward($amt = 1) {
- $this->cursor+= $amt;
- return $this;
- }
-
- public function seek($pos = null) {
- $old = $this->cursor;
- if ($pos !== null) { $this->cursor = $pos; }
- return $old;
- }
-
-
- public function peek($offset = 0) {
-
- if (!array_key_exists($this->cursor + $offset, $this->tokens)) {
- return null;
- }
-
- return $this->tokens[$this->cursor + $offset];
- }
-
- public function read() {
-
- if (!array_key_exists($this->cursor, $this->tokens)) {
- return null;
- }
-
- $_ret = $this->tokens[$this->cursor];
- $this->cursor++;
- return $_ret;
- }
-}
diff --git a/core/parser/lexemes/EndOfFile.php b/core/parser/lexemes/EndOfFile.php
deleted file mode 100644
index f6d9d70..0000000
--- a/core/parser/lexemes/EndOfFile.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php namespace spitfire\core\parser\lexemes;
-
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * The end of file is a really simple lexeme, it basically indicates that the
- * scanner had no more content to read, appending this lexeme so the parser can
- * actually expect the end of file after it parsed the output from the lexer.
- *
- * This follows a recommendation from the booking craftinginterpreters.com that
- * pointed out that it would then be far easier to build the parser tree.
- *
- * @author César de la Cal Bretschneider <cesar@magic3w.com>
- */
-class EndOfFile implements LexemeInterface
-{
-
- /**
- * Obviously, the end of a file is an empty string - it has no content, and it's
- * presence indicates that the scanner is done.
- *
- * @return string
- */
- public function getBody(): string {
- return '';
- }
-
- /**
- * Sometimes it's very interesting to print the output from the lexer (specially
- * when debugging)
- *
- * @return string
- */
- public function __toString() {
- return '__EOF__';
- }
-
-}
diff --git a/core/parser/lexemes/Identifier.php b/core/parser/lexemes/Identifier.php
deleted file mode 100644
index a539117..0000000
--- a/core/parser/lexemes/Identifier.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php namespace spitfire\core\parser\lexemes;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * An identifier is a lexeme that identifies a user defined variable or function
- * name. In this context, anything that is not white-space, and matches a standard
- * function / variable naming expression will be used.
- *
- * Please note that the system requires all identifiers to have valid names. In
- * case your application contains identifiers like fully qualified names (\my\ClassName)
- * you will be required to construct this by indicating to the system that a class
- * identifier can be constructed by adding multiple identifiers together.
- *
- * @author César de la Cal Bretschneider <cesar@magic3w.com>
- */
-class Identifier implements LexemeInterface
-{
-
- private $name;
-
- /**
- * Creates the identifier.
- *
- * @param string $name
- */
- public function __construct($name = null) {
- $this->name = $name;
- }
-
- /**
- * Returns the content of the identifier. This will be the name of the variable
- * / function / class / whatever inside your language.
- *
- * @return string
- */
- public function getBody(): string {
- return $this->name;
- }
-
- /**
- * In the event of printing out the Identifier, we're printing it as a representation
- * that will make sense within the other output of the lexer.
- *
- * @return string
- */
- public function __toString() {
- return sprintf('val(%s)', strval($this->name));
- }
-
-}
diff --git a/core/parser/lexemes/LexemeInterface.php b/core/parser/lexemes/LexemeInterface.php
deleted file mode 100644
index 68ba1c4..0000000
--- a/core/parser/lexemes/LexemeInterface.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php namespace spitfire\core\parser\lexemes;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * Every expression that a scanner reads, results in a series of lexemes that can
- * later be analyzed by the parser.
- */
-interface LexemeInterface
-{
-
- function getBody() : string;
-}
diff --git a/core/parser/lexemes/Literal.php b/core/parser/lexemes/Literal.php
deleted file mode 100644
index 69b4dc0..0000000
--- a/core/parser/lexemes/Literal.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php namespace spitfire\core\parser\lexemes;
-
-/*
- * The MIT License
- *
- * Copyright 2018 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/*
- * A literal contains a predefined string. This means that the user provided the
- * application with predefined data.
- */
-class Literal implements LexemeInterface
-{
-
- private $body = null;
-
-
- public function __construct($body) {
- $this->body = $body;
- }
-
- public function getBody(): string {
- return $this->body;
- }
-
- public function __toString() {
- return '###' . $this->body . '###';
- }
-
-}
diff --git a/core/parser/lexemes/ReservedWord.php b/core/parser/lexemes/ReservedWord.php
deleted file mode 100644
index 6b84694..0000000
--- a/core/parser/lexemes/ReservedWord.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php namespace spitfire\core\parser\lexemes;
-
-use spitfire\core\parser\scanner\ScannerModuleInterface;
-use spitfire\core\parser\StringBuffer;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * As opposed to a symbol, the reserved word expects to be separated by white-space.
- */
-class ReservedWord implements LexemeInterface, ScannerModuleInterface
-{
-
- private $literal;
-
-
- public function __construct($literal) {
- $this->literal = $literal;
- }
-
- public function getBody() : string {
- return $this->literal;
- }
-
- public function in(StringBuffer $buffer): ?LexemeInterface {
-
- if ($buffer->peek(strlen($this->literal)) != $this->literal) {
- return null;
- }
-
- $next = $buffer->peek(strlen($this->literal), 1);
-
- if (ctype_alnum($next)) {
- return null;
- }
-
- $buffer->fastforward(strlen($this->literal) + 1);
- return $this;
- }
-
- public function __toString() {
- return $this->literal;
- }
-
-}
diff --git a/core/parser/lexemes/Symbol.php b/core/parser/lexemes/Symbol.php
deleted file mode 100644
index 25c1fd7..0000000
--- a/core/parser/lexemes/Symbol.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php namespace spitfire\core\parser\lexemes;
-
-use spitfire\core\parser\scanner\ScannerModuleInterface;
-use spitfire\core\parser\StringBuffer;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * The main difference between symbols and reserved words, is that the tokenizer
- * will search for symbols as breaking characters, while reserved words will be
- * only matched if they are properly delimited.
- */
-class Symbol implements LexemeInterface, ScannerModuleInterface
-{
-
- private $literal;
-
-
- public function __construct($literal) {
- $this->literal = $literal;
- }
-
- public function getBody() : string {
- return $this->literal;
- }
-
- public function in(StringBuffer $buffer): ?LexemeInterface {
-
- if ($buffer->peek(1) === $this->literal) {
- $buffer->read();
- return $this;
- }
- else {
- return null;
- }
- }
-
- public function __toString() {
- return sprintf('sym(%s)', strval($this->literal));
- }
-
-}
diff --git a/core/parser/lexemes/WhiteSpace.php b/core/parser/lexemes/WhiteSpace.php
deleted file mode 100644
index 7c4a416..0000000
--- a/core/parser/lexemes/WhiteSpace.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php namespace spitfire\core\parser\lexemes;
-
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class WhiteSpace implements LexemeInterface
-{
-
- public function getBody(): string {
- return '';
- }
-
-}
diff --git a/core/parser/parser/Block.php b/core/parser/parser/Block.php
deleted file mode 100644
index 16d30be..0000000
--- a/core/parser/parser/Block.php
+++ /dev/null
@@ -1,125 +0,0 @@
-<?php namespace spitfire\core\parser\parser;
-
-use spitfire\core\parser\lexemes\LexemeInterface;
-use spitfire\core\parser\TokenBuffer;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class Block
-{
- private $matches = [];
-
- private $operation;
-
- public $name = 'undefined';
-
- public function matches() {
- $args = func_get_args();
- $this->matches = $args;
- }
-
- public function matchesArray($a) {
- $this->matches = $a;
- }
-
- public function test(TokenBuffer$tokens) {
-
- $found = [];
-
- /*
- * Loop over the matches and see if we can extract anything of value
- */
- foreach ($this->matches as $rule) {
-
-
- /*
- * If another block is the child, we will first descend into it. If it
- * returns false, then the block did not match, and therefore ours won't
- * either.
- *
- * On the other hand, if the block did match, then we will put it's result
- * into found, and continue parsing.
- */
- if ($rule instanceof Block || $rule instanceof Either || $rule instanceof Multiple || $rule instanceof Optional) {
-
- $r = $rule->test($tokens);
-
- if ($r === false) { return false; }
- else { $found[] = $r; }
-
- }
-
- elseif ($rule instanceof LexemeInterface) {
- if ($rule === $tokens->peek()) { $found[] = $tokens->read(); }
- else { return false; }
- }
-
- elseif ($rule instanceof TerminalInterface) {
- if ($rule->test($tokens->peek())) { $found[] = $rule->get($tokens->read()); }
- else { return false; }
- }
- }
-
-
- $r = new ParseTree($this, $found);
- return $r;
- }
-
- public function children() {
- return $this->matches;
- }
-
- public function does($fn) {
- $this->operation = $fn;
- return $this;
- }
-
- public function operate($leaf, $scope) {
- return ($this->operation)($leaf, $scope);
- }
-
- public function __toString() {
- return 'block';
- }
-
- public static function either() {
- $args = func_get_args();
- return new Either($args);
- }
-
- public static function optional() {
- $args = func_get_args();
- $opt = new Optional();
- $opt->matchesArray($args);
- return $opt;
- }
-
- public static function multiple() {
- $args = func_get_args();
- $opt = new Multiple();
- $opt->matchesArray($args);
- return $opt;
- }
-}
\ No newline at end of file
diff --git a/core/parser/parser/Either.php b/core/parser/parser/Either.php
deleted file mode 100644
index 2b0630c..0000000
--- a/core/parser/parser/Either.php
+++ /dev/null
@@ -1,111 +0,0 @@
-<?php namespace spitfire\core\parser\parser;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * Allows an abstract syntax tree parser builder to create a parser that accepts
- * multiple syntax for a certain expression.
- *
- * This is an anonymous block, meaning it does not provide any logic to interpret
- * the results from the parsed syntax. The block above it will be required to make
- * a distinction between the results given by this block.
- *
- * @author César de la Cal Bretschneider <cesar@magic3w.com>
- */
-class Either
-{
-
- /**
- * The blocks that this relies on to perform the parsing. Please note that if
- * the application has multiple matches for a tokenbuffer, the first match
- * will be considered.
- *
- * @var \spitfire\collection\DefinedCollection < Block >
- */
- private $blocks;
-
- /**
- * Create an either-block. This block will accept rules for multiple blocks
- * and whenever it's test() method is invoked it will attempt to match one of
- * them.
- *
- * @param mixed $a Array of arrays containing terminals or blocks
- */
- public function __construct($a) {
- $this->blocks = collect($a)->each(function ($e) {
- $block = new Block();
- $block->matchesArray($e);
- return $block;
- } );
- }
-
- /**
- * Unlike "regular" blocks, either will return an array so that the parent can
- * merge it into the other blocks.
- *
- * Just like regular blocks, this mechanism will consume the buffer, which means
- * that it will be modified if the parse succeeds.
- *
- * @param \spitfire\core\parser\TokenBuffer $tokens A tokenbuffer to consume
- * @return boolean
- */
- public function test($tokens) {
- $blocks = clone($this->blocks);
-
- foreach ($blocks as $block) {
- $res = $block->test($tokens);
-
- if ($res) {
- /*
- * Depending on whether the descendant returned an array or a ParseTree,
- * we will strip it out so it can be flattened into the parent.
- *
- * This means that these anonymous blocks are not referred to when evaluating
- * the tree and are transparent to the developer. This means that these
- * anon bocks are also unable to provide any functionality and therefore
- * need to have their logic shifted to their parent.
- *
- * For example, the code
- * block(either(private, public), function, reservedword...)
- *
- * Will have to have the logic to determine whether the first block is
- * either private or public.
- */
- return is_array($res)? $res : $res->getLeafs();
- }
- }
-
- return false;
- }
-
- public function children() {
- return $this->blocks;
- }
-
- public function __toString() {
- return sprintf('either:');
- }
-
-}
diff --git a/core/parser/parser/IdentifierTerminal.php b/core/parser/parser/IdentifierTerminal.php
deleted file mode 100644
index e6f2042..0000000
--- a/core/parser/parser/IdentifierTerminal.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php namespace spitfire\core\parser\parser;
-
-use spitfire\core\parser\lexemes\Identifier;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class IdentifierTerminal implements TerminalInterface
-{
-
- public function get($token) {
- return $token;
- }
-
- public function test($token) {
- return $token instanceof Identifier;
- }
-
- public function children() {
- return [];
- }
-
- public function __toString() {
- return 'Identifier';
- }
-
-}
diff --git a/core/parser/parser/LiteralTerminal.php b/core/parser/parser/LiteralTerminal.php
deleted file mode 100644
index f065574..0000000
--- a/core/parser/parser/LiteralTerminal.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php namespace spitfire\core\parser\parser;
-
-use spitfire\core\parser\lexemes\Literal;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class LiteralTerminal implements TerminalInterface
-{
-
- public function get($token) {
- return $token;
- }
-
- public function test($token) {
- return $token instanceof Literal;
- }
-
- public function children() {
- return [];
- }
-
- public function __toString() {
- return 'Literal';
- }
-
-}
diff --git a/core/parser/parser/Multiple.php b/core/parser/parser/Multiple.php
deleted file mode 100644
index 49c5329..0000000
--- a/core/parser/parser/Multiple.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php namespace spitfire\core\parser\parser;
-
-use spitfire\core\parser\TokenBuffer;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * A multiple block allows an application to consume multiple blocks in a greedy
- * fashion, it can be used to construct statements like or statements, where an
- * expression is followed by multiple combinations of pipes and expressions.
- *
- * @author César de la Cal Bretschneider <cesar@magic3w.com>
- */
-class Multiple extends Block
-{
-
- /**
- * The multiple block will return a "shallow" array of the results of multiple
- * iterations of the same Block being executed on a token buffer.
- *
- * Basically, this block will consume from the buffer until the block it wraps
- * can no longer match.
- *
- * @param TokenBuffer $tokens
- * @return mixed
- */
- public function test(TokenBuffer$tokens) {
- $_ret = [];
-
- while ($res = parent::test($tokens)) {
- $_ret[] = is_array($res)? $res : $res->getLeafs();
- }
-
- return !empty($_ret)? $_ret : false;
- }
-
- public function __toString() {
- return parent::__toString() . '+';
- }
-
-}
diff --git a/core/parser/parser/Optional.php b/core/parser/parser/Optional.php
deleted file mode 100644
index 5fa6216..0000000
--- a/core/parser/parser/Optional.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php namespace spitfire\core\parser\parser;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * The optional shallow-block allows the application to define a segment of the
- * buffer that may be present but may also not be. A typical example for this
- * would be the type modifiers for PHP functions where:
- *
- * reserved(function) identifier symbol(() optional(modifier(type)) modifier(variablename) optional(multiple(...)) symbol())
- *
- * We could use these blocks to identify that the type may, or may not, be present
- * in your expression.
- */
-class Optional extends Block
-{
-
- /**
- * Test whether the buffer contains the block this inherits from, unlike a
- * regular block, an empty result will not lead to the parser failing, but the
- * block being skipped and it's result set to null.
- *
- * @param type $tokens
- * @return boolean
- */
- public function test($tokens) {
- $res = parent::test($tokens);
-
- /*
- * This is a shallow-block, meaning that the leafs are passed as an array
- * to the parent instead of a parse tree.
- */
- if ($res) {
- return $res->getLeafs();
- }
-
- /*
- * Unlike a regular block, this result will be null.
- */
- return null;
- }
-
- public function __toString() {
- return 'optional';
- }
-
-}
diff --git a/core/parser/parser/ParseTree.php b/core/parser/parser/ParseTree.php
deleted file mode 100644
index 6fe7c05..0000000
--- a/core/parser/parser/ParseTree.php
+++ /dev/null
@@ -1,114 +0,0 @@
-<?php namespace spitfire\core\parser\parser;
-
-use spitfire\core\parser\Scope;
-use function collect;
-use function console;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * The parse tree is a class that creates a link between a block and the result
- * it produces.
- *
- * When defining a block, you also provide an optional callable to the does() method,
- * which allows the application to (in combination with scopes) make modifications
- * to the scope and generate a result.
- *
- * In essence, the parse tree is the result from the parsing and will allow you
- * to "execute" the parsed expression.
- *
- * @author César de la Cal Bretschneider <cesar@magic3w.com>
- */
-class ParseTree
-{
-
- /**
- * The block that this parse tree was generated by.
- *
- * @var Block
- */
- private $block;
-
- /**
- * Contains the result of the block parsing the token buffer. This will contain
- * lexemes from the scanner.
- *
- * @var mixed[]
- */
- private $leafs = [];
-
- /**
- * Creates a new parse tree.
- *
- * @param Block $block
- * @param type $nodes
- */
- public function __construct(Block$block, $nodes) {
- $this->block = $block;
- $this->leafs = $nodes;
- }
-
- public function getBlock() {
- return $this->block;
- }
-
- public function getLeafs() {
- return $this->leafs;
- }
-
- public function setBlock($block) {
- $this->block = $block;
- return $this;
- }
-
- public function setLeafs($nodes) {
- $this->leafs = $nodes;
- return $this;
- }
-
- /**
- * Allows the user to "execute" the parse tree. This method returns whatever
- * the block's does() method returns.
- *
- * @param Scope $context
- * @return mixed
- */
- public function resolve(Scope$context) {
- return $this->block->operate($this, $context);
- }
-
- public function stringify($offset = 0) {
- $leafs = collect($this->leafs);
-
- return str_repeat(' ', $offset) . sprintf('branch(%s - %s - %s)%s%s', count($this->leafs), $this->block->name, get_class($this->block), PHP_EOL, $leafs->each(function ($e) use ($offset) {
- return $e instanceof ParseTree? $e->stringify($offset + 4) : str_repeat(' ', $offset + 4) . $e;
- })->join(PHP_EOL));
- }
-
- public function __toString() {
- return $this->stringify();
- }
-
-}
diff --git a/core/parser/parser/Parser.php b/core/parser/parser/Parser.php
deleted file mode 100644
index dcaaa89..0000000
--- a/core/parser/parser/Parser.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php namespace spitfire\core\parser\parser;
-
-use spitfire\core\parser\TokenBuffer;
-use spitfire\exceptions\PrivateException;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class Parser
-{
-
- /**
- *
- * @var Block
- */
- private $root;
-
- public function __construct($root) {
- $this->root = $root;
- }
-
- public function parse($tokens) {
-
- $buffer = new TokenBuffer($tokens);
- $res = $this->root->test($buffer);
-
- if ($buffer->peek(1) !== null) { throw new PrivateException('Extraneous data at the end of buffer'); }
-
- return $res;
-
- }
-
-}
diff --git a/core/parser/parser/ReservedWordTerminal.php b/core/parser/parser/ReservedWordTerminal.php
deleted file mode 100644
index 9706afb..0000000
--- a/core/parser/parser/ReservedWordTerminal.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php namespace spitfire\core\parser\parser;
-
-use spitfire\core\parser\lexemes\Symbol;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class ReservedWordTerminal implements TerminalInterface
-{
-
- private $symbol;
-
- public function __construct($symbol) {
- $this->symbol = $symbol;
- }
-
- public function get($token) {
- return $token;
- }
-
- public function test($token) {
- return $token instanceof \spitfire\core\parser\lexemes\ReservedWord && $this->symbol === $token;
- }
-
- public function children() {
- return [];
- }
-
- public function __toString() {
- return 'Reserved Word';
- }
-
-}
diff --git a/core/parser/parser/SymbolTerminal.php b/core/parser/parser/SymbolTerminal.php
deleted file mode 100644
index aed3965..0000000
--- a/core/parser/parser/SymbolTerminal.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php namespace spitfire\core\parser\parser;
-
-use spitfire\core\parser\lexemes\Symbol;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class SymbolTerminal implements TerminalInterface
-{
-
- private $symbol;
-
- public function __construct($symbol) {
- $this->symbol = $symbol;
- }
-
- public function get($token) {
- return $token;
- }
-
- public function test($token) {
- return $token instanceof Symbol && $this->symbol === $token;
- }
-
- public function children() {
- return [];
- }
-
- public function __toString() {
- return 'Symbol';
- }
-
-}
diff --git a/core/parser/parser/TerminalInterface.php b/core/parser/parser/TerminalInterface.php
deleted file mode 100644
index aa1f943..0000000
--- a/core/parser/parser/TerminalInterface.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php namespace spitfire\core\parser\parser;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * A terminal represents a parser entity (token) that cannot be descended into,
- * it basically provides a stop to recursion in an abstract syntax tree.
- */
-interface TerminalInterface
-{
-
- function test($token);
- function get($token);
-}
\ No newline at end of file
diff --git a/core/parser/printer/Context.php b/core/parser/printer/Context.php
deleted file mode 100644
index b2acf13..0000000
--- a/core/parser/printer/Context.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php namespace spitfire\core\parser\printer;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * Provides context so the system does not print recursive statements.
- */
-class Context
-{
-
- private $scanned;
-
- public function __construct() {
- $this->scanned = collect();
- }
-
- public function add($e) {
- $this->scanned->push($e);
- }
-
- public function contains($e) {
- return $this->scanned->contains($e);
- }
-
- public function __clone() {
- $this->scanned = clone $this->scanned;
- }
-
-
-}
\ No newline at end of file
diff --git a/core/parser/printer/Printer.php b/core/parser/printer/Printer.php
deleted file mode 100644
index 8fa811b..0000000
--- a/core/parser/printer/Printer.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php namespace spitfire\core\parser\printer;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class Printer
-{
-
- public function print(\spitfire\core\parser\parser\Block$block) {
- $context = new Context();
- $this->descend($block, $context);
- }
-
- private function descend($block, Context$context, $level = 0) {
-
- $context = clone $context;
- $context->add($block);
-
- if (is_string($block)) {
- echo sprintf('%s *string*%s%s', str_repeat(' ', $level), $block, PHP_EOL);
- return;
- }
-
- if ($block instanceof \spitfire\core\parser\lexemes\LexemeInterface) {
- echo sprintf('%s %s%s', str_repeat(' ', $level), $block, PHP_EOL);
- return;
- }
-
- echo str_repeat(' ', $level) . $block . PHP_EOL;
-
- foreach ($block->children() as $e) {
- if ($context->contains($e)) {
- echo sprintf('%s **recursion %s**%s', str_repeat(' ', $level + 1), $block, PHP_EOL);
- }
- else {
- $this->descend($e, $context, $level + 1);
- }
- }
- }
-
-}
\ No newline at end of file
diff --git a/core/parser/scanner/IdentifierScanner.php b/core/parser/scanner/IdentifierScanner.php
deleted file mode 100644
index 9b19441..0000000
--- a/core/parser/scanner/IdentifierScanner.php
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php namespace spitfire\core\parser\scanner;
-
-use spitfire\core\parser\lexemes\Identifier;
-use spitfire\core\parser\lexemes\LexemeInterface;
-use spitfire\core\parser\StringBuffer;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * The identifier scanner allows applications to search for variable, function or
- * class names within source code. The common restriction to these is that they
- * must begin with a letter and be followed by either more letters, numbers or
- * underscores.
- *
- * While this potentially limits the functionality of our parser, it also greatly
- * increases the speed with which we can create expression parsers which is ultimately
- * the goal for this tool.
- *
- * @author César de la Cal Bretschneider <cesar@magic3w.com>
- */
-class IdentifierScanner implements ScannerModuleInterface
-{
-
- /**
- * Reads from a string buffer, the string buffer is modified when being consumed.
- *
- * @param StringBuffer $buffer
- * @return LexemeInterface|null
- */
- public function in(StringBuffer $buffer): ?LexemeInterface {
-
- $next = $buffer->peek();
-
- /*
- * If the first character is indeed a character, we will continue
- */
- if (!preg_match('/[a-zA-Z]/i', $next)) { return null; }
-
- $matched = $buffer->read();
-
- while (preg_match('/[A-Za-z_0-9]/', $buffer->peek())) {
- $matched.= $buffer->read();
- }
-
- return new Identifier($matched);
-
- }
-
-}
diff --git a/core/parser/scanner/IntegerLiteralScanner.php b/core/parser/scanner/IntegerLiteralScanner.php
deleted file mode 100644
index 1a5342e..0000000
--- a/core/parser/scanner/IntegerLiteralScanner.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php namespace spitfire\core\parser\scanner;
-
-use spitfire\core\parser\lexemes\LexemeInterface;
-use spitfire\core\parser\lexemes\Literal;
-use spitfire\core\parser\scanner\ScannerModuleInterface;
-use spitfire\core\parser\StringBuffer;
-use spitfire\exceptions\PrivateException;
-
-/*
- * The MIT License
- *
- * Copyright 2018 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-class IntegerLiteralScanner implements ScannerModuleInterface
-{
-
-
- private $body = null;
-
-
- public function setBody($body): Literal {
- $this->body = $body;
- return $this;
- }
-
- public function getBody(): string {
- return $this->body;
- }
-
- public function in(StringBuffer $buffer): ?LexemeInterface {
-
- $next = $buffer->peek();
- $matched = '';
-
- /*
- * If the first character is indeed a character, we will continue
- */
- if (!preg_match('/[0-9\.]/i', $next)) { return null; }
-
- while (preg_match('/[0-9\.]/', $buffer->peek())) {
- $matched.= $buffer->read();
- }
-
- if (preg_match('/[\p{L}]/i', $buffer->peek())) {
- throw new PrivateException('Parse error', 2002251955);
- }
-
- return new Literal($matched);
-
- }
-
-}
diff --git a/core/parser/scanner/LiteralScanner.php b/core/parser/scanner/LiteralScanner.php
deleted file mode 100644
index 5d942e2..0000000
--- a/core/parser/scanner/LiteralScanner.php
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php namespace spitfire\core\parser\scanner;
-
-use spitfire\core\parser\lexemes\LexemeInterface;
-use spitfire\core\parser\lexemes\Literal;
-use spitfire\core\parser\scanner\ScannerModuleInterface;
-use spitfire\core\parser\StringBuffer;
-
-/*
- * The MIT License
- *
- * Copyright 2018 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-class LiteralScanner implements ScannerModuleInterface
-{
-
- private $open;
-
- private $close;
-
-
- public function __construct($open, $close) {
- $this->open = $open;
- $this->close = $close;
- }
-
- public function in(StringBuffer $buffer): ?LexemeInterface {
- /**
- * Check if the opening is present
- */
- if ($buffer->peek(strlen($this->open)) !== $this->open) {
- return null;
- }
-
- $pos = $buffer->seek();
-
- try {
- /*
- * Read the first character from thee sequence, we already know that it's
- * the appropriate character
- */
- $buffer->read();
- $_ret = new Literal(stripslashes($buffer->readUntil($this->close, '\\')));
-
- /*
- * The buffer doesn't consume the closing character when reading up to the
- * indicated character. We need to fetch it from the buffer
- */
- $buffer->read();
- return $_ret;
- }
- catch (\spitfire\exceptions\OutOfBoundsException$ex) {
- /*
- * Place the buffer back to it's original position
- */
- $buffer->seek($pos);
-
- /*
- * If the buffer is empty and we did not receive a return, then the string
- * is invalid.
- */
- return null;
- }
-
- }
-
-}
diff --git a/core/parser/scanner/ScannerModuleInterface.php b/core/parser/scanner/ScannerModuleInterface.php
deleted file mode 100644
index 522762e..0000000
--- a/core/parser/scanner/ScannerModuleInterface.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php namespace spitfire\core\parser\scanner;
-
-use spitfire\core\parser\lexemes\LexemeInterface;
-use spitfire\core\parser\StringBuffer;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-interface ScannerModuleInterface
-{
-
- function in(StringBuffer$buffer) : ?LexemeInterface;
-}
diff --git a/core/parser/scanner/WhiteSpaceScanner.php b/core/parser/scanner/WhiteSpaceScanner.php
deleted file mode 100644
index 99c3694..0000000
--- a/core/parser/scanner/WhiteSpaceScanner.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php namespace spitfire\core\parser\scanner;
-
-use spitfire\core\parser\lexemes\LexemeInterface;
-use spitfire\core\parser\lexemes\WhiteSpace;
-use spitfire\core\parser\scanner\ScannerModuleInterface;
-use spitfire\core\parser\StringBuffer;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class WhiteSpaceScanner implements ScannerModuleInterface
-{
-
- public function in(StringBuffer $buffer): ?LexemeInterface {
- $match = [' ', PHP_EOL, "\r", "\t"];
-
- if (in_array($buffer->peek(1), $match)) {
- $buffer->fastforward();
- return new WhiteSpace();
- }
-
- return null;
- }
-
-}
diff --git a/mvc/middleware/standard/ValidationMiddleware.php b/mvc/middleware/standard/ValidationMiddleware.php
index 9a6eba7..ad6cd23 100644
--- a/mvc/middleware/standard/ValidationMiddleware.php
+++ b/mvc/middleware/standard/ValidationMiddleware.php
@@ -1,79 +1,79 @@
<?php namespace spitfire\mvc\middleware\standard;
use spitfire\collection\Collection;
+use spitfire\ast\Scope;
use spitfire\core\ContextCLI;
use spitfire\core\ContextInterface;
use spitfire\core\Response;
-use spitfire\exceptions\PublicException;
use spitfire\validation\ValidationException;
use spitfire\mvc\middleware\MiddlewareInterface;
use spitfire\validation\parser\Parser;
/*
* The MIT License
*
* Copyright 2018 César de la Cal Bretschneider <cesar@magic3w.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
class ValidationMiddleware implements MiddlewareInterface
{
public function before(ContextInterface $context) {
$expressions = $context->annotations['validate']?? null;
$parser = new Parser();
$context->validation = new Collection();
if (!$expressions) {
return;
}
foreach ($expressions as $expression) {
$throw = true;
if(substr($expression, 0, 2) === '>>') {
$expression = substr($expression, 2);
$throw = false;
}
/*
* Create a context with the variables that we want to have within the
* expression's scope.
*/
- $scope = new \spitfire\core\parser\Scope();
+ $scope = new Scope();
$scope->set('GET', $_GET);
$scope->set('POST', $_POST);
$scope->set('ARGV', $context instanceof ContextCLI? $context->parameters : $context->object);
$result = $parser->parse($expression)->resolve($scope);
if (!empty($result)) {
if ($throw) { throw new ValidationException('Validation failed', 400, $result); }
$context->validation->add($result);
}
}
}
public function after(ContextInterface $context, Response $response = null) {
}
}
diff --git a/tests/core/parser/LexerTest.php b/tests/core/parser/LexerTest.php
deleted file mode 100644
index c94203d..0000000
--- a/tests/core/parser/LexerTest.php
+++ /dev/null
@@ -1,121 +0,0 @@
-<?php namespace tests\spitfire\core\parser;
-
-use PHPUnit\Framework\TestCase;
-use spitfire\core\parser\lexemes\Literal;
-use spitfire\core\parser\lexemes\ReservedWord;
-use spitfire\core\parser\lexemes\Symbol;
-use spitfire\core\parser\Lexer;
-use spitfire\core\parser\scanner\IdentifierScanner;
-use spitfire\core\parser\scanner\IntegerLiteralScanner;
-use spitfire\core\parser\scanner\LiteralScanner;
-use spitfire\core\parser\scanner\WhiteSpaceScanner;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class LexerTest extends TestCase
-{
-
- public function testBasicLexer() {
- $and = new ReservedWord('AND');
- $or = new ReservedWord('OR');
- $lit = new LiteralScanner('"', '"');
- $pop = new Symbol('(');
- $pcl = new Symbol(')');
- $com = new Symbol(',');
- $whs = new WhiteSpaceScanner();
- $ids = new IdentifierScanner();
- $nms = new IntegerLiteralScanner();
-
- $lex = new Lexer($and, $or, $lit, $pop, $pcl, $com, $whs, $ids, $nms);
- $res = $lex->tokenize('hello("crazy world", 1)');
-
- $this->assertEquals(7, count($res));
- $this->assertInstanceOf(Literal::class, $res[2]);
- $this->assertEquals('crazy world', $res[2]->getBody());
-
- }
-
- public function testBasicLexer2() {
- $lit = new LiteralScanner('"', '"');
- $pls = new Symbol('+');
- $mns = new Symbol('-');
- $eqs = new Symbol('=');
- $mul = new Symbol('*');
- $div = new Symbol('/');
- $whs = new WhiteSpaceScanner();
- $nms = new IntegerLiteralScanner();
-
- $lex = new Lexer($lit, $pls, $mns, $eqs, $mul, $div, $whs, $nms);
- $res = $lex->tokenize('3+1*5/6');
-
- $this->assertEquals(8, count($res));
- $this->assertEquals('1', $res[2]->getBody());
-
- }
-
- public function testBasicLexer3() {
- $lit = new LiteralScanner('"', '"');
- $pls = new Symbol('+');
- $mns = new Symbol('-');
- $eqs = new Symbol('=');
- $mul = new Symbol('*');
- $div = new Symbol('/');
- $whs = new WhiteSpaceScanner();
- $ids = new IdentifierScanner();
- $nms = new IntegerLiteralScanner();
-
- $lex = new Lexer($lit, $pls, $mns, $eqs, $mul, $div, $whs, $ids, $nms);
- $res = $lex->tokenize('3 + myval * 5 / 6');
-
- $this->assertEquals(8, count($res));
- $this->assertEquals('myval', $res[2]->getBody());
-
- }
-
- public function testBasicLexer4() {
- $and = new ReservedWord('AND');
- $or = new ReservedWord('OR');
- $lit = new LiteralScanner('"', '"');
- $pop = new Symbol('(');
- $pcl = new Symbol(')');
- $bop = new Symbol('[');
- $bcl = new Symbol(']');
- $com = new Symbol(',');
- $dot = new Symbol('.');
- $whs = new WhiteSpaceScanner();
- $ids = new IdentifierScanner();
- $nms = new IntegerLiteralScanner();
-
- $lex = new Lexer($and, $or, $lit, $pop, $pcl, $com, $dot, $whs, $bop, $bcl, $ids, $nms);
-
- $string = 'GET.input(string length[10,24] not["detail"]) OR POST.other(positive number)';
- $res = $lex->tokenize($string);
-
- $this->assertEquals(25, count($res));
- $this->assertEquals('input', $res[2]->getBody());
-
- }
-
-}
diff --git a/tests/core/parser/Parser2Test.php b/tests/core/parser/Parser2Test.php
deleted file mode 100644
index 6395fdc..0000000
--- a/tests/core/parser/Parser2Test.php
+++ /dev/null
@@ -1,178 +0,0 @@
-<?php namespace tests\spitfire\core\parser;
-
-use Exception;
-use PHPUnit\Framework\TestCase;
-use spitfire\core\parser\lexemes\Identifier;
-use spitfire\core\parser\lexemes\Literal;
-use spitfire\core\parser\lexemes\Symbol;
-use spitfire\core\parser\Lexer;
-use spitfire\core\parser\parser\Block;
-use spitfire\core\parser\parser\IdentifierTerminal;
-use spitfire\core\parser\parser\LiteralTerminal;
-use spitfire\core\parser\parser\Parser;
-use spitfire\core\parser\parser\ParseTree;
-use spitfire\core\parser\parser\SymbolTerminal;
-use spitfire\core\parser\scanner\IdentifierScanner;
-use spitfire\core\parser\scanner\IntegerLiteralScanner;
-use spitfire\core\parser\scanner\LiteralScanner;
-use spitfire\core\parser\scanner\WhiteSpaceScanner;
-use spitfire\core\parser\Scope;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class Parser2Test extends TestCase
-{
-
-
-
- public function testBasicParser() {
- $lit = new LiteralScanner('"', '"');
- $pls = new Symbol('+');
- $mns = new Symbol('-');
- $mul = new Symbol('*');
- $div = new Symbol('/');
- $not = new Symbol('!');
- $pop = new Symbol('(');
- $pcl = new Symbol(')');
- $whs = new WhiteSpaceScanner();
- $ids = new IdentifierScanner();
- $int = new IntegerLiteralScanner();
-
- $expression = new Block();
- $addition = new Block();
- $multiplication = new Block();
- $unary = new Block();
- $primary = new Block();
-
- $expression->matches($addition);
- $addition->matches($multiplication, Block::optional(Block::multiple(Block::either([$pls], [$mns]), $multiplication)));
-
- $multiplication->matches(
- $unary,
- Block::optional(Block::multiple(Block::either([new SymbolTerminal($mul)], [new SymbolTerminal($div)]), $unary))
- );
-
- $unary->matches(
- Block::either([new SymbolTerminal($not), $primary], [$primary])
- );
-
- $primary->matches(Block::either(
- [new IdentifierTerminal()],
- [new LiteralTerminal()],
- [new SymbolTerminal($pop), $expression, new SymbolTerminal($pcl)]
- )
- );
-
- $lex = new Lexer($lit, $pls, $mns, $mul, $div, $whs, $ids, $int, $not, $pop, $pcl);
- $parser = new Parser($expression);
-
- $res = $parser->parse($lex->tokenize('3 * myval + 5 / (1 + two * two) + 5'));
-
- $this->assertEquals(true, $res instanceof ParseTree);
- $this->assertEquals(1, count($res->getLeafs()));
-
-
- $expression->does(function ($leaf, $scope) {
- $previous = $leaf->getLeafs();
- return $previous[0]->resolve($scope);
- });
-
- $addition->does(function ($leaf, $scope) {
- list($left, $right) = $leaf->getLeafs();
-
- $left = $left->resolve($scope);
-
- if ($right === null) {
- return $left;
- }
-
- foreach ($right[0] as $next) {
- list($operator, $operand) = $next;
- $operand = $operand->resolve($scope);
-
- if ($operator[0]->getBody() === '+') { $left+= $operand; }
- else { $left-= $operand; }
- }
-
- return $left;
- });
-
- $multiplication->does(function ($leaf, $scope) {
- list($left, $right) = $leaf->getLeafs();
-
- $left = $left->resolve($scope);
-
- if ($right === null) {
- return $left;
- }
-
- foreach ($right[0] as $next) {
- list($operator, $operand) = $next;
- $operand = $operand->resolve($scope);
-
- if ($operator[0]->getBody() === '*') { $left*= $operand; }
- else { $left/= $operand; }
- }
-
- return $left;
- });
-
- $unary->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs();
-
- if (count($leafs[0]) == 2) {
- return !$leafs[0][1]->resolve($scope);
- } else {
- return $leafs[0][0]->resolve($scope);
- }
- });
-
- $primary->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs()[0];
-
- switch(count($leafs)) {
- case 1: // literal | identifier
- if ($leafs[0] instanceof Literal) { return $leafs[0]->getBody(); }
- if ($leafs[0] instanceof Identifier) {
- return $scope->get($leafs[0]->getBody());
- }
-
- throw new Exception('Unsupported operand');
- case 3: // (expression)
- return $leafs[1]->resolve($scope);
- }
- });
-
- //echo $res;
- //echo PHP_EOL;
- $scope = new Scope();
- $scope->set('myval', 10);
- $scope->set('two', 2);
- $out = $res->resolve($scope);
-
- $this->assertEquals(36, $out);
- }
-
-}
diff --git a/tests/core/parser/Parser3Test.php b/tests/core/parser/Parser3Test.php
deleted file mode 100644
index cebc478..0000000
--- a/tests/core/parser/Parser3Test.php
+++ /dev/null
@@ -1,226 +0,0 @@
-<?php namespace tests\spitfire\core\parser;
-
-use Exception;
-use PHPUnit\Framework\TestCase;
-use spitfire\core\parser\lexemes\Identifier;
-use spitfire\core\parser\lexemes\Literal as Literal2;
-use spitfire\core\parser\lexemes\ReservedWord;
-use spitfire\core\parser\lexemes\Symbol;
-use spitfire\core\parser\Lexer;
-use spitfire\core\parser\Literal;
-use spitfire\core\parser\parser\Block;
-use spitfire\core\parser\parser\IdentifierTerminal;
-use spitfire\core\parser\parser\LiteralTerminal;
-use spitfire\core\parser\parser\Parser;
-use spitfire\core\parser\parser\ParseTree;
-use spitfire\core\parser\printer\Printer;
-use spitfire\core\parser\scanner\IdentifierScanner;
-use spitfire\core\parser\scanner\IntegerLiteralScanner;
-use spitfire\core\parser\scanner\LiteralScanner;
-use spitfire\core\parser\scanner\WhiteSpaceScanner;
-use spitfire\core\parser\Scope;
-use spitfire\exceptions\PrivateException;
-use function collect;
-use function console;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class Parser3Test extends TestCase
-{
-
-
-
- public function testBasicParser() {
- $and = new ReservedWord('AND');
- $or = new ReservedWord('OR');
- $lit = new LiteralScanner('"', '"');
- $pop = new Symbol('(');
- $pcl = new Symbol(')');
- $bop = new Symbol('[');
- $bcl = new Symbol(']');
- $com = new Symbol(',');
- $ran = new Symbol('>');
- $dot = new Symbol('.');
- $whs = new WhiteSpaceScanner();
- $ids = new IdentifierScanner();
- $int = new IntegerLiteralScanner();
-
- $statement = new Block();
- $expression = new Block();
- $binaryand = new Block();
- $binaryor = new Block();
- $rule = new Block();
- $fnname = new Block();
- $arguments = new Block();
- $options = new Block();
-
-
- $statement->matches($binaryor);
- $binaryor->matches($binaryand, Block::optional(Block::multiple($or, $binaryand)));
- $binaryand->matches($expression, Block::optional(Block::multiple($and, $expression)));
-
- $expression->matches(Block::either([$rule], [$pop, $statement, $pcl]));
- $rule->matches($fnname, $pop, $arguments, $pcl);
- $fnname->matches(new IdentifierTerminal(), $dot, new IdentifierTerminal());
- $arguments->matches(Block::multiple(new IdentifierTerminal(), Block::optional($options)));
- $options->matches($bop, new LiteralTerminal(), Block::optional(Block::multiple($com, new LiteralTerminal())), $bcl);
-
-
- $lex = new Lexer($and, $or, $lit, $pop, $pcl, $com, $dot, $whs, $bop, $bcl, $ids, $int, $ran);
-
-
- $string = 'GET.input(string length[5, 24] not["detail"]) OR POST.other(positive number)';
- $parser = new Parser($statement);
-
- $statement->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs();
- return $leafs[0]->resolve($scope);
- });
-
- $binaryor->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs();
- $result = $leafs[0]->resolve($scope);
-
- if (!$leafs[1]) { return $result; }
-
- foreach ($leafs[1][0] as $op) {
- $result = $result || $op[1]->resolve($scope);
- }
-
- return $result;
- });
-
- $binaryand->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs();
- $result = $leafs[0]->resolve($scope);
-
- if (!$leafs[1]) { return $result; }
-
- foreach ($leafs[1][0] as $op) {
- $result = $result && $op[1]->resolve($scope);
- }
-
- return $result;
- });
-
- $expression->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs()[0];
- if (count($leafs) == 1) {
- return $leafs[0]->resolve($scope);
- }
-
- if (count($leafs) == 3) {
- return $leafs[1]->resolve($scope);
- }
-
- throw new Exception('Impossible condition reached');
- });
-
- $rule->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs();
- $fn = $leafs[0]->resolve($scope);
- $args = $leafs[2]->resolve($scope);
-
- $payload = $scope->get($fn[0])[$fn[1]]?? null;
- $pass = true;
-
- foreach ($args as $arg) {
- $pass = $pass && $arg($payload);
- }
-
- return $pass;
- });
-
- $fnname->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs();
- return [$leafs[0]->getBody(), $leafs[2]->getBody()];
- });
-
- $arguments->does(function ($leaf, $scope) {
- $fns = [
- 'not' => function ($args = []) { return function ($payload) use ($args) { return $payload !== $args[0]; }; },
- 'string' => function ($args = []) { return function ($payload) use ($args) { return is_string($payload); }; },
- 'positive' => function ($args = []) { return function ($payload) use ($args) { return $payload > 0; }; },
- 'number' => function ($args = []) { return function ($payload) use ($args) { return is_numeric($payload); }; },
- 'file' => function ($args = []) { return function ($payload) use ($args) { return $payload === 'file'; }; },
- 'something' => function ($args = []) { return function ($payload) use ($args) { return $payload === 'something'; }; },
- 's' => function ($args = []) { return function ($payload) use ($args) { return $payload === 's'; }; },
- 'else' => function ($args = []) { return function ($payload) use ($args) { return $payload === 'else'; }; },
- 'length' => function ($args = []) { return function ($payload) use ($args) { return strlen($payload) > $args[0] && strlen($payload) < $args[1] ; }; }
- ];
-
- $_ret = collect($leaf->getLeafs()[0])->each(function ($e) use ($fns, $scope) {
- list($argument, $options) = $e;
- $params = $options? collect($options)->each(function ($e) use ($scope) { return $e->resolve($scope); })->toArray() : [[]];
- return $fns[$argument->getBody()]($params[0]);
- })->toArray();
-
- return $_ret;
- });
-
- $options->does(function ($leaf, $scope) {
- $raw = $leaf->getLeafs();
-
- $clean = [$raw[1]->getBody()];
- $modifiers = $raw[2];
-
- //$options->matches($bop, new LiteralTerminal(), Block::optional(Block::multiple($com, new LiteralTerminal())), $bcl);
-
- if (!empty($modifiers)) {
- foreach ($modifiers[0] as $modifier) {
- $clean[] = $modifier[1]->getBody();
- }
- }
-
- return $clean;
- });
-
- $res = $parser->parse($lex->tokenize($string));
-
- $this->assertEquals(true, $res instanceof ParseTree);
- $this->assertEquals(1, count($res->getLeafs()));
-
- /*
- * Create a context with the variables that we want to have within the
- * expression's scope.
- */
- $scope = new Scope();
- $scope->set('GET', ['input' => 'testtesttest']);
- $scope->set('POST', ['other' => -35]);
-
- $scope2 = new Scope();
- $scope2->set('GET', ['input' => 'detail']);
- $scope2->set('POST', ['other' => -35]);
-
- $scope3 = new Scope();
- $scope3->set('GET', ['input' => 'detail']);
- $scope3->set('POST', ['other' => 35]);
-
- $this->assertEquals(true, $res->resolve($scope));
- $this->assertEquals(false, $res->resolve($scope2));
- $this->assertEquals(true, $res->resolve($scope3));
- }/**/
-
-}
diff --git a/tests/core/parser/ParserTest.php b/tests/core/parser/ParserTest.php
deleted file mode 100644
index 5ebd200..0000000
--- a/tests/core/parser/ParserTest.php
+++ /dev/null
@@ -1,211 +0,0 @@
-<?php namespace tests\spitfire\core\parser;
-
-use PHPUnit\Framework\TestCase;
-use spitfire\core\parser\lexemes\ReservedWord;
-use spitfire\core\parser\lexemes\Symbol;
-use spitfire\core\parser\Lexer;
-use spitfire\core\parser\parser\Block;
-use spitfire\core\parser\parser\IdentifierTerminal;
-use spitfire\core\parser\parser\LiteralTerminal;
-use spitfire\core\parser\parser\ParseTree;
-use spitfire\core\parser\printer\Printer;
-use spitfire\core\parser\scanner\IdentifierScanner;
-use spitfire\core\parser\scanner\IntegerLiteralScanner;
-use spitfire\core\parser\scanner\LiteralScanner;
-use spitfire\core\parser\scanner\WhiteSpaceScanner;
-use spitfire\core\parser\Scope;
-use spitfire\core\parser\parser\Parser;
-
-use Exception;
-
-/*
- * The MIT License
- *
- * Copyright 2019 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class ParserTest extends TestCase
-{
-
-
-
- public function testBasicParser() {
- $and = new ReservedWord('AND');
- $or = new ReservedWord('OR');
- $lit = new LiteralScanner('"', '"');
- $pop = new Symbol('(');
- $pcl = new Symbol(')');
- $bop = new Symbol('[');
- $bcl = new Symbol(']');
- $com = new Symbol(',');
- $ran = new Symbol('>');
- $dot = new Symbol('.');
- $whs = new WhiteSpaceScanner();
- $ids = new IdentifierScanner();
- $int = new IntegerLiteralScanner();
-
- $statement = new Block();
- $expression = new Block();
- $binaryand = new Block();
- $binaryor = new Block();
- $rule = new Block();
- $fnname = new Block();
- $arguments = new Block();
- $options = new Block();
-
-
- $statement->matches($binaryor);
- $binaryor->matches($binaryand, Block::optional(Block::multiple($or, $binaryand)));
- $binaryand->matches($expression, Block::optional(Block::multiple($and, $expression)));
-
- $expression->matches(Block::either([$rule], [$pop, $statement, $pcl]));
- $rule->matches($fnname, $pop, $arguments, $pcl);
- $fnname->matches(new IdentifierTerminal(), $dot, new IdentifierTerminal());
- $arguments->matches(Block::multiple(new IdentifierTerminal(), Block::optional($options)));
- $options->matches($bop, new LiteralTerminal(), Block::optional(Block::multiple($com, new LiteralTerminal())), $bcl);
-
-
- $lex = new Lexer($and, $or, $lit, $pop, $pcl, $com, $dot, $whs, $bop, $bcl, $ids, $int, $ran);
-
-
- $string = '(GET.input(string length[10, 24] not["detail"]) OR POST.other(positive number)) AND POST.test(file) OR t.s(something) AND t.i(s else["else"])';
- $parser = new Parser($statement);
-
-
- $statement->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs();
- return $leafs[0]->resolve($scope);
- });
-
- $binaryor->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs();
- $result = $leafs[0]->resolve($scope);
-
- if (!$leafs[1]) { return $result; }
-
- foreach ($leafs[1][0] as $op) {
- $result = $result || $op[1]->resolve($scope);
- }
-
- return $result;
- });
-
- $binaryand->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs();
- $result = $leafs[0]->resolve($scope);
-
- if (!$leafs[1]) { return $result; }
-
- foreach ($leafs[1][0] as $op) {
- $result = $result && $op[1]->resolve($scope);
- }
-
- return $result;
- });
-
- $expression->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs()[0];
- if (count($leafs) == 1) {
- return $leafs[0]->resolve($scope);
- }
-
- if (count($leafs) == 3) {
- return $leafs[1]->resolve($scope);
- }
-
- throw new Exception('Impossible condition reached');
- });
-
- $rule->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs();
- $fn = $leafs[0]->resolve($scope);
- $args = $leafs[2]->resolve($scope);
-
- $payload = $scope->get($fn[0])[$fn[1]]?? null;
- $pass = true;
-
- foreach ($args as $arg) {
- $pass = $pass && $arg($payload);
- }
-
- return $pass;
- });
-
- $fnname->does(function ($leaf, $scope) {
- $leafs = $leaf->getLeafs();
- return [$leafs[0]->getBody(), $leafs[2]->getBody()];
- });
-
- $arguments->does(function ($leaf, $scope) {
- $fns = [
- 'not' => function ($args = []) { return function ($payload) use ($args) { return $payload !== $args[0]; }; },
- 'string' => function ($args = []) { return function ($payload) use ($args) { return is_string($payload); }; },
- 'positive' => function ($args = []) { return function ($payload) use ($args) { return $payload > 0; }; },
- 'number' => function ($args = []) { return function ($payload) use ($args) { return is_numeric($payload); }; },
- 'file' => function ($args = []) { return function ($payload) use ($args) { return $payload === 'file'; }; },
- 'something' => function ($args = []) { return function ($payload) use ($args) { return $payload === 'something'; }; },
- 's' => function ($args = []) { return function ($payload) use ($args) { return $payload === 's'; }; },
- 'else' => function ($args = []) { return function ($payload) use ($args) { return $payload === 'else'; }; },
- 'length' => function ($args = []) { return function ($payload) use ($args) { return strlen($payload) > $args[0] && strlen($payload) < $args[1] ; }; }
- ];
-
- return collect($leaf->getLeafs()[0])->each(function ($e) use ($fns, $scope) {
- list($argument, $options) = $e;
-
- $params = $options? collect($options)->each(function ($e) use ($scope) { return $e->resolve($scope); })->toArray() : [[]];
- return $fns[$argument->getBody()]($params[0]);
-
- })->toArray();
- });
-
- $options->does(function ($leaf, $scope) {
- $raw = $leaf->getLeafs();
-
- $clean = [$raw[1]->getBody()];
- $modifiers = $raw[2];
-
- if (!empty($modifiers)) {
- foreach ($modifiers[0] as $modifier) {
- $clean[] = $modifier[1]->getBody();
- }
- }
-
- return $clean;
- });
-
- $res = $parser->parse($lex->tokenize($string));
-
- $this->assertEquals(true, $res instanceof ParseTree);
- $this->assertEquals(1, count($res->getLeafs()));
-
- /*
- * Create a context with the variables that we want to have within the
- * expression's scope.
- */
- $scope = new Scope();
- $scope->set('GET', ['input' => 'testtesttest']);
- $scope->set('POST', []);
- $scope->set('t', ['s' => 'something']);
-
- $res->resolve($scope);
- }/**/
-
-}
diff --git a/tests/core/parser/parser/BlockTest.php b/tests/core/parser/parser/BlockTest.php
deleted file mode 100644
index 923aceb..0000000
--- a/tests/core/parser/parser/BlockTest.php
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php namespace tests\spitfire\core\parser\parser;
-
-use PHPUnit\Framework\TestCase;
-
-/*
- * The MIT License
- *
- * Copyright 2020 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class BlockTest extends TestCase
-{
-
- /**
- * This test simulates the behavior the application would display when given
- * a (theoretical) basic function declaration like `function myfun(myval)` and
- * measures whether it properly parsed it.
- */
- public function testTest() {
-
- $fn = new \spitfire\core\parser\lexemes\ReservedWord('function');
- $pop = new \spitfire\core\parser\lexemes\Symbol('(');
- $pcl = new \spitfire\core\parser\lexemes\Symbol(')');
-
- $buffer = new \spitfire\core\parser\TokenBuffer([
- $fn,
- new \spitfire\core\parser\lexemes\Identifier('myfun'),
- $pop,
- new \spitfire\core\parser\lexemes\Identifier('myval'),
- $pcl
- ]);
-
- $block = new \spitfire\core\parser\parser\Block();
- $block->matches(
- new \spitfire\core\parser\parser\ReservedWordTerminal($fn),
- new \spitfire\core\parser\parser\IdentifierTerminal(),
- new \spitfire\core\parser\parser\SymbolTerminal($pop),
- new \spitfire\core\parser\parser\IdentifierTerminal(),
- new \spitfire\core\parser\parser\SymbolTerminal($pcl)
- );
-
- $result = $block->test($buffer);
- $this->assertInstanceOf(\spitfire\core\parser\parser\ParseTree::class, $result);
-
- $leafs = $result->getLeafs();
- $this->assertInstanceOf(\spitfire\core\parser\lexemes\ReservedWord::class, $leafs[0]);
- $this->assertInstanceOf(\spitfire\core\parser\lexemes\Identifier::class, $leafs[1]);
- $this->assertInstanceOf(\spitfire\core\parser\lexemes\Symbol::class, $leafs[2]);
-
- }
-
-}
diff --git a/tests/core/parser/parser/EitherTest.php b/tests/core/parser/parser/EitherTest.php
deleted file mode 100644
index 7580bb9..0000000
--- a/tests/core/parser/parser/EitherTest.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php namespace tests\spitfire\core\parser\parser;
-
-use PHPUnit\Framework\TestCase;
-
-/*
- * The MIT License
- *
- * Copyright 2020 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class EitherTest extends TestCase
-{
-
- public function testBasic() {
-
- $hello = new \spitfire\core\parser\lexemes\ReservedWord('hello');
- $world = new \spitfire\core\parser\lexemes\ReservedWord('world');
-
- $buffer1 = new \spitfire\core\parser\TokenBuffer([ $hello ]);
- $buffer2 = new \spitfire\core\parser\TokenBuffer([ $world ]);
- $buffer3 = new \spitfire\core\parser\TokenBuffer([ $hello, $world ]);
-
- $block = new \spitfire\core\parser\parser\Either([
- [ new \spitfire\core\parser\parser\ReservedWordTerminal($hello)],
- [ new \spitfire\core\parser\parser\ReservedWordTerminal($world)]
- ]);
-
- $r1 = $block->test($buffer1);
- $r2 = $block->test($buffer2);
- $r3 = $block->test($buffer3);
-
- $this->assertInstanceOf(\spitfire\core\parser\lexemes\ReservedWord::class, $r1[0]);
- $this->assertInstanceOf(\spitfire\core\parser\lexemes\ReservedWord::class, $r2[0]);
- $this->assertInstanceOf(\spitfire\core\parser\lexemes\ReservedWord::class, $r3[0]);
-
- }
-
-}
diff --git a/tests/core/parser/parser/IdentifierTerminalTest.php b/tests/core/parser/parser/IdentifierTerminalTest.php
deleted file mode 100644
index 9d0e2f8..0000000
--- a/tests/core/parser/parser/IdentifierTerminalTest.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php namespace tests\spitfire\core\parser\parser;
-
-use PHPUnit\Framework\TestCase;
-use spitfire\core\parser\lexemes\Identifier;
-use spitfire\core\parser\lexemes\Literal;
-use spitfire\core\parser\lexemes\ReservedWord;
-use spitfire\core\parser\parser\Block;
-use spitfire\core\parser\parser\IdentifierTerminal;
-use spitfire\core\parser\parser\ParseTree;
-use spitfire\core\parser\TokenBuffer;
-
-/*
- * The MIT License
- *
- * Copyright 2020 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class IdentifierTerminalTest extends TestCase
-{
-
- public function testParsing() {
- $buff1 = new TokenBuffer([new Identifier('test')]);
- $buff2 = new TokenBuffer([new ReservedWord('test')]);
- $buff3 = new TokenBuffer([new Literal('test')]);
-
- $terminal = new IdentifierTerminal();
-
- $block = new Block();
- $block->matches($terminal);
-
- $this->assertInstanceOf(ParseTree::class, $block->test($buff1));
- $this->assertEquals(false, $block->test($buff2));
- $this->assertEquals(false, $block->test($buff3));
- }
-
-}
diff --git a/tests/core/parser/parser/LiteralTerminalTest.php b/tests/core/parser/parser/LiteralTerminalTest.php
deleted file mode 100644
index 9ee31cb..0000000
--- a/tests/core/parser/parser/LiteralTerminalTest.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php namespace tests\spitfire\core\parser\parser;
-
-use PHPUnit\Framework\TestCase;
-use spitfire\core\parser\lexemes\Identifier;
-use spitfire\core\parser\lexemes\Literal;
-use spitfire\core\parser\lexemes\ReservedWord;
-use spitfire\core\parser\parser\Block;
-use spitfire\core\parser\parser\LiteralTerminal;
-use spitfire\core\parser\parser\ParseTree;
-use spitfire\core\parser\TokenBuffer;
-
-/*
- * The MIT License
- *
- * Copyright 2020 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class LiteralTerminalTest extends TestCase
-{
-
- public function testParsing() {
- $buff1 = new TokenBuffer([new Identifier('test')]);
- $buff2 = new TokenBuffer([new ReservedWord('test')]);
- $buff3 = new TokenBuffer([new Literal('test')]);
-
- $terminal = new LiteralTerminal();
-
- $block = new Block();
- $block->matches($terminal);
-
- $res3 = $block->test($buff3);
-
- $this->assertEquals(false, $block->test($buff1));
- $this->assertEquals(false, $block->test($buff2));
- $this->assertInstanceOf(ParseTree::class, $res3);
-
- $this->assertEquals('test', $res3->getLeafs()[0]->getBody());
- }
-
-}
diff --git a/tests/core/parser/parser/MultipleTest.php b/tests/core/parser/parser/MultipleTest.php
deleted file mode 100644
index a024e96..0000000
--- a/tests/core/parser/parser/MultipleTest.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php namespace tests\spitfire\core\parser\parser;
-
-use PHPUnit\Framework\TestCase;
-use spitfire\core\parser\lexemes\Literal;
-use spitfire\core\parser\parser\Block;
-use spitfire\core\parser\parser\LiteralTerminal;
-use spitfire\core\parser\TokenBuffer;
-
-/*
- * The MIT License
- *
- * Copyright 2020 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class MultipleTest extends TestCase
-{
-
- /**
- *
- */
- public function testBasic() {
-
- $tokens = new TokenBuffer([
- new Literal('hello'),
- new Literal('world'),
- new Literal('this'),
- new Literal('is ur'),
- new Literal('captain')
- ]);
-
- $block = new Block();
- $block->matches(Block::multiple(new LiteralTerminal()));
-
- $result = $block->test($tokens);
-
- $this->assertInstanceOf(\spitfire\core\parser\parser\ParseTree::class, $result);
- $this->assertEquals(1, count($result->getLeafs()));
- $this->assertEquals(5, count($result->getLeafs()[0]));
- }
-
- public function testBasic2() {
-
- $comma = new \spitfire\core\parser\lexemes\Symbol(',');
- $tokens = new TokenBuffer([
- new Literal('hello'),
- $comma,
- new Literal('world'),
- $comma,
- new Literal('this'),
- $comma,
- new Literal('is ur'),
- new Literal('captain')
- ]);
-
- $block = new Block();
- $block->matches(Block::multiple(new LiteralTerminal(), $comma));
-
- $result = $block->test($tokens);
-
- $this->assertInstanceOf(\spitfire\core\parser\parser\ParseTree::class, $result);
- $this->assertEquals(1, count($result->getLeafs()));
- $this->assertEquals(3, count($result->getLeafs()[0]));
- }
-
-}
diff --git a/tests/core/parser/parser/OptionalTest.php b/tests/core/parser/parser/OptionalTest.php
deleted file mode 100644
index bce8c22..0000000
--- a/tests/core/parser/parser/OptionalTest.php
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php namespace tests\spitfire\core\parser\parser;
-
-use PHPUnit\Framework\TestCase;
-use spitfire\core\parser\lexemes\Literal;
-use spitfire\core\parser\parser\Block;
-use spitfire\core\parser\parser\LiteralTerminal;
-use spitfire\core\parser\TokenBuffer;
-
-/*
- * The MIT License
- *
- * Copyright 2020 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class OptionalTest extends TestCase
-{
-
- /**
- *
- */
- public function testBasic() {
-
- $comma = new \spitfire\core\parser\lexemes\Symbol(',');
- $tokens = new TokenBuffer([
- new Literal('hello'),
- new Literal('world'),
- new Literal('this'),
- new Literal('is ur'),
- new Literal('captain')
- ]);
-
- $block = new Block();
- $block->matches(new LiteralTerminal(), Block::optional($comma), new LiteralTerminal());
-
- $result = $block->test($tokens);
-
- $this->assertInstanceOf(\spitfire\core\parser\parser\ParseTree::class, $result);
- $this->assertEquals(3, count($result->getLeafs()));
- $this->assertEquals(null, $result->getLeafs()[1]);
- }
-
- /**
- *
- */
- public function testBasic2() {
-
- $comma = new \spitfire\core\parser\lexemes\Symbol(',');
- $tokens = new TokenBuffer([
- new Literal('hello'),
- $comma,
- new Literal('world')
- ]);
-
- $block = new Block();
- $block->matches(new LiteralTerminal(), Block::optional($comma), new LiteralTerminal());
-
- $result = $block->test($tokens);
-
- $this->assertInstanceOf(\spitfire\core\parser\parser\ParseTree::class, $result);
- $this->assertEquals(3, count($result->getLeafs()));
- $this->assertInstanceOf(\spitfire\core\parser\lexemes\Symbol::class, $result->getLeafs()[1][0]);
- }
-
- /**
- *
- */
- public function testMultipleOptionalComponents() {
-
- $comma = new \spitfire\core\parser\lexemes\Symbol(',');
- $tokens = new TokenBuffer([
- new Literal('hello'),
- $comma,
- $comma,
- new Literal('world')
- ]);
-
- $block = new Block();
- $block->matches(new LiteralTerminal(), Block::optional($comma, $comma), new LiteralTerminal());
-
- $result = $block->test($tokens);
-
- $this->assertInstanceOf(\spitfire\core\parser\parser\ParseTree::class, $result);
- $this->assertEquals(3, count($result->getLeafs()));
- $this->assertInstanceOf(\spitfire\core\parser\lexemes\Symbol::class, $result->getLeafs()[1][0]);
- $this->assertInstanceOf(\spitfire\core\parser\lexemes\Symbol::class, $result->getLeafs()[1][1]);
- }
-
-}
diff --git a/tests/core/parser/scanner/IdentifierScannerTest.php b/tests/core/parser/scanner/IdentifierScannerTest.php
deleted file mode 100644
index b5cb40b..0000000
--- a/tests/core/parser/scanner/IdentifierScannerTest.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-
-use PHPUnit\Framework\TestCase;
-use spitfire\core\parser\scanner\IdentifierScanner;
-use spitfire\core\parser\StringBuffer;
-
-/*
- * The MIT License
- *
- * Copyright 2020 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/*
- * The identifier scanner must be able to consume identifiers from a string without
- * taking in too much or too little
- */
-class IdentifierScannerTest extends TestCase
-{
-
- public function testBasic() {
- $buffer = new StringBuffer('hello world');
- $scanner = new IdentifierScanner();
-
- $this->assertEquals('hello', $buffer->peek(5));
- $this->assertInstanceOf(\spitfire\core\parser\lexemes\Identifier::class, $scanner->in($buffer));
- $this->assertEquals(' world', $buffer->peek(6));
- }
-
- public function testHyphens() {
- $buffer = new StringBuffer('hello-world');
- $scanner = new IdentifierScanner();
-
- $this->assertInstanceOf(\spitfire\core\parser\lexemes\Identifier::class, $scanner->in($buffer));
- $this->assertEquals('-world', $buffer->peek(6));
- }
-
- public function testParentheses() {
- $buffer = new StringBuffer('hello(world)');
- $scanner = new IdentifierScanner();
-
- $this->assertInstanceOf(\spitfire\core\parser\lexemes\Identifier::class, $scanner->in($buffer));
- $this->assertEquals('(world', $buffer->peek(6));
- }
-
- public function testUnderscore() {
- $buffer = new StringBuffer('hello_world');
- $scanner = new IdentifierScanner();
-
- $this->assertEquals('hello', $buffer->peek(5));
- $this->assertInstanceOf(\spitfire\core\parser\lexemes\Identifier::class, $scanner->in($buffer));
- $this->assertEquals('', $buffer->peek(6));
- }
-
-}
diff --git a/tests/core/parser/scanner/IntegerLiteralScannerTest.php b/tests/core/parser/scanner/IntegerLiteralScannerTest.php
deleted file mode 100644
index 3e8472a..0000000
--- a/tests/core/parser/scanner/IntegerLiteralScannerTest.php
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php namespace tests\spitfire\core\parser\scanner;
-
-/*
- * The MIT License
- *
- * Copyright 2020 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-class IntegerLiteralScannerTest extends \PHPUnit\Framework\TestCase
-{
-
- public function testNumber() {
- $scanner = new \spitfire\core\parser\scanner\IntegerLiteralScanner();
- $this->assertEquals(1, $scanner->in(new \spitfire\core\parser\StringBuffer("1"))->getBody());
- $this->assertEquals(1, $scanner->in(new \spitfire\core\parser\StringBuffer("1 + 3"))->getBody());
- $this->assertEquals(1, $scanner->in(new \spitfire\core\parser\StringBuffer("1+3"))->getBody());
- }
-
- public function testNaN1() {
- $this->expectException(\spitfire\exceptions\PrivateException::class);
-
- $scanner = new \spitfire\core\parser\scanner\IntegerLiteralScanner();
- $scanner->in(new \spitfire\core\parser\StringBuffer("123helloworld"));
- }
-
- public function testFloat() {
- $scanner = new \spitfire\core\parser\scanner\IntegerLiteralScanner();
- $this->assertEquals(123.13, $scanner->in(new \spitfire\core\parser\StringBuffer("123.13"))->getBody());
- $this->assertEquals(123.13, $scanner->in(new \spitfire\core\parser\StringBuffer("123.13 + 256.3"))->getBody());
- $this->assertEquals(123.13, $scanner->in(new \spitfire\core\parser\StringBuffer("123.13+256.3"))->getBody());
- }
-
-}
diff --git a/tests/core/parser/scanner/LiteralScannerTest.php b/tests/core/parser/scanner/LiteralScannerTest.php
deleted file mode 100644
index acd1b33..0000000
--- a/tests/core/parser/scanner/LiteralScannerTest.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php namespace tests\spitfire\core\parser\scanner;
-
-use PHPUnit\Framework\TestCase;
-use spitfire\core\parser\scanner\LiteralScanner;
-use spitfire\core\parser\StringBuffer;
-use spitfire\exceptions\OutOfBoundsException;
-
-/*
- * The MIT License
- *
- * Copyright 2020 César de la Cal Bretschneider <cesar@magic3w.com>.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITE