Skip to content

Commit

Permalink
!!!TASK: Remove old AST objects and adjust dependent classes/tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grebaldi committed Aug 6, 2023
1 parent 8af0e0e commit 36cd9bb
Show file tree
Hide file tree
Showing 173 changed files with 2,092 additions and 4,166 deletions.
1 change: 0 additions & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@
--display-deprecations \
--display-errors \
--display-notices \
--testdox \
--coverage-html build/coverage-report \
--coverage-filter src $@
72 changes: 0 additions & 72 deletions src/Definition/BinaryOperator.php

This file was deleted.

79 changes: 0 additions & 79 deletions src/Definition/Precedence.php

This file was deleted.

7 changes: 7 additions & 0 deletions src/Domain/ComponentName/ComponentName.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

namespace PackageFactory\ComponentEngine\Domain\ComponentName;

use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;

final class ComponentName
{
private function __construct(
Expand All @@ -33,4 +35,9 @@ public static function from(string $string): self
{
return new self($string);
}

public function toTypeName(): TypeName
{
return TypeName::from($this->value);
}
}
7 changes: 7 additions & 0 deletions src/Domain/EnumName/EnumName.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

namespace PackageFactory\ComponentEngine\Domain\EnumName;

use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;

final class EnumName
{
private function __construct(
Expand All @@ -33,4 +35,9 @@ public static function from(string $string): self
{
return new self($string);
}

public function toTypeName(): TypeName
{
return TypeName::from($this->value);
}
}
7 changes: 7 additions & 0 deletions src/Domain/PropertyName/PropertyName.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

namespace PackageFactory\ComponentEngine\Domain\PropertyName;

use PackageFactory\ComponentEngine\Domain\EnumMemberName\EnumMemberName;

final class PropertyName
{
private function __construct(
Expand All @@ -33,4 +35,9 @@ public static function from(string $string): self
{
return new self($string);
}

public function toEnumMemberName(): EnumMemberName
{
return EnumMemberName::from($this->value);
}
}
7 changes: 7 additions & 0 deletions src/Domain/StructName/StructName.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

namespace PackageFactory\ComponentEngine\Domain\StructName;

use PackageFactory\ComponentEngine\Domain\TypeName\TypeName;

final class StructName
{
private function __construct(
Expand All @@ -33,4 +35,9 @@ public static function from(string $string): self
{
return new self($string);
}

public function toTypeName(): TypeName
{
return TypeName::from($this->value);
}
}
9 changes: 8 additions & 1 deletion src/Domain/TypeName/TypeName.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* PackageFactory.ComponentEngine - Universal View Components for PHP
* Copyright (C) 2022 Contributors of PackageFactory.ComponentEngine
* 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
Expand All @@ -22,6 +22,8 @@

namespace PackageFactory\ComponentEngine\Domain\TypeName;

use PackageFactory\ComponentEngine\Domain\VariableName\VariableName;

final class TypeName
{
private function __construct(
Expand All @@ -33,4 +35,9 @@ public static function from(string $string): self
{
return new self($string);
}

public function toVariableName(): VariableName
{
return VariableName::from($this->value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ public function __construct(PropertyDeclarationNode ...$items)

$this->items = $itemsAsHashMap;
}

public function isEmpty(): bool
{
return count($this->items) === 0;
}
}
17 changes: 13 additions & 4 deletions src/Language/Parser/Expression/ExpressionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use PackageFactory\ComponentEngine\Parser\Tokenizer\Token;
use PackageFactory\ComponentEngine\Parser\Tokenizer\TokenType;
use PackageFactory\ComponentEngine\Parser\Tokenizer\TokenTypes;
use PhpParser\Parser\Tokens;

final class ExpressionParser
{
Expand All @@ -69,23 +70,31 @@ public function __construct(
*/
public function parse(\Iterator &$tokens): ExpressionNode
{
Scanner::skipSpaceAndComments($tokens);

$result = $this->parseUnaryStatement($tokens);

if ($this->shouldStop($tokens)) {
return $result;
}

$result = match (Scanner::type($tokens)) {
$binaryOperationTokens = TokenTypes::from(
TokenType::OPERATOR_BOOLEAN_AND,
TokenType::OPERATOR_BOOLEAN_OR,
TokenType::COMPARATOR_EQUAL,
TokenType::COMPARATOR_NOT_EQUAL,
TokenType::COMPARATOR_GREATER_THAN,
TokenType::COMPARATOR_GREATER_THAN_OR_EQUAL,
TokenType::COMPARATOR_LESS_THAN,
TokenType::COMPARATOR_LESS_THAN_OR_EQUAL => $this->parseBinaryOperation($tokens, $result),
default => $result
};
TokenType::COMPARATOR_LESS_THAN_OR_EQUAL
);

while (
!$this->shouldStop($tokens) &&
$binaryOperationTokens->contains(Scanner::type($tokens))
) {
$result = $this->parseBinaryOperation($tokens, $result);
}

if ($this->shouldStop($tokens)) {
return $result;
Expand Down
Loading

0 comments on commit 36cd9bb

Please sign in to comment.