logo       

4155 - in trunk/Template: src src/parsers/source_to_tst/implementations tes: msg#00330

web.ezcomponents.cvs

Subject: 4155 - in trunk/Template: src src/parsers/source_to_tst/implementations tests/regression_tests/expressions/correct [eZComponents: Trunk]

Author: Raymond Bosman
Date: 2006-11-30 16:19:33 +0100 (Thu, 30 Nov 2006)
New Revision: 4155

Log:
- Fixed an issue that assignments can be used inside an expression. This
is not allowed.

Modified:
trunk/Template/src/error_messages.php
trunk/Template/src/parsers/source_to_tst/implementations/array.php
trunk/Template/src/parsers/source_to_tst/implementations/array_fetch.php
trunk/Template/src/parsers/source_to_tst/implementations/cache.php
trunk/Template/src/parsers/source_to_tst/implementations/custom_block.php
trunk/Template/src/parsers/source_to_tst/implementations/declaration.php
trunk/Template/src/parsers/source_to_tst/implementations/delimiter.php
trunk/Template/src/parsers/source_to_tst/implementations/foreach_loop.php
trunk/Template/src/parsers/source_to_tst/implementations/if_condition.php
trunk/Template/src/parsers/source_to_tst/implementations/include.php
trunk/Template/src/parsers/source_to_tst/implementations/switch_condition.php
trunk/Template/src/parsers/source_to_tst/implementations/while_loop.php
trunk/Template/tests/regression_tests/expressions/correct/array_fetch.in
trunk/Template/tests/regression_tests/expressions/correct/array_fetch.out

Modified: trunk/Template/src/error_messages.php
===================================================================
--- trunk/Template/src/error_messages.php 2006-11-30 15:14:48 UTC (rev
4154)
+++ trunk/Template/src/error_messages.php 2006-11-30 15:19:33 UTC (rev
4155)
@@ -87,6 +87,7 @@
const MSG_OPERATOR_IS_MODIFYING_BLOCK = "Unexpected operand or
expression. The operand or expression modifies a variable, which is not
allowed.";

const MSG_PARAMETER_CANNOT_BE_MODIFYING_BLOCK = "The given parameter is
not allowed to modify a variable.";
+ const MSG_MODIFYING_EXPRESSION_NOT_ALLOWED = "An expression that
modifies a variable is not allowed.";


const MSG_OBJECT_FUNCTION_CALL_NOT_ALLOWED = "Calling a method from an
imported object is not allowed.";

Modified: trunk/Template/src/parsers/source_to_tst/implementations/array.php
===================================================================
--- trunk/Template/src/parsers/source_to_tst/implementations/array.php
2006-11-30 15:14:48 UTC (rev 4154)
+++ trunk/Template/src/parsers/source_to_tst/implementations/array.php
2006-11-30 15:19:33 UTC (rev 4155)
@@ -128,6 +128,12 @@
$elementNumber++;
}

+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
+
$this->findNextElement();

// We allow a comma after the key/value even if there are no more

Modified:
trunk/Template/src/parsers/source_to_tst/implementations/array_fetch.php
===================================================================
--- trunk/Template/src/parsers/source_to_tst/implementations/array_fetch.php
2006-11-30 15:14:48 UTC (rev 4154)
+++ trunk/Template/src/parsers/source_to_tst/implementations/array_fetch.php
2006-11-30 15:19:33 UTC (rev 4155)
@@ -59,6 +59,11 @@
throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_EXPRESSION );
}

+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
$this->fetch->endCursor = clone
$this->lastParser->currentOperator->endCursor;
$this->fetch->appendParameter( $this->lastParser->currentOperator );
$this->parser->reportElementCursor( $this->fetch->startCursor,
$this->fetch->endCursor, $this->fetch );

Modified: trunk/Template/src/parsers/source_to_tst/implementations/cache.php
===================================================================
--- trunk/Template/src/parsers/source_to_tst/implementations/cache.php
2006-11-30 15:14:48 UTC (rev 4154)
+++ trunk/Template/src/parsers/source_to_tst/implementations/cache.php
2006-11-30 15:19:33 UTC (rev 4155)
@@ -117,6 +117,11 @@
{
throw new ezcTemplateParserException(
$this->parser->source, $this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_EXPRESSION );
}
+
+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException(
$this->parser->source, $this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }

// Append the parameter to the "namedParameters" array.
$cacheNode->ttl = $this->lastParser->rootOperator;
@@ -205,6 +210,11 @@
}
else
{
+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException(
$this->parser->source, $this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
$cb->namedParameters[ $def->startExpressionName ] =
$this->lastParser->rootOperator;
$this->findNextElement( $cursor );
}
@@ -244,6 +254,12 @@
{
throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_EXPRESSION );
}
+
+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+

// Append the parameter to the "namedParameters" array.
$cb->namedParameters[ $match ] = $this->lastParser->rootOperator;

Modified:
trunk/Template/src/parsers/source_to_tst/implementations/custom_block.php
===================================================================
--- trunk/Template/src/parsers/source_to_tst/implementations/custom_block.php
2006-11-30 15:14:48 UTC (rev 4154)
+++ trunk/Template/src/parsers/source_to_tst/implementations/custom_block.php
2006-11-30 15:19:33 UTC (rev 4155)
@@ -119,6 +119,11 @@
}
else
{
+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException(
$this->parser->source, $this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
$cb->namedParameters[ $def->startExpressionName ] =
$this->lastParser->rootOperator;
$this->findNextElement( $cursor );
}
@@ -158,7 +163,13 @@
{
throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_EXPRESSION );
}
-
+
+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
+
// Append the parameter to the "namedParameters" array.
$cb->namedParameters[ $match ] = $this->lastParser->rootOperator;
}

Modified:
trunk/Template/src/parsers/source_to_tst/implementations/declaration.php
===================================================================
--- trunk/Template/src/parsers/source_to_tst/implementations/declaration.php
2006-11-30 15:14:48 UTC (rev 4154)
+++ trunk/Template/src/parsers/source_to_tst/implementations/declaration.php
2006-11-30 15:19:33 UTC (rev 4155)
@@ -127,6 +127,11 @@
}
}

+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException(
$this->parser->source, $this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
$declaration->expression = $this->lastParser->rootOperator;
}


Modified: trunk/Template/src/parsers/source_to_tst/implementations/delimiter.php
===================================================================
--- trunk/Template/src/parsers/source_to_tst/implementations/delimiter.php
2006-11-30 15:14:48 UTC (rev 4154)
+++ trunk/Template/src/parsers/source_to_tst/implementations/delimiter.php
2006-11-30 15:19:33 UTC (rev 4155)
@@ -62,6 +62,11 @@
throw new ezcTemplateSourceToTstParserException( $this,
$this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_EXPRESSION );
}

+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException(
$this->parser->source, $this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
$delimiter->modulo = $this->lastParser->rootOperator;

if ( $this->currentCursor->match( "is" ) )
@@ -72,6 +77,11 @@
throw new ezcTemplateParserException(
$this->parser->source, $this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_EXPRESSION );
}

+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException(
$this->parser->source, $this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
$delimiter->rest = $this->lastParser->rootOperator;
$this->findNextElement();
}

Modified:
trunk/Template/src/parsers/source_to_tst/implementations/foreach_loop.php
===================================================================
--- trunk/Template/src/parsers/source_to_tst/implementations/foreach_loop.php
2006-11-30 15:14:48 UTC (rev 4154)
+++ trunk/Template/src/parsers/source_to_tst/implementations/foreach_loop.php
2006-11-30 15:19:33 UTC (rev 4155)
@@ -56,6 +56,12 @@
{
throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_EXPRESSION );
}
+
+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
$el->array = $this->lastParser->rootOperator;

$this->findNextElement();
@@ -137,6 +143,11 @@
throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_EXPRESSION );
}

+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
$el->offset = $this->lastParser->rootOperator;
$this->findNextElement();
}
@@ -151,6 +162,12 @@
throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_EXPRESSION );
}

+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
+
$el->limit = $this->lastParser->rootOperator;
$this->findNextElement();
}

Modified:
trunk/Template/src/parsers/source_to_tst/implementations/if_condition.php
===================================================================
--- trunk/Template/src/parsers/source_to_tst/implementations/if_condition.php
2006-11-30 15:14:48 UTC (rev 4154)
+++ trunk/Template/src/parsers/source_to_tst/implementations/if_condition.php
2006-11-30 15:19:33 UTC (rev 4155)
@@ -66,6 +66,11 @@
}

$condition = $this->lastParser->rootOperator;
+ if( $condition instanceof ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
$this->findNextElement();
}


Modified: trunk/Template/src/parsers/source_to_tst/implementations/include.php
===================================================================
--- trunk/Template/src/parsers/source_to_tst/implementations/include.php
2006-11-30 15:14:48 UTC (rev 4154)
+++ trunk/Template/src/parsers/source_to_tst/implementations/include.php
2006-11-30 15:19:33 UTC (rev 4155)
@@ -54,6 +54,12 @@
{
throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_EXPRESSION );
}
+
+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+

$include = new ezcTemplateIncludeTstNode( $this->parser->source,
$this->startCursor, $this->currentCursor );
$include->file = $this->lastParser->rootOperator;
@@ -105,6 +111,11 @@

if ( $this->parseOptionalType( "Expression", null, false ) )
{
+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException(
$this->parser->source, $this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
if ( $this->lastParser->rootOperator instanceof
ezcTemplateVariableTstNode )
{
$asOptional = true;
@@ -267,6 +278,11 @@
}
}

+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException(
$this->parser->source, $this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
$declaration->expression = $this->lastParser->rootOperator;
}


Modified:
trunk/Template/src/parsers/source_to_tst/implementations/switch_condition.php
===================================================================
---
trunk/Template/src/parsers/source_to_tst/implementations/switch_condition.php
2006-11-30 15:14:48 UTC (rev 4154)
+++
trunk/Template/src/parsers/source_to_tst/implementations/switch_condition.php
2006-11-30 15:19:33 UTC (rev 4155)
@@ -70,6 +70,12 @@
throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_EXPRESSION );
}

+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
+
$this->findNextElement();
if ( !$cursor->match( '}' ) )
{

Modified:
trunk/Template/src/parsers/source_to_tst/implementations/while_loop.php
===================================================================
--- trunk/Template/src/parsers/source_to_tst/implementations/while_loop.php
2006-11-30 15:14:48 UTC (rev 4154)
+++ trunk/Template/src/parsers/source_to_tst/implementations/while_loop.php
2006-11-30 15:19:33 UTC (rev 4155)
@@ -43,6 +43,11 @@
throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_EXPECT_EXPRESSION );
}

+ if( $this->lastParser->rootOperator instanceof
ezcTemplateModifyingOperatorTstNode )
+ {
+ throw new ezcTemplateParserException( $this->parser->source,
$this->startCursor, $this->currentCursor,
ezcTemplateSourceToTstErrorMessages::MSG_MODIFYING_EXPRESSION_NOT_ALLOWED );
+ }
+
$condition = $this->lastParser->rootOperator;
}


Modified:
trunk/Template/tests/regression_tests/expressions/correct/array_fetch.in
===================================================================
--- trunk/Template/tests/regression_tests/expressions/correct/array_fetch.in
2006-11-30 15:14:48 UTC (rev 4154)
+++ trunk/Template/tests/regression_tests/expressions/correct/array_fetch.in
2006-11-30 15:19:33 UTC (rev 4155)
@@ -3,6 +3,3 @@
{$a[0]}
{$a[1 + 0 / 1]}
{$a[$b]}
-{$a[--$b]}
-{$a[$b--]}
-{$a[$b]}

Modified:
trunk/Template/tests/regression_tests/expressions/correct/array_fetch.out
===================================================================
--- trunk/Template/tests/regression_tests/expressions/correct/array_fetch.out
2006-11-30 15:14:48 UTC (rev 4154)
+++ trunk/Template/tests/regression_tests/expressions/correct/array_fetch.out
2006-11-30 15:19:33 UTC (rev 4155)
@@ -1,6 +1,3 @@
1
1
3
-2
-2
-1



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise