Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Split parsing logic from AST objects #31

Merged
merged 64 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
ca51f99
!!!TASK: Give ImportNode only the source path, not the entire source
grebaldi Jul 25, 2023
1406f9e
TASK: Implement `BooleanLiteralParser`
grebaldi Jul 25, 2023
4c4ffa6
TASK: Implement `NullLiteralParser`
grebaldi Jul 25, 2023
c9064d0
TASK: Implement `IntegerLiteralParser`
grebaldi Jul 26, 2023
eb29f48
TASK: Implement `StringLiteralParser`
grebaldi Jul 26, 2023
8a20958
TASK: Implement `EnumDeclarationParser`
grebaldi Jul 27, 2023
d442e4b
TASK: Refactor BooleanLiteralParserTest to use single assertions
grebaldi Jul 27, 2023
6210071
TASK: Refactor IntegerLiteralParserTest to use single assertion
grebaldi Jul 27, 2023
583baef
TASK: Add cases for all integer formats to IntegerLiteralParserTest
grebaldi Jul 27, 2023
0cf8fa8
TASK: Refactor NullLiteralParserTest to use single assertion
grebaldi Jul 27, 2023
28ec204
TASK: Refactor StringLiteralParserTest to use single assertion
grebaldi Jul 27, 2023
14cc6d6
TASK: Rename Location to NodeAttributes
grebaldi Jul 27, 2023
7dd44fc
TASK: Move all members of AST namespace to AST\Node
grebaldi Jul 27, 2023
9bf87f0
TASK: Move NodeAttributes class to AST namespace
grebaldi Jul 27, 2023
bc87d13
TASK: Add abstract Node class for all AST nodes to inherit from
grebaldi Jul 27, 2023
a392481
TASK: Add cases for all integer formats to EnumDeclarationParserTest
grebaldi Jul 27, 2023
c0c564e
TASK: Rename Boundaries::fromPositions -> Boundaries::from
grebaldi Jul 27, 2023
b56aae8
TASK: Rename Boundaries -> Range
grebaldi Jul 27, 2023
f34588c
TASK: Rename Position::create -> Position::from
grebaldi Jul 27, 2023
d20042a
TASK: Remove dead equals method from Token class
grebaldi Jul 27, 2023
149d6a4
TASK: Remove dead code from Range class
grebaldi Jul 27, 2023
319be86
TASK: Remove dead code from Position class
grebaldi Jul 27, 2023
b67b004
TASK: Reduce Position class to contain only lineNumber and columnNumber
grebaldi Jul 27, 2023
ea11e11
TASK: Split parse method of EnumDeclarationParser
grebaldi Jul 27, 2023
d0e38e4
TASK: Turn name of EnumDeclarationNode into an AST Node as well
grebaldi Jul 27, 2023
910a54a
TASK: Turn name and value of EnumMemberDeclarationNode into an AST No…
grebaldi Jul 28, 2023
af729d5
TASK: Instantiate subsequent parsers in constructor of EnumDeclaratio…
grebaldi Jul 28, 2023
4f4f737
TASK: Rename property memberDeclarations to members in EnumDeclaratio…
grebaldi Jul 28, 2023
c5d13c1
TASK: Implement TypeReferenceParser
grebaldi Jul 28, 2023
c28ce28
TASK: Wrap type name in additional AST node within TypeReferenceNode
grebaldi Jul 28, 2023
f192958
TASK: Allow for type references to refer to multiple types in principle
grebaldi Jul 28, 2023
312dfc3
TASK: Add constraints for union type references
grebaldi Jul 28, 2023
ef6a732
FEATURE: Parse references to union types
grebaldi Jul 31, 2023
d47936b
TASK: Remove pathToSource property from NodeAttributes
grebaldi Jul 31, 2023
2e86dca
TASK: Let ParserException carry only the affected range in source
grebaldi Jul 31, 2023
2ab3f72
TASK: Refactor TypeReferenceParser
grebaldi Jul 31, 2023
8c85541
TASK: Implement PropertyDeclarationParser
grebaldi Jul 31, 2023
93dea79
TASK: Implement StructDeclarationParser
grebaldi Aug 1, 2023
2f5a0a1
TASK: Implement TextParser
grebaldi Aug 1, 2023
f908a6d
TASK: Implement ValueReferenceParser
grebaldi Aug 2, 2023
a980d7d
TASK: Add AST node objects for all remaining expression-related concepts
grebaldi Aug 2, 2023
e9cc01e
TASK: Implement TagParser with limited capabilities
grebaldi Aug 2, 2023
6e44ca4
TASK: Remove NodeAttributes class
grebaldi Aug 2, 2023
9098ce2
TASK: Rename property tagAttributes of TagNode to attributes
grebaldi Aug 2, 2023
1d1e101
TASK: Refactor TextParser after builder pattern
grebaldi Aug 2, 2023
ac7f3ec
TASK: Implement ExpressionParser (partially)
grebaldi Aug 3, 2023
e88566a
TASK: Implement TemplateLiteralParser
grebaldi Aug 3, 2023
19c56cb
TASK: Implement MatchParser
grebaldi Aug 4, 2023
4e7760f
TASK: Implement ComponentDeclarationParser
grebaldi Aug 4, 2023
e7aed5a
TASK: Implement ImportParser
grebaldi Aug 4, 2023
99bb80a
TASK: Implement ExportParser
grebaldi Aug 4, 2023
ba7e0bb
TASK: Implement ModuleParser
grebaldi Aug 5, 2023
d7a3d8e
TASK: Pass token iterator by-reference in all Parser implementations
grebaldi Aug 5, 2023
8d5ff20
TASK: Replace IntegerFormat::fromTokenType with parser-specific method
grebaldi Aug 5, 2023
f2e47cc
TASK: Refactor all parser tests, so they inherit from base test case
grebaldi Aug 5, 2023
fb4b6c5
TASK: Turn parsers into singletons where applicable
grebaldi Aug 5, 2023
8af0e0e
TASK: Add test cases for complex bracketed expressions
grebaldi Aug 5, 2023
36cd9bb
!!!TASK: Remove old AST objects and adjust dependent classes/tests
grebaldi Aug 6, 2023
30e2600
TASK: Remove leftover AST and Token snapshots
grebaldi Aug 6, 2023
c0dbace
!!!TASK: Rename IdentifierTypeResolver -> ValueReferenceTypeResolver
grebaldi Aug 6, 2023
b2c75cb
!!!TASK: Rename IdentifierTranspiler -> ValueReferenceTranspiler
grebaldi Aug 6, 2023
68f4fa2
TASK: Turn all Domain\* name objects into flyweights
grebaldi Aug 6, 2023
3bac790
TASK: Reform GlobalScope to use explicit type names
grebaldi Aug 6, 2023
5b3f7ca
!!!TASK: Refactor all remaining Singletons with Singleton Trait
grebaldi Aug 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

./vendor/bin/phpunit \
--enforce-time-limit \
--testdox \
--display-deprecations \
--display-errors \
--display-notices \
--coverage-html build/coverage-report \
--coverage-filter src $@
72 changes: 0 additions & 72 deletions src/Definition/BinaryOperator.php

This file was deleted.

41 changes: 41 additions & 0 deletions src/Domain/AttributeName/AttributeName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/**
* PackageFactory.ComponentEngine - Universal View Components for PHP
* Copyright (C) 2023 Contributors of PackageFactory.ComponentEngine
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

declare(strict_types=1);

namespace PackageFactory\ComponentEngine\Domain\AttributeName;

final class AttributeName
{
/**
* @var array<string,self>
*/
private static array $instances = [];

private function __construct(
public readonly string $value
) {
}

public static function from(string $string): self
{
return self::$instances[$string] ??= new self($string);
}
}
48 changes: 48 additions & 0 deletions src/Domain/ComponentName/ComponentName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* PackageFactory.ComponentEngine - Universal View Components for PHP
* Copyright (C) 2022 Contributors of PackageFactory.ComponentEngine
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

declare(strict_types=1);

namespace PackageFactory\ComponentEngine\Domain\ComponentName;

use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;

final class ComponentName
{
/**
* @var array<string,self>
*/
private static array $instances = [];

private function __construct(
public readonly string $value
) {
}

public static function from(string $string): self
{
return self::$instances[$string] ??= new self($string);
}

public function toTypeName(): TypeName
{
return TypeName::from($this->value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,22 @@

declare(strict_types=1);

namespace PackageFactory\ComponentEngine\Definition;
namespace PackageFactory\ComponentEngine\Domain\EnumMemberName;

use PackageFactory\ComponentEngine\Parser\Tokenizer\TokenType;

enum IntegerFormat: string
final class EnumMemberName
{
case BINARY = 'BINARY';
case OCTAL = 'OCTAL';
case DECIMAL = 'DECIMAL';
case HEXADECIMAL = 'HEXADECIMAL';
/**
* @var array<string,self>
*/
private static array $instances = [];

public static function fromTokenType(TokenType $tokenType): self
{
return match ($tokenType) {
TokenType::NUMBER_BINARY => self::BINARY,
TokenType::NUMBER_OCTAL => self::OCTAL,
TokenType::NUMBER_DECIMAL => self::DECIMAL,
TokenType::NUMBER_HEXADECIMAL => self::HEXADECIMAL,
private function __construct(
public readonly string $value
) {
}

default => throw new \Exception('@TODO: Unknown Integer Format: ' . $tokenType->value)
};
public static function from(string $string): self
{
return self::$instances[$string] ??= new self($string);
}
}
48 changes: 48 additions & 0 deletions src/Domain/EnumName/EnumName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* PackageFactory.ComponentEngine - Universal View Components for PHP
* Copyright (C) 2022 Contributors of PackageFactory.ComponentEngine
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

declare(strict_types=1);

namespace PackageFactory\ComponentEngine\Domain\EnumName;

use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;

final class EnumName
{
/**
* @var array<string,self>
*/
private static array $instances = [];

private function __construct(
public readonly string $value
) {
}

public static function from(string $string): self
{
return self::$instances[$string] ??= new self($string);
}

public function toTypeName(): TypeName
{
return TypeName::from($this->value);
}
}
48 changes: 48 additions & 0 deletions src/Domain/PropertyName/PropertyName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* PackageFactory.ComponentEngine - Universal View Components for PHP
* Copyright (C) 2023 Contributors of PackageFactory.ComponentEngine
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

declare(strict_types=1);

namespace PackageFactory\ComponentEngine\Domain\PropertyName;

use PackageFactory\ComponentEngine\Domain\EnumMemberName\EnumMemberName;

final class PropertyName
{
/**
* @var array<string,self>
*/
private static array $instances = [];

private function __construct(
public readonly string $value
) {
}

public static function from(string $string): self
{
return self::$instances[$string] ??= new self($string);
}

public function toEnumMemberName(): EnumMemberName
{
return EnumMemberName::from($this->value);
}
}
48 changes: 48 additions & 0 deletions src/Domain/StructName/StructName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* PackageFactory.ComponentEngine - Universal View Components for PHP
* Copyright (C) 2022 Contributors of PackageFactory.ComponentEngine
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

declare(strict_types=1);

namespace PackageFactory\ComponentEngine\Domain\StructName;

use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;

final class StructName
{
/**
* @var array<string,self>
*/
private static array $instances = [];

private function __construct(
public readonly string $value
) {
}

public static function from(string $string): self
{
return self::$instances[$string] ??= new self($string);
}

public function toTypeName(): TypeName
{
return TypeName::from($this->value);
}
}
Loading
Loading