commit c8b1e04112bce95ba03d008e87e199f0f1c4ebc0
parent bd7b66c467041339a6f104d53f7b1ba2fe54d775
Author: Jan Dankert <develop@jandankert.de>
Date: Mon, 6 Jun 2022 13:35:56 +0200
Change: Completely ignoring let,var,const statements.
Diffstat:
3 files changed, 4 insertions(+), 50 deletions(-)
diff --git a/modules/dsl/ast/DslAssignment.class.php b/modules/dsl/ast/DslAssignment.class.php
@@ -34,8 +34,10 @@ class DslAssignment implements DslStatement
$value = $this->value->execute( $context );
- if ( ! array_key_exists( $this->target->name,$context ) )
- throw new DslRuntimeException('variable \''.$this->target->name.'\' does not exist');
+ // if the variable is not already bound in this context it will be created.
+ // there is no need for a "var" or "let". they are completely obsolet.
+ //if ( ! array_key_exists( $this->target->name,$context ) )
+ // throw new DslRuntimeException('variable \''.$this->target->name.'\' does not exist');
$context[ $this->target->name ] = $value;
diff --git a/modules/dsl/ast/DslInitialisation.class.php b/modules/dsl/ast/DslInitialisation.class.php
@@ -1,32 +0,0 @@
-<?php
-
-namespace dsl\ast;
-
-use dsl\DslRuntimeException;
-use dsl\DslToken;
-
-class DslInitialisation implements DslStatement
-{
- private $name;
- private $value;
-
- public function __construct( $name, $parameters )
- {
- $this->name = $name;
- $this->value = new DslExpression( $parameters );
- }
-
- public function execute( & $context ) {
- if ( array_key_exists( $this->name, $context ) )
- throw new DslRuntimeException('variable '.$this->name.' is already initialised');
-
- $context[ $this->name ] = $this->value->execute( $context );
- //echo "new var: ".$this->name.':'.$context[$this->name];
-
- }
-
- public function parse($tokens)
- {
- // TODO: Implement parse() method.
- }
-}
-\ No newline at end of file
diff --git a/modules/dsl/ast/DslStatementList.class.php b/modules/dsl/ast/DslStatementList.class.php
@@ -100,21 +100,6 @@ class DslStatementList extends DslElement implements DslStatement
break;
case DslToken::T_LET:
- $statementTokens = $this->getSingleStatement( $tokens );
- $nextToken = array_shift($statementTokens );
- if ($nextToken->type != DslToken::T_STRING)
- throw new DslParserException('only variables may be initialized', $token->lineNumber);
- $name = $nextToken->value;
-
- $nextToken = array_shift($statementTokens);
- if ( $nextToken == null )
- $value = null;
- elseif ($nextToken->type == DslToken::T_OPERATOR && $nextToken->value == '=')
- $value = $statementTokens;
- else
- throw new DslParserException('Unexpected token in initialisation', $token->lineNumber);
-
- $this->statements[] = new DslInitialisation( $name, $value );
break;
case DslToken::T_FOR: