summaryrefslogtreecommitdiff
path: root/src/Parser
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2025-02-06 13:59:50 +0100
committerDaniel Weipert <git@mail.dweipert.de>2025-02-06 13:59:50 +0100
commit54b4040a8e46c4104e228264fa57b44d17e245c9 (patch)
tree938f077f1343ee018476bd1cf68924f9181143f1 /src/Parser
parent7667162a20ebdedac14de88260df018b961548d4 (diff)
all current tests passing
Diffstat (limited to 'src/Parser')
-rw-r--r--src/Parser/Parser.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/Parser/Parser.php b/src/Parser/Parser.php
index 1ce092c..a3a6839 100644
--- a/src/Parser/Parser.php
+++ b/src/Parser/Parser.php
@@ -294,6 +294,11 @@ class Parser
$this->advance(1);
}
+ else if ($currentToken->type == TokenType::PipePlaceholder) {
+ $currentExpression = new IdentifierNode($currentToken);
+ $this->advance(1);
+ }
+
else if ($currentToken->literal == "(") {
if ($this->getNextToken(2)->literal == ":") {
$currentExpression = $this->parseFunctionDefinition();
@@ -559,9 +564,9 @@ class Parser
$this->advance(1);
}
- /*else if ($currentToken->type == TokenType::Identifier) {
+ else if ($currentToken->type == TokenType::Identifier) {
$body[] = $this->parseFunctionCall();
- }*/
+ }
else {
$error = sprintf("Unexpected %s at %d:%d" . PHP_EOL, $currentToken->value, $currentToken->line, $currentToken->column);
@@ -833,6 +838,11 @@ class NumberNode extends Node
public Token $token,
public int|float $value,
) {}
+
+ public function getValue(): int|float
+ {
+ return $this->value;
+ }
}
class StringNode extends Node
@@ -840,6 +850,11 @@ class StringNode extends Node
public function __construct(
public Token $token,
) {}
+
+ public function getValue(): string
+ {
+ return $this->token->value;
+ }
}
class BoolNode extends Node
@@ -847,6 +862,11 @@ class BoolNode extends Node
public function __construct(
public Token $token,
) {}
+
+ public function getValue(): bool
+ {
+ return filter_var($this->token->value, FILTER_VALIDATE_BOOLEAN);
+ }
}
class CommentNode extends Node